diff --git a/Jenkinsfile b/Jenkinsfile index fcfc17a86f..b188539b14 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,18 +18,6 @@ fi ln -snf ${env.TEST_DIR} /data/pythonpath -if [ -f /EON ]; then - # kill all old procs in the openpilot cpuset - while read p; do - kill "\$p" || true - done < /dev/cpuset/app/tasks - - echo \$\$ > /dev/cpuset/app/tasks || true - - mkdir -p /dev/shm - chmod 777 /dev/shm -fi - cd ${env.TEST_DIR} || true ${cmd} exit 0 @@ -62,29 +50,15 @@ pipeline { } stages { - stage('build releases') { + stage('build release3') { + agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } } when { branch 'devel-staging' } - - parallel { - stage('release2') { - agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } } - steps { - phone_steps("eon-build", [ - ["build release2-staging & dashcam-staging", "PUSH=1 $SOURCE_DIR/release/build_release.sh"], - ]) - } - } - - stage('release3') { - agent { docker { image 'ghcr.io/commaai/alpine-ssh'; args '--user=root' } } - steps { - phone_steps("tici", [ - ["build release3-staging & dashcam3-staging", "PUSH=1 $SOURCE_DIR/release/build_release.sh"], - ]) - } - } + steps { + phone_steps("tici", [ + ["build release3-staging & dashcam3-staging", "PUSH=1 $SOURCE_DIR/release/build_release.sh"], + ]) } } @@ -106,41 +80,6 @@ pipeline { stages { stage('parallel tests') { parallel { - stage('C2: build') { - steps { - phone_steps("eon-build", [ - ["build master-ci", "cd $SOURCE_DIR/release && EXTRA_FILES='tools/' ./build_devel.sh"], - ["build openpilot", "cd selfdrive/manager && ./build.py"], - ["test manager", "python selfdrive/manager/test/test_manager.py"], - ["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"], - ["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"], - ]) - } - } - - stage('C2: replay') { - steps { - phone_steps("eon2", [ - ["build", "cd selfdrive/manager && ./build.py"], - ["model replay", "cd selfdrive/test/process_replay && ./model_replay.py"], - ]) - } - } - - stage('C2: HW + Unit Tests') { - steps { - phone_steps("eon", [ - ["build", "cd selfdrive/manager && ./build.py"], - ["test sounds", "python selfdrive/ui/tests/test_soundd.py"], - ["test boardd loopback", "python selfdrive/boardd/tests/test_boardd_loopback.py"], - ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"], - ["test encoder", "python selfdrive/loggerd/tests/test_encoder.py"], - ["test logcatd", "python selfdrive/logcatd/tests/test_logcatd_android.py"], - ["test updater", "python selfdrive/hardware/eon/test_neos_updater.py"], - ]) - } - } - /* stage('Power Consumption Tests') { steps { @@ -162,7 +101,7 @@ pipeline { } */ - stage('C3: build') { + stage('build') { environment { R3_PUSH = "${env.BRANCH_NAME == 'master' ? '1' : ' '}" } @@ -177,7 +116,7 @@ pipeline { } } - stage('C3: HW + Unit Tests') { + stage('HW + Unit Tests') { steps { phone_steps("tici2", [ ["build", "cd selfdrive/manager && ./build.py"], @@ -188,17 +127,7 @@ pipeline { } } - stage('C2: camerad') { - steps { - phone_steps("eon-party", [ - ["build", "cd selfdrive/manager && ./build.py"], - ["test camerad", "python selfdrive/camerad/test/test_camerad.py"], - ["test exposure", "python selfdrive/camerad/test/test_exposure.py"], - ]) - } - } - - stage('C3: camerad') { + stage('camerad') { steps { phone_steps("tici-party", [ ["build", "cd selfdrive/manager && ./build.py"], @@ -208,7 +137,7 @@ pipeline { } } - stage('C3: replay') { + stage('replay') { steps { phone_steps("tici3", [ ["build", "cd selfdrive/manager && ./build.py"], @@ -225,7 +154,7 @@ pipeline { branch 'master' } steps { - phone_steps("eon-build", [ + phone_steps("tici-build", [ ["push devel", "cd $SOURCE_DIR/release && PUSH='master-ci' ./build_devel.sh"], ]) } diff --git a/README.md b/README.md index b012883d78..5af02de8d9 100755 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ Running in a car To use openpilot in a car, you need four things * This software. It's free and available right here. * One of [the 150+ supported cars](docs/CARS.md). We support Honda, Toyota, Hyundai, Nissan, Kia, Chrysler, Lexus, Acura, Audi, VW, and more. If your car is not supported, but has adaptive cruise control and lane keeping assist, it's likely able to run openpilot. -* A supported device to run this software. This can be a [comma two](https://comma.ai/shop/products/two), [comma three](https://comma.ai/shop/products/three), or if you like to experiment, a [Ubuntu computer with webcams](https://github.com/commaai/openpilot/tree/master/tools/webcam). -* A way to connect to your car. With a comma two or three, you need only a [car harness](https://comma.ai/shop/products/car-harness). With an EON Gold or PC, you also need a [black panda](https://comma.ai/shop/products/panda). +* A supported device to run this software: a [comma three](https://comma.ai/shop/products/three), or if you like to experiment, a [Ubuntu computer with webcams](https://github.com/commaai/openpilot/tree/master/tools/webcam). +* A way to connect to your car. With a comma three, you need only a [car harness](https://comma.ai/shop/products/car-harness). With a PC, you also need a [black panda](https://comma.ai/shop/products/panda). We have detailed instructions for [how to install the device in a car](https://comma.ai/setup). diff --git a/SConstruct b/SConstruct index 6b520bee41..ec76448235 100644 --- a/SConstruct +++ b/SConstruct @@ -73,14 +73,9 @@ lenv = { rpath = lenv["LD_LIBRARY_PATH"].copy() -if arch == "aarch64" or arch == "larch64": +if arch == "larch64": lenv["LD_LIBRARY_PATH"] += ['/data/data/com.termux/files/usr/lib'] - if arch == "aarch64": - # android - lenv["ANDROID_DATA"] = os.environ['ANDROID_DATA'] - lenv["ANDROID_ROOT"] = os.environ['ANDROID_ROOT'] - cpppath = [ "#third_party/opencl/include", ] @@ -92,27 +87,17 @@ if arch == "aarch64" or arch == "larch64": f"#third_party/acados/{arch}/lib", ] - if arch == "larch64": - libpath += [ - "#third_party/snpe/larch64", - "#third_party/libyuv/larch64/lib", - "/usr/lib/aarch64-linux-gnu" - ] - cpppath += [ - "#selfdrive/camerad/include", - ] - cflags = ["-DQCOM2", "-mcpu=cortex-a57"] - cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"] - rpath += ["/usr/local/lib"] - else: - rpath = [] - libpath += [ - "#third_party/snpe/aarch64", - "#third_party/libyuv/lib", - "/system/vendor/lib64" - ] - cflags = ["-DQCOM", "-D_USING_LIBCXX", "-mcpu=cortex-a57"] - cxxflags = ["-DQCOM", "-D_USING_LIBCXX", "-mcpu=cortex-a57"] + libpath += [ + "#third_party/snpe/larch64", + "#third_party/libyuv/larch64/lib", + "/usr/lib/aarch64-linux-gnu" + ] + cpppath += [ + "#selfdrive/camerad/include", + ] + cflags = ["-DQCOM2", "-mcpu=cortex-a57"] + cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"] + rpath += ["/usr/local/lib"] else: cflags = [] cxxflags = [] @@ -259,6 +244,7 @@ if os.environ.get('SCONS_PROGRESS'): SHARED = False +# TODO: this can probably be removed def abspath(x): if arch == 'aarch64': pth = os.path.join("/data/pythonpath", x[0].path) @@ -287,9 +273,7 @@ Export('envCython') # Qt build environment qt_env = env.Clone() -qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia", "Quick", "Qml", "QuickWidgets", "Location", "Positioning"] -if arch != "aarch64": - qt_modules += ["DBus"] +qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia", "Quick", "Qml", "QuickWidgets", "Location", "Positioning", "DBus"] qt_libs = [] if arch == "Darwin": @@ -304,15 +288,6 @@ if arch == "Darwin": qt_env["LINKFLAGS"] += ["-F" + os.path.join(qt_env['QTDIR'], "lib")] qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"] qt_env.AppendENVPath('PATH', os.path.join(qt_env['QTDIR'], "bin")) -elif arch == "aarch64": - qt_env['QTDIR'] = "/usr" - qt_dirs = [ - f"/usr/include/qt", - ] - qt_dirs += [f"/usr/include/qt/Qt{m}" for m in qt_modules] - - qt_libs = [f"Qt5{m}" for m in qt_modules] - qt_libs += ['EGL', 'GLESv3', 'c++_shared'] else: qt_env['QTDIR'] = "/usr" qt_dirs = [ @@ -390,7 +365,7 @@ rednose_config = { }, } -if arch not in ["aarch64", "larch64"]: +if arch != "larch64": rednose_config['to_build'].update({ 'gnss': ('#selfdrive/locationd/models/gnss_kf.py', True, []), 'loc_4': ('#selfdrive/locationd/models/loc_kf.py', True, []), diff --git a/common/file_helpers.py b/common/file_helpers.py index 592b2a199a..8a45fa313c 100644 --- a/common/file_helpers.py +++ b/common/file_helpers.py @@ -81,25 +81,12 @@ def _get_fileobject_func(writer, temp_dir): return writer.get_fileobject(dir=temp_dir) return _get_fileobject -def monkeypatch_os_link(): - # This is neccesary on EON/C2, where os.link is patched out of python - if not hasattr(os, 'link'): - from cffi import FFI - ffi = FFI() - ffi.cdef("int link(const char *oldpath, const char *newpath);") - libc = ffi.dlopen(None) - - def link(src, dest): - return libc.link(src.encode(), dest.encode()) - os.link = link - def atomic_write_on_fs_tmp(path, **kwargs): """Creates an atomic writer using a temporary file in a temporary directory on the same filesystem as path. """ # TODO(mgraczyk): This use of AtomicWriter relies on implementation details to set the temp # directory. - monkeypatch_os_link() writer = AtomicWriter(path, **kwargs) return writer._open(_get_fileobject_func(writer, get_tmpdir_on_same_filesystem(path))) @@ -108,6 +95,5 @@ def atomic_write_in_dir(path, **kwargs): """Creates an atomic writer using a temporary file in the same directory as the destination file. """ - monkeypatch_os_link() writer = AtomicWriter(path, **kwargs) return writer._open(_get_fileobject_func(writer, os.path.dirname(path))) diff --git a/installer/updater/updater b/installer/updater/updater deleted file mode 100755 index baf17a62f2..0000000000 --- a/installer/updater/updater +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2ca3679a8e9a066bccbf8cb27377a40bad65e348d668040adda37c27ff6bad4d -size 69 diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index 29f58ad002..28e3801c28 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -8,96 +8,6 @@ source "$BASEDIR/launch_env.sh" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -function two_init { - - # set IO scheduler - setprop sys.io.scheduler noop - for f in /sys/block/*/queue/scheduler; do - echo noop > $f - done - - # *** shield cores 2-3 *** - - # TODO: should we enable this? - # offline cores 2-3 to force recurring timers onto the other cores - #echo 0 > /sys/devices/system/cpu/cpu2/online - #echo 0 > /sys/devices/system/cpu/cpu3/online - #echo 1 > /sys/devices/system/cpu/cpu2/online - #echo 1 > /sys/devices/system/cpu/cpu3/online - - # android gets two cores - echo 0-1 > /dev/cpuset/background/cpus - echo 0-1 > /dev/cpuset/system-background/cpus - echo 0-1 > /dev/cpuset/foreground/cpus - echo 0-1 > /dev/cpuset/foreground/boost/cpus - echo 0-1 > /dev/cpuset/android/cpus - - # openpilot gets all the cores - echo 0-3 > /dev/cpuset/app/cpus - - # mask off 2-3 from RPS and XPS - Receive/Transmit Packet Steering - echo 3 | tee /sys/class/net/*/queues/*/rps_cpus - echo 3 | tee /sys/class/net/*/queues/*/xps_cpus - - # *** set up governors *** - - # +50mW offroad, +500mW onroad for 30% more RAM bandwidth - echo "performance" > /sys/class/devfreq/soc:qcom,cpubw/governor - echo 1056000 > /sys/class/devfreq/soc:qcom,m4m/max_freq - echo "performance" > /sys/class/devfreq/soc:qcom,m4m/governor - - # unclear if these help, but they don't seem to hurt - echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu0/governor - echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu2/governor - - # GPU - echo "performance" > /sys/class/devfreq/b00000.qcom,kgsl-3d0/governor - - # /sys/class/devfreq/soc:qcom,mincpubw is the only one left at "powersave" - # it seems to gain nothing but a wasted 500mW - - # *** set up IRQ affinities *** - - # Collect RIL and other possibly long-running I/O interrupts onto CPU 1 - echo 1 > /proc/irq/78/smp_affinity_list # qcom,smd-modem (LTE radio) - echo 1 > /proc/irq/33/smp_affinity_list # ufshcd (flash storage) - echo 1 > /proc/irq/35/smp_affinity_list # wifi (wlan_pci) - echo 1 > /proc/irq/6/smp_affinity_list # MDSS - - # USB traffic needs realtime handling on cpu 3 - [ -d "/proc/irq/733" ] && echo 3 > /proc/irq/733/smp_affinity_list - - # GPU and camera get cpu 2 - CAM_IRQS="177 178 179 180 181 182 183 184 185 186 192" - for irq in $CAM_IRQS; do - echo 2 > /proc/irq/$irq/smp_affinity_list - done - echo 2 > /proc/irq/193/smp_affinity_list # GPU - - # give GPU threads RT priority - for pid in $(pgrep "kgsl"); do - chrt -f -p 52 $pid - done - - # the flippening! - LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1 - - # disable bluetooth - service call bluetooth_manager 8 - - # wifi scan - wpa_cli IFNAME=wlan0 SCAN - - # Check for NEOS update - if [ $(< /VERSION) != "$REQUIRED_NEOS_VERSION" ]; then - echo "Installing NEOS update" - NEOS_PY="$DIR/selfdrive/hardware/eon/neos.py" - MANIFEST="$DIR/selfdrive/hardware/eon/neos.json" - $NEOS_PY --swap-if-ready $MANIFEST - $DIR/selfdrive/hardware/eon/updater $NEOS_PY $MANIFEST - fi -} - function tici_init { # wait longer for weston to come up if [ -f "$BASEDIR/prebuilt" ]; then @@ -168,9 +78,7 @@ function launch { export PYTHONPATH="$PWD:$PWD/pyextra" # hardware specific init - if [ -f /EON ]; then - two_init - elif [ -f /TICI ]; then + if [ -f /TICI ]; then tici_init fi diff --git a/launch_env.sh b/launch_env.sh index cd0c27f643..d4b57c909a 100755 --- a/launch_env.sh +++ b/launch_env.sh @@ -6,10 +6,6 @@ export NUMEXPR_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 export VECLIB_MAXIMUM_THREADS=1 -if [ -z "$REQUIRED_NEOS_VERSION" ]; then - export REQUIRED_NEOS_VERSION="19.1" -fi - if [ -z "$AGNOS_VERSION" ]; then export AGNOS_VERSION="4" fi diff --git a/release/build_release.sh b/release/build_release.sh index 95fcfea1a1..79ab4fb087 100755 --- a/release/build_release.sh +++ b/release/build_release.sh @@ -13,10 +13,6 @@ if [ -f /TICI ]; then FILES_SRC="release/files_tici" RELEASE_BRANCH=release3-staging DASHCAM_BRANCH=dashcam3-staging -elif [ -f /EON ]; then - FILES_SRC="release/files_eon" - RELEASE_BRANCH=release2-staging - DASHCAM_BRANCH=dashcam-staging else exit 0 fi diff --git a/release/files_common b/release/files_common index ff7669084e..905f58f609 100644 --- a/release/files_common +++ b/release/files_common @@ -65,8 +65,6 @@ release/* tools/lib/* -installer/updater/updater - selfdrive/version.py selfdrive/__init__.py @@ -260,14 +258,6 @@ selfdrive/hardware/__init__.py selfdrive/hardware/base.h selfdrive/hardware/base.py selfdrive/hardware/hw.h -selfdrive/hardware/eon/__init__.py -selfdrive/hardware/eon/androidd.py -selfdrive/hardware/eon/shutdownd.py -selfdrive/hardware/eon/hardware.h -selfdrive/hardware/eon/hardware.py -selfdrive/hardware/eon/neos.py -selfdrive/hardware/eon/neos.json -selfdrive/hardware/eon/updater selfdrive/hardware/tici/__init__.py selfdrive/hardware/tici/hardware.py selfdrive/hardware/tici/amplifier.py @@ -299,7 +289,6 @@ selfdrive/locationd/models/live_kf.cc selfdrive/locationd/calibrationd.py selfdrive/logcatd/SConscript -selfdrive/logcatd/logcatd_android.cc selfdrive/logcatd/logcatd_systemd.cc selfdrive/proclogd/SConscript @@ -329,7 +318,6 @@ selfdrive/loggerd/xattr_cache.py selfdrive/sensord/SConscript selfdrive/sensord/libdiag.h -selfdrive/sensord/sensors_qcom.cc selfdrive/sensord/sensors_qcom2.cc selfdrive/sensord/sensors/*.cc selfdrive/sensord/sensors/*.h @@ -363,8 +351,6 @@ selfdrive/ui/qt/offroad/*.h selfdrive/ui/qt/offroad/*.qml selfdrive/ui/qt/widgets/*.cc selfdrive/ui/qt/widgets/*.h -selfdrive/ui/qt/spinner_aarch64 -selfdrive/ui/qt/text_aarch64 selfdrive/ui/replay/*.cc selfdrive/ui/replay/*.h @@ -376,11 +362,8 @@ selfdrive/camerad/snapshot/* selfdrive/camerad/include/* selfdrive/camerad/cameras/camera_common.h selfdrive/camerad/cameras/camera_common.cc -selfdrive/camerad/cameras/camera_qcom.cc -selfdrive/camerad/cameras/camera_qcom.h selfdrive/camerad/cameras/camera_replay.cc selfdrive/camerad/cameras/camera_replay.h -selfdrive/camerad/cameras/debayer.cl selfdrive/camerad/cameras/sensor_i2c.h selfdrive/camerad/cameras/sensor2_i2c.h @@ -456,7 +439,6 @@ selfdrive/assets/training/* third_party/SConscript -third_party/libgralloc/** third_party/linux/** third_party/opencl/** third_party/zlib/* @@ -477,19 +459,12 @@ third_party/libyuv/lib/** third_party/libyuv/larch64/** third_party/snpe/include/** -third_party/snpe/aarch64** -third_party/snpe/larch64** third_party/snpe/dsp** third_party/acados/x86_64/** -third_party/acados/aarch64/** third_party/acados/larch64/** third_party/acados/include/** -third_party/android_frameworks_native/** -third_party/android_hardware_libhardware/** -third_party/android_system_core/** - scripts/update_now.sh scripts/stop_updater.sh diff --git a/release/files_eon b/release/files_eon deleted file mode 100644 index b43bf86b50..0000000000 --- a/release/files_eon +++ /dev/null @@ -1 +0,0 @@ -README.md diff --git a/release/files_tici b/release/files_tici index 59cc41918f..f63a750f4d 100644 --- a/release/files_tici +++ b/release/files_tici @@ -1,3 +1,5 @@ +third_party/snpe/larch64** +third_party/snpe/aarch64-linux-gcc4.9/* third_party/mapbox-gl-native-qt/include/* selfdrive/timezoned.py diff --git a/selfdrive/camerad/SConscript b/selfdrive/camerad/SConscript index 85bc756bc1..bb55c825d4 100644 --- a/selfdrive/camerad/SConscript +++ b/selfdrive/camerad/SConscript @@ -2,10 +2,7 @@ Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc', libs = ['m', 'pthread', common, 'jpeg', 'OpenCL', 'yuv', cereal, messaging, 'zmq', 'capnp', 'kj', visionipc, gpucommon] -if arch == "aarch64": - libs += ['gsl', 'CB', 'adreno_utils', 'EGL', 'GLESv3', 'cutils', 'ui'] - cameras = ['cameras/camera_qcom.cc'] -elif arch == "larch64": +if arch == "larch64": libs += ['atomic'] cameras = ['cameras/camera_qcom2.cc'] else: diff --git a/selfdrive/camerad/cameras/camera_common.cc b/selfdrive/camerad/cameras/camera_common.cc index 7c4d2748f1..625c284fa4 100644 --- a/selfdrive/camerad/cameras/camera_common.cc +++ b/selfdrive/camerad/cameras/camera_common.cc @@ -18,10 +18,7 @@ #include "selfdrive/common/util.h" #include "selfdrive/hardware/hw.h" -#ifdef QCOM -#include "CL/cl_ext_qcom.h" -#include "selfdrive/camerad/cameras/camera_qcom.h" -#elif QCOM2 +#if QCOM2 #include "CL/cl_ext_qcom.h" #include "selfdrive/camerad/cameras/camera_qcom2.h" #elif WEBCAM @@ -418,17 +415,6 @@ static void driver_cam_auto_exposure(CameraState *c, SubMaster &sm) { } static ExpRect rect = def_rect; - // use driver face crop for AE - if (Hardware::EON() && sm.updated("driverState")) { - if (auto state = sm["driverState"].getDriverState(); state.getFaceProb() > 0.4) { - auto face_position = state.getFacePosition(); - int x = is_rhd ? 0 : frame_width - (0.5 * frame_height); - x += (face_position[0] * (is_rhd ? -1.0 : 1.0) + 0.5) * (0.5 * frame_height) + x_offset; - int y = (face_position[1] + 0.5) * frame_height + y_offset; - rect = {std::max(0, x - 72), std::min(b->rgb_width - 1, x + 72), 2, - std::max(0, y - 72), std::min(b->rgb_height - 1, y + 72), 1}; - } - } camera_autoexposure(c, set_exposure_target(b, rect.x1, rect.x2, rect.x_skip, rect.y1, rect.y2, rect.y_skip)); } @@ -452,7 +438,7 @@ void common_process_driver_camera(MultiCameraState *s, CameraState *c, int cnt) void camerad_thread() { cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); -#if defined(QCOM) || defined(QCOM2) +#ifdef QCOM2 const cl_context_properties props[] = {CL_CONTEXT_PRIORITY_HINT_QCOM, CL_PRIORITY_HINT_HIGH_QCOM, 0}; cl_context context = CL_CHECK_ERR(clCreateContext(props, 1, &device_id, NULL, NULL, &err)); #else diff --git a/selfdrive/camerad/cameras/camera_common.h b/selfdrive/camerad/cameras/camera_common.h index 6fafa0e59d..e415f80982 100644 --- a/selfdrive/camerad/cameras/camera_common.h +++ b/selfdrive/camerad/cameras/camera_common.h @@ -29,7 +29,7 @@ #define CAMERA_ID_MAX 10 const int UI_BUF_COUNT = 4; -const int YUV_BUFFER_COUNT = Hardware::EON() ? 100 : 40; +const int YUV_BUFFER_COUNT = 40; enum CameraType { RoadCam = 0, diff --git a/selfdrive/camerad/cameras/camera_qcom.cc b/selfdrive/camerad/cameras/camera_qcom.cc deleted file mode 100644 index 411ff0aec4..0000000000 --- a/selfdrive/camerad/cameras/camera_qcom.cc +++ /dev/null @@ -1,1164 +0,0 @@ -#include "selfdrive/camerad/cameras/camera_qcom.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include "selfdrive/camerad/cameras/sensor_i2c.h" -#include "selfdrive/camerad/include/msm_cam_sensor.h" -#include "selfdrive/camerad/include/msmb_camera.h" -#include "selfdrive/camerad/include/msmb_isp.h" -#include "selfdrive/camerad/include/msmb_ispif.h" -#include "selfdrive/common/clutil.h" -#include "selfdrive/common/params.h" -#include "selfdrive/common/swaglog.h" -#include "selfdrive/common/timing.h" -#include "selfdrive/common/util.h" - -// leeco actuator (DW9800W H-Bridge Driver IC) -// from sniff -const uint16_t INFINITY_DAC = 364; - -extern ExitHandler do_exit; - -static int cam_ioctl(int fd, unsigned long int request, void *arg, const char *log_msg = nullptr) { - int err = HANDLE_EINTR(ioctl(fd, request, arg)); - if (err != 0 && log_msg) { - LOG(util::string_format("%s: %d", log_msg, err).c_str()); - } - return err; -} -// global var for AE/AF ops -std::atomic road_cam_exp{{0}}; -std::atomic driver_cam_exp{{0}}; - -CameraInfo cameras_supported[CAMERA_ID_MAX] = { - [CAMERA_ID_IMX298] = { - .frame_width = 2328, - .frame_height = 1748, - .frame_stride = 2912, - .bayer = true, - .bayer_flip = 3, - .hdr = true - }, - [CAMERA_ID_OV8865] = { - .frame_width = 1632, - .frame_height = 1224, - .frame_stride = 2040, // seems right - .bayer = true, - .bayer_flip = 3, - .hdr = false - }, - // this exists to get the kernel to build for the LeEco in release - [CAMERA_ID_IMX298_FLIPPED] = { - .frame_width = 2328, - .frame_height = 1748, - .frame_stride = 2912, - .bayer = true, - .bayer_flip = 3, - .hdr = true - }, - [CAMERA_ID_OV10640] = { - .frame_width = 1280, - .frame_height = 1080, - .frame_stride = 2040, - .bayer = true, - .bayer_flip = 0, - .hdr = true - }, -}; - -static void camera_release_buffer(void* cookie, int buf_idx) { - CameraState *s = (CameraState *)cookie; - // printf("camera_release_buffer %d\n", buf_idx); - s->ss[0].qbuf_info[buf_idx].dirty_buf = 1; - HANDLE_EINTR(ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &s->ss[0].qbuf_info[buf_idx])); -} - -int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, msm_camera_i2c_data_type data_type) { - struct msm_camera_i2c_reg_setting out_settings = { - .reg_setting = arr, - .size = (uint16_t)size, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .data_type = data_type, - .delay = 0, - }; - sensorb_cfg_data cfg_data = {.cfgtype = CFG_WRITE_I2C_ARRAY, .cfg.setting = &out_settings}; - return HANDLE_EINTR(ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &cfg_data)); -} - -static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, uint32_t frame_length) { - int analog_gain = std::min(gain, 448); - s->digital_gain = gain > 448 ? (512.0/(512-(gain))) / 8.0 : 1.0; - //printf("%5d/%5d %5d %f\n", s->cur_integ_lines, s->frame_length, analog_gain, s->digital_gain); - - struct msm_camera_i2c_reg_array reg_array[] = { - // REG_HOLD - {0x104,0x1,0}, - {0x3002,0x0,0}, // long autoexposure off - - // FRM_LENGTH - {0x340, (uint16_t)(frame_length >> 8), 0}, {0x341, (uint16_t)(frame_length & 0xff), 0}, - // INTEG_TIME aka coarse_int_time_addr aka shutter speed - {0x202, (uint16_t)(integ_lines >> 8), 0}, {0x203, (uint16_t)(integ_lines & 0xff),0}, - // global_gain_addr - // if you assume 1x gain is 32, 448 is 14x gain, aka 2^14=16384 - {0x204, (uint16_t)(analog_gain >> 8), 0}, {0x205, (uint16_t)(analog_gain & 0xff),0}, - - // digital gain for colors: gain_greenR, gain_red, gain_blue, gain_greenB - /*{0x20e, digital_gain_gr >> 8, 0}, {0x20f,digital_gain_gr & 0xFF,0}, - {0x210, digital_gain_r >> 8, 0}, {0x211,digital_gain_r & 0xFF,0}, - {0x212, digital_gain_b >> 8, 0}, {0x213,digital_gain_b & 0xFF,0}, - {0x214, digital_gain_gb >> 8, 0}, {0x215,digital_gain_gb & 0xFF,0},*/ - - // REG_HOLD - {0x104,0x0,0}, - }; - return sensor_write_regs(s, reg_array, std::size(reg_array), MSM_CAMERA_I2C_BYTE_DATA); -} - -static int ov8865_apply_exposure(CameraState *s, int gain, int integ_lines, uint32_t frame_length) { - //printf("driver camera: %d %d %d\n", gain, integ_lines, frame_length); - int coarse_gain_bitmap, fine_gain_bitmap; - - // get bitmaps from iso - static const int gains[] = {0, 100, 200, 400, 800}; - int i; - for (i = 1; i < std::size(gains); i++) { - if (gain >= gains[i - 1] && gain < gains[i]) - break; - } - int coarse_gain = i - 1; - float fine_gain = (gain - gains[coarse_gain])/(float)(gains[coarse_gain+1]-gains[coarse_gain]); - coarse_gain_bitmap = (1 << coarse_gain) - 1; - fine_gain_bitmap = ((int)(16*fine_gain) << 3) + 128; // 7th is always 1, 0-2nd are always 0 - - integ_lines *= 16; // The exposure value in reg is in 16ths of a line - - struct msm_camera_i2c_reg_array reg_array[] = { - //{0x104,0x1,0}, - - // FRM_LENGTH - {0x380e, (uint16_t)(frame_length >> 8), 0}, {0x380f, (uint16_t)(frame_length & 0xff), 0}, - // AEC EXPO - {0x3500, (uint16_t)(integ_lines >> 16), 0}, {0x3501, (uint16_t)(integ_lines >> 8), 0}, {0x3502, (uint16_t)(integ_lines & 0xff),0}, - // AEC MANUAL - {0x3503, 0x4, 0}, - // AEC GAIN - {0x3508, (uint16_t)(coarse_gain_bitmap), 0}, {0x3509, (uint16_t)(fine_gain_bitmap), 0}, - - //{0x104,0x0,0}, - }; - return sensor_write_regs(s, reg_array, std::size(reg_array), MSM_CAMERA_I2C_BYTE_DATA); -} - -static void camera_init(VisionIpcServer *v, CameraState *s, int camera_id, int camera_num, - uint32_t pixel_clock, uint32_t line_length_pclk, - uint32_t max_gain, uint32_t fps, cl_device_id device_id, cl_context ctx, - VisionStreamType rgb_type, VisionStreamType yuv_type) { - s->camera_num = camera_num; - s->camera_id = camera_id; - - assert(camera_id < std::size(cameras_supported)); - s->ci = cameras_supported[camera_id]; - assert(s->ci.frame_width != 0); - - s->pixel_clock = pixel_clock; - s->max_gain = max_gain; - s->fps = fps; - s->frame_length = s->pixel_clock / line_length_pclk / s->fps; - s->self_recover = 0; - - s->apply_exposure = (camera_id == CAMERA_ID_IMX298) ? imx298_apply_exposure : ov8865_apply_exposure; - s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type, camera_release_buffer); -} - -void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { - char project_name[1024] = {0}; - property_get("ro.boot.project_name", project_name, ""); - assert(strlen(project_name) == 0); - - // sensor is flipped in LP3 - // IMAGE_ORIENT = 3 - init_array_imx298[0].reg_data = 3; - - // 0 = ISO 100 - // 256 = ISO 200 - // 384 = ISO 400 - // 448 = ISO 800 - // 480 = ISO 1600 - // 496 = ISO 3200 - // 504 = ISO 6400, 8x digital gain - // 508 = ISO 12800, 16x digital gain - // 510 = ISO 25600, 32x digital gain - - camera_init(v, &s->road_cam, CAMERA_ID_IMX298, 0, - /*pixel_clock=*/600000000, /*line_length_pclk=*/5536, - /*max_gain=*/510, //0 (ISO 100)- 448 (ISO 800, max analog gain) - 511 (super noisy) -#ifdef HIGH_FPS - /*fps*/ 60, -#else - /*fps*/ 20, -#endif - device_id, ctx, - VISION_STREAM_RGB_ROAD, VISION_STREAM_ROAD); - - camera_init(v, &s->driver_cam, CAMERA_ID_OV8865, 1, - /*pixel_clock=*/72000000, /*line_length_pclk=*/1602, - /*max_gain=*/510, 10, device_id, ctx, - VISION_STREAM_RGB_DRIVER, VISION_STREAM_DRIVER); - - s->sm = new SubMaster({"driverState"}); - s->pm = new PubMaster({"roadCameraState", "driverCameraState", "thumbnail"}); - - for (int i = 0; i < FRAME_BUF_COUNT; i++) { - // TODO: make lengths correct - s->focus_bufs[i].allocate(0xb80); - s->stats_bufs[i].allocate(0xb80); - } - std::fill_n(s->lapres, std::size(s->lapres), 16160); - s->lap_conv = new LapConv(device_id, ctx, s->road_cam.buf.rgb_width, s->road_cam.buf.rgb_height, s->road_cam.buf.rgb_stride, 3); -} - -static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) { - int err = 0; - uint32_t gain = s->cur_gain; - uint32_t integ_lines = s->cur_integ_lines; - - if (exposure_frac >= 0) { - exposure_frac = std::clamp(exposure_frac, 2.0f / s->frame_length, 1.0f); - integ_lines = s->frame_length * exposure_frac; - - // See page 79 of the datasheet, this is the max allowed (-1 for phase adjust) - integ_lines = std::min(integ_lines, s->frame_length - 11); - } - - if (gain_frac >= 0) { - // ISO200 is minimum gain - gain_frac = std::clamp(gain_frac, 1.0f/64, 1.0f); - - // linearize gain response - // TODO: will be wrong for driver camera - // 0.125 -> 448 - // 0.25 -> 480 - // 0.5 -> 496 - // 1.0 -> 504 - // 512 - 512/(128*gain_frac) - gain = (s->max_gain/510) * (512 - 512/(256*gain_frac)); - } - - if (gain != s->cur_gain || integ_lines != s->cur_integ_lines) { - if (s->apply_exposure == ov8865_apply_exposure) { - gain = 800 * gain_frac; // ISO - } - err = s->apply_exposure(s, gain, integ_lines, s->frame_length); - if (err == 0) { - std::lock_guard lk(s->frame_info_lock); - s->cur_gain = gain; - s->cur_integ_lines = integ_lines; - } else { - LOGE("camera %d apply_exposure err: %d", s->camera_num, err); - } - } - - if (err == 0) { - s->cur_exposure_frac = exposure_frac; - std::lock_guard lk(s->frame_info_lock); - s->cur_gain_frac = gain_frac; - } - - //LOGD("set exposure: %f %f - %d", exposure_frac, gain_frac, err); -} - -static void do_autoexposure(CameraState *s, float grey_frac) { - const float target_grey = 0.3; - - s->frame_info_lock.lock(); - s->measured_grey_fraction = grey_frac; - s->target_grey_fraction = target_grey; - s->frame_info_lock.unlock(); - - if (s->apply_exposure == ov8865_apply_exposure) { - // gain limits downstream - const float gain_frac_min = 0.015625; - const float gain_frac_max = 1.0; - // exposure time limits - const uint32_t exposure_time_min = 16; - const uint32_t exposure_time_max = s->frame_length - 11; // copied from set_exposure() - - float cur_gain_frac = s->cur_gain_frac; - float exposure_factor = pow(1.05, (target_grey - grey_frac) / 0.05); - if (cur_gain_frac > 0.125 && exposure_factor < 1) { - cur_gain_frac *= exposure_factor; - } else if (s->cur_integ_lines * exposure_factor <= exposure_time_max && s->cur_integ_lines * exposure_factor >= exposure_time_min) { // adjust exposure time first - s->cur_exposure_frac *= exposure_factor; - } else if (cur_gain_frac * exposure_factor <= gain_frac_max && cur_gain_frac * exposure_factor >= gain_frac_min) { - cur_gain_frac *= exposure_factor; - } - s->frame_info_lock.lock(); - s->cur_gain_frac = cur_gain_frac; - s->frame_info_lock.unlock(); - - set_exposure(s, s->cur_exposure_frac, cur_gain_frac); - } else { // keep the old for others - float new_exposure = s->cur_exposure_frac; - new_exposure *= pow(1.05, (target_grey - grey_frac) / 0.05 ); - //LOGD("diff %f: %f to %f", target_grey - grey_frac, s->cur_exposure_frac, new_exposure); - - float new_gain = s->cur_gain_frac; - if (new_exposure < 0.10) { - new_gain *= 0.95; - } else if (new_exposure > 0.40) { - new_gain *= 1.05; - } - - set_exposure(s, new_exposure, new_gain); - } -} - -static void sensors_init(MultiCameraState *s) { - msm_camera_sensor_slave_info slave_infos[2] = { - (msm_camera_sensor_slave_info){ // road camera - .sensor_name = "imx298", - .eeprom_name = "sony_imx298", - .actuator_name = "dw9800w", - .ois_name = "", - .flash_name = "pmic", - .camera_id = CAMERA_0, - .slave_addr = 32, - .i2c_freq_mode = I2C_FAST_MODE, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .sensor_id_info = {.sensor_id_reg_addr = 22, .sensor_id = 664, .module_id = 9, .vcm_id = 6}, - .power_setting_array = { - .power_setting_a = { - {.seq_type = SENSOR_GPIO, .delay = 1}, - {.seq_type = SENSOR_VREG, .seq_val = 2}, - {.seq_type = SENSOR_GPIO, .seq_val = 5, .config_val = 2}, - {.seq_type = SENSOR_VREG, .seq_val = 1}, - {.seq_type = SENSOR_VREG, .seq_val = 3, .delay = 1}, - {.seq_type = SENSOR_CLK, .config_val = 24000000, .delay = 1}, - {.seq_type = SENSOR_GPIO, .config_val = 2, .delay = 10}, - }, - .size = 7, - .power_down_setting_a = { - {.seq_type = SENSOR_CLK, .delay = 1}, - {.seq_type = SENSOR_GPIO, .delay = 1}, - {.seq_type = SENSOR_VREG, .seq_val = 1}, - {.seq_type = SENSOR_GPIO, .seq_val = 5}, - {.seq_type = SENSOR_VREG, .seq_val = 2}, - {.seq_type = SENSOR_VREG, .seq_val = 3, .delay = 1}, - }, - .size_down = 6, - }, - .is_init_params_valid = 0, - .sensor_init_params = {.modes_supported = 1, .position = BACK_CAMERA_B, .sensor_mount_angle = 90}, - .output_format = MSM_SENSOR_BAYER, - }, - (msm_camera_sensor_slave_info){ // driver camera - .sensor_name = "ov8865_sunny", - .eeprom_name = "ov8865_plus", - .actuator_name = "", - .ois_name = "", - .flash_name = "", - .camera_id = CAMERA_2, - .slave_addr = 108, - .i2c_freq_mode = I2C_FAST_MODE, - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .sensor_id_info = {.sensor_id_reg_addr = 12299, .sensor_id = 34917, .module_id = 2}, - .power_setting_array = { - .power_setting_a = { - {.seq_type = SENSOR_GPIO, .delay = 5}, - {.seq_type = SENSOR_VREG, .seq_val = 1}, - {.seq_type = SENSOR_VREG, .seq_val = 2}, - {.seq_type = SENSOR_VREG}, - {.seq_type = SENSOR_CLK, .config_val = 24000000, .delay = 1}, - {.seq_type = SENSOR_GPIO, .config_val = 2, .delay = 1}, - }, - .size = 6, - .power_down_setting_a = { - {.seq_type = SENSOR_GPIO, .delay = 5}, - {.seq_type = SENSOR_CLK, .delay = 1}, - {.seq_type = SENSOR_VREG}, - {.seq_type = SENSOR_VREG, .seq_val = 1}, - {.seq_type = SENSOR_VREG, .seq_val = 2, .delay = 1}, - }, - .size_down = 5, - }, - .is_init_params_valid = 0, - .sensor_init_params = {.modes_supported = 1, .position = FRONT_CAMERA_B, .sensor_mount_angle = 270}, - .output_format = MSM_SENSOR_BAYER, - }}; - - unique_fd sensorinit_fd = open_v4l_by_name_and_index("msm_sensor_init"); - assert(sensorinit_fd >= 0); - for (auto &info : slave_infos) { - info.power_setting_array.power_setting = &info.power_setting_array.power_setting_a[0]; - info.power_setting_array.power_down_setting = &info.power_setting_array.power_down_setting_a[0]; - sensor_init_cfg_data sensor_init_cfg = {.cfgtype = CFG_SINIT_PROBE, .cfg.setting = &info}; - int err = cam_ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg, "sensor init cfg"); - assert(err >= 0); - } -} - -static void camera_open(CameraState *s, bool is_road_cam) { - struct csid_cfg_data csid_cfg_data = {}; - struct v4l2_event_subscription sub = {}; - - struct msm_actuator_cfg_data actuator_cfg_data = {}; - - // open devices - s->csid_fd = open_v4l_by_name_and_index("msm_csid", is_road_cam ? 0 : 2); - assert(s->csid_fd >= 0); - s->csiphy_fd = open_v4l_by_name_and_index("msm_csiphy", is_road_cam ? 0 : 2); - assert(s->csiphy_fd >= 0); - s->isp_fd = open_v4l_by_name_and_index("vfe", is_road_cam ? 0 : 1); - assert(s->isp_fd >= 0); - - if (is_road_cam) { - s->actuator_fd = open_v4l_by_name_and_index("msm_actuator"); - assert(s->actuator_fd >= 0); - } - - // wait for sensor device - // on first startup, these devices aren't present yet - for (int i = 0; i < 10; i++) { - s->sensor_fd = open_v4l_by_name_and_index(is_road_cam ? "imx298" : "ov8865_sunny"); - if (s->sensor_fd >= 0) break; - LOGW("waiting for sensors..."); - util::sleep_for(1000); // sleep one second - } - assert(s->sensor_fd >= 0); - - // *** SHUTDOWN ALL *** - - // CSIPHY: release csiphy - struct msm_camera_csi_lane_params csi_lane_params = {0}; - csi_lane_params.csi_lane_mask = 0x1f; - csiphy_cfg_data csiphy_cfg_data = { .cfg.csi_lane_params = &csi_lane_params, .cfgtype = CSIPHY_RELEASE}; - int err = cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "release csiphy"); - - // CSID: release csid - csid_cfg_data.cfgtype = CSID_RELEASE; - cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "release csid"); - - // SENSOR: send power down - struct sensorb_cfg_data sensorb_cfg_data = {.cfgtype = CFG_POWER_DOWN}; - cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "sensor power down"); - - // actuator powerdown - actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERDOWN; - cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator powerdown"); - - // reset isp - // struct msm_vfe_axi_halt_cmd halt_cmd = { - // .stop_camif = 1, - // .overflow_detected = 1, - // .blocking_halt = 1, - // }; - // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_HALT, &halt_cmd); - // printf("axi halt: %d\n", err); - - // struct msm_vfe_axi_reset_cmd reset_cmd = { - // .blocking = 1, - // .frame_id = 1, - // }; - // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESET, &reset_cmd); - // printf("axi reset: %d\n", err); - - // struct msm_vfe_axi_restart_cmd restart_cmd = { - // .enable_camif = 1, - // }; - // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESTART, &restart_cmd); - // printf("axi restart: %d\n", err); - - // **** GO GO GO **** - LOG("******************** GO GO GO ************************"); - - // CSID: init csid - csid_cfg_data.cfgtype = CSID_INIT; - cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "init csid"); - - // CSIPHY: init csiphy - csiphy_cfg_data = {.cfgtype = CSIPHY_INIT}; - cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "init csiphy"); - - // SENSOR: stop stream - struct msm_camera_i2c_reg_setting stop_settings = { - .reg_setting = stop_reg_array, - .size = std::size(stop_reg_array), - .addr_type = MSM_CAMERA_I2C_WORD_ADDR, - .data_type = MSM_CAMERA_I2C_BYTE_DATA, - .delay = 0 - }; - sensorb_cfg_data.cfgtype = CFG_SET_STOP_STREAM_SETTING; - sensorb_cfg_data.cfg.setting = &stop_settings; - cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "stop stream"); - - // SENSOR: send power up - sensorb_cfg_data = {.cfgtype = CFG_POWER_UP}; - cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "sensor power up"); - - // **** configure the sensor **** - - // SENSOR: send i2c configuration - if (s->camera_id == CAMERA_ID_IMX298) { - err = sensor_write_regs(s, init_array_imx298, std::size(init_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); - } else if (s->camera_id == CAMERA_ID_OV8865) { - err = sensor_write_regs(s, init_array_ov8865, std::size(init_array_ov8865), MSM_CAMERA_I2C_BYTE_DATA); - } else { - assert(false); - } - LOG("sensor init i2c: %d", err); - - if (is_road_cam) { - // init the actuator - actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERUP; - cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator powerup"); - - actuator_cfg_data.cfgtype = CFG_ACTUATOR_INIT; - cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator init"); - - struct msm_actuator_reg_params_t actuator_reg_params[] = { - { - .reg_write_type = MSM_ACTUATOR_WRITE_DAC, - // MSB here at address 3 - .reg_addr = 3, - .data_type = 9, - .addr_type = 4, - }, - }; - - struct reg_settings_t actuator_init_settings[] = { - { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=1, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, // PD = power down - { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=0, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 }, // 0 = power up - { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=2, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 }, // RING = SAC mode - { .reg_addr=6, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=64, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, // 0x40 = SAC3 mode - { .reg_addr=7, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=113, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, - // 0x71 = DIV1 | DIV0 | SACT0 -- Tvib x 1/4 (quarter) - // SAC Tvib = 6.3 ms + 0.1 ms = 6.4 ms / 4 = 1.6 ms - // LSC 1-step = 252 + 1*4 = 256 ms / 4 = 64 ms - }; - - struct region_params_t region_params[] = { - {.step_bound = {238, 0,}, .code_per_step = 235, .qvalue = 128} - }; - - actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO; - actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){ - .actuator_params = { - .act_type = ACTUATOR_BIVCM, - .reg_tbl_size = 1, - .data_size = 10, - .init_setting_size = 5, - .i2c_freq_mode = I2C_STANDARD_MODE, - .i2c_addr = 24, - .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR, - .i2c_data_type = MSM_ACTUATOR_WORD_DATA, - .reg_tbl_params = &actuator_reg_params[0], - .init_settings = &actuator_init_settings[0], - .park_lens = {.damping_step = 1023, .damping_delay = 14000, .hw_params = 11, .max_step = 20}, - }, - .af_tuning_params = { - .initial_code = INFINITY_DAC, - .pwd_step = 0, - .region_size = 1, - .total_steps = 238, - .region_params = ®ion_params[0], - }, - }; - - cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator set info"); - } - - if (s->camera_id == CAMERA_ID_IMX298) { - err = sensor_write_regs(s, mode_setting_array_imx298, std::size(mode_setting_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); - LOG("sensor setup: %d", err); - } - - // CSIPHY: configure csiphy - struct msm_camera_csiphy_params csiphy_params = {}; - if (s->camera_id == CAMERA_ID_IMX298) { - csiphy_params = {.lane_cnt = 4, .settle_cnt = 14, .lane_mask = 0x1f, .csid_core = 0}; - } else if (s->camera_id == CAMERA_ID_OV8865) { - // guess! - csiphy_params = {.lane_cnt = 4, .settle_cnt = 24, .lane_mask = 0x1f, .csid_core = 2}; - } - csiphy_cfg_data.cfgtype = CSIPHY_CFG; - csiphy_cfg_data.cfg.csiphy_params = &csiphy_params; - cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "csiphy configure"); - - // CSID: configure csid -#define CSI_STATS 0x35 -#define CSI_PD 0x36 - struct msm_camera_csid_params csid_params = { - .lane_cnt = 4, - .lane_assign = 0x4320, - .phy_sel = (uint8_t)(is_road_cam ? 0 : 2), - .lut_params.num_cid = (uint8_t)(is_road_cam ? 3 : 1), - .lut_params.vc_cfg_a = { - {.cid = 0, .dt = CSI_RAW10, .decode_format = CSI_DECODE_10BIT}, - {.cid = 1, .dt = CSI_PD, .decode_format = CSI_DECODE_10BIT}, - {.cid = 2, .dt = CSI_STATS, .decode_format = CSI_DECODE_10BIT}, - }, - }; - - csid_params.lut_params.vc_cfg[0] = &csid_params.lut_params.vc_cfg_a[0]; - csid_params.lut_params.vc_cfg[1] = &csid_params.lut_params.vc_cfg_a[1]; - csid_params.lut_params.vc_cfg[2] = &csid_params.lut_params.vc_cfg_a[2]; - - csid_cfg_data.cfgtype = CSID_CFG; - csid_cfg_data.cfg.csid_params = &csid_params; - cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "csid configure"); - - // ISP: SMMU_ATTACH - msm_vfe_smmu_attach_cmd smmu_attach_cmd = {.security_mode = 0, .iommu_attach_mode = IOMMU_ATTACH}; - cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_SMMU_ATTACH, &smmu_attach_cmd, "isp smmu attach"); - - // ******************* STREAM RAW ***************************** - - // configure QMET input - struct msm_vfe_input_cfg input_cfg = {}; - for (int i = 0; i < (is_road_cam ? 3 : 1); i++) { - StreamState *ss = &s->ss[i]; - - memset(&input_cfg, 0, sizeof(struct msm_vfe_input_cfg)); - input_cfg.input_src = (msm_vfe_input_src)(VFE_RAW_0+i); - input_cfg.input_pix_clk = s->pixel_clock; - input_cfg.d.rdi_cfg.cid = i; - input_cfg.d.rdi_cfg.frame_based = 1; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_INPUT_CFG, &input_cfg); - LOG("configure input(%d): %d", i, err); - - // ISP: REQUEST_STREAM - ss->stream_req.axi_stream_handle = 0; - if (is_road_cam) { - ss->stream_req.session_id = 2; - ss->stream_req.stream_id = /*ISP_META_CHANNEL_BIT | */ISP_NATIVE_BUF_BIT | (1+i); - } else { - ss->stream_req.session_id = 3; - ss->stream_req.stream_id = ISP_NATIVE_BUF_BIT | 1; - } - - if (i == 0) { - ss->stream_req.output_format = v4l2_fourcc('R', 'G', '1', '0'); - } else { - ss->stream_req.output_format = v4l2_fourcc('Q', 'M', 'E', 'T'); - } - ss->stream_req.stream_src = (msm_vfe_axi_stream_src)(RDI_INTF_0+i); - -#ifdef HIGH_FPS - if (is_road_cam) { - ss->stream_req.frame_skip_pattern = EVERY_3FRAME; - } -#endif - - ss->stream_req.frame_base = 1; - ss->stream_req.buf_divert = 1; //i == 0; - - // setup stream plane. doesn't even matter? - /*s->stream_req.plane_cfg[0].output_plane_format = Y_PLANE; - s->stream_req.plane_cfg[0].output_width = s->ci.frame_width; - s->stream_req.plane_cfg[0].output_height = s->ci.frame_height; - s->stream_req.plane_cfg[0].output_stride = s->ci.frame_width; - s->stream_req.plane_cfg[0].output_scan_lines = s->ci.frame_height; - s->stream_req.plane_cfg[0].rdi_cid = 0;*/ - - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_STREAM, &ss->stream_req); - LOG("isp request stream: %d -> 0x%x", err, ss->stream_req.axi_stream_handle); - - // ISP: REQUEST_BUF - ss->buf_request.session_id = ss->stream_req.session_id; - ss->buf_request.stream_id = ss->stream_req.stream_id; - ss->buf_request.num_buf = FRAME_BUF_COUNT; - ss->buf_request.buf_type = ISP_PRIVATE_BUF; - ss->buf_request.handle = 0; - cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_BUF, &ss->buf_request, "isp request buf"); - LOG("got buf handle: 0x%x", ss->buf_request.handle); - - // ENQUEUE all buffers - for (int j = 0; j < ss->buf_request.num_buf; j++) { - ss->qbuf_info[j].handle = ss->buf_request.handle; - ss->qbuf_info[j].buf_idx = j; - ss->qbuf_info[j].buffer.num_planes = 1; - ss->qbuf_info[j].buffer.planes[0].addr = ss->bufs[j].fd; - ss->qbuf_info[j].buffer.planes[0].length = ss->bufs[j].len; - err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &ss->qbuf_info[j]); - } - - // ISP: UPDATE_STREAM - struct msm_vfe_axi_stream_update_cmd update_cmd = {}; - update_cmd.num_streams = 1; - update_cmd.update_info[0].user_stream_id = ss->stream_req.stream_id; - update_cmd.update_info[0].stream_handle = ss->stream_req.axi_stream_handle; - update_cmd.update_type = UPDATE_STREAM_ADD_BUFQ; - cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_UPDATE_STREAM, &update_cmd, "isp update stream"); - } - - LOG("******** START STREAMS ********"); - - sub.id = 0; - sub.type = 0x1ff; - cam_ioctl(s->isp_fd, VIDIOC_SUBSCRIBE_EVENT, &sub, "isp subscribe"); - - // ISP: START_STREAM - s->stream_cfg.cmd = START_STREAM; - s->stream_cfg.num_streams = is_road_cam ? 3 : 1; - for (int i = 0; i < s->stream_cfg.num_streams; i++) { - s->stream_cfg.stream_handle[i] = s->ss[i].stream_req.axi_stream_handle; - } - cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg, "isp start stream"); -} - -static void road_camera_start(CameraState *s) { - set_exposure(s, 1.0, 1.0); - - int err = sensor_write_regs(s, start_reg_array, std::size(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); - LOG("sensor start regs: %d", err); - - int inf_step = 512 - INFINITY_DAC; - - // initial guess - s->lens_true_pos = 400; - - // reset lens position - struct msm_actuator_cfg_data actuator_cfg_data = {}; - actuator_cfg_data.cfgtype = CFG_SET_POSITION; - actuator_cfg_data.cfg.setpos = (struct msm_actuator_set_position_t){ - .number_of_steps = 1, - .hw_params = (uint32_t)7, - .pos = {INFINITY_DAC, 0}, - .delay = {0,} - }; - cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator set pos"); - - // TODO: confirm this isn't needed - /*memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data)); - actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS; - actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){ - .dir = 0, - .sign_dir = 1, - .dest_step_pos = inf_step, - .num_steps = inf_step, - .curr_lens_pos = 0, - .ringing_params = &actuator_ringing_params, - }; - err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); // should be ~332 at startup ? - LOG("init actuator move focus: %d", err);*/ - //actuator_cfg_data.cfg.move.curr_lens_pos; - - s->cur_lens_pos = 0; - s->cur_step_pos = inf_step; - - actuator_move(s, s->cur_lens_pos); - LOG("init lens pos: %d", s->cur_lens_pos); -} - -void actuator_move(CameraState *s, uint16_t target) { - // LP3 moves only on even positions. TODO: use proper sensor params - - // focus on infinity assuming phone is perpendicular - static struct damping_params_t actuator_ringing_params = { - .damping_step = 1023, - .damping_delay = 20000, - .hw_params = 13, - }; - - int step = (target - s->cur_lens_pos) / 2; - - int dest_step_pos = s->cur_step_pos + step; - dest_step_pos = std::clamp(dest_step_pos, 0, 255); - - struct msm_actuator_cfg_data actuator_cfg_data = {0}; - actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS; - actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){ - .dir = (int8_t)((step > 0) ? MOVE_NEAR : MOVE_FAR), - .sign_dir = (int8_t)((step > 0) ? MSM_ACTUATOR_MOVE_SIGNED_NEAR : MSM_ACTUATOR_MOVE_SIGNED_FAR), - .dest_step_pos = (int16_t)dest_step_pos, - .num_steps = abs(step), - .curr_lens_pos = s->cur_lens_pos, - .ringing_params = &actuator_ringing_params, - }; - HANDLE_EINTR(ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data)); - - s->cur_step_pos = dest_step_pos; - s->cur_lens_pos = actuator_cfg_data.cfg.move.curr_lens_pos; - //LOGD("step %d target: %d lens pos: %d", dest_step_pos, target, s->cur_lens_pos); -} - -static void parse_autofocus(CameraState *s, uint8_t *d) { - int good_count = 0; - int16_t max_focus = -32767; - int avg_focus = 0; - - /*printf("FOCUS: "); - for (int i = 0; i < 0x10; i++) { - printf("%2.2X ", d[i]); - }*/ - - for (int i = 0; i < NUM_FOCUS; i++) { - int doff = i*5+5; - s->confidence[i] = d[doff]; - // this should just be a 10-bit signed int instead of 11 - // TODO: write it in a nicer way - int16_t focus_t = (d[doff+1] << 3) | (d[doff+2] >> 5); - if (focus_t >= 1024) focus_t = -(2048-focus_t); - s->focus[i] = focus_t; - //printf("%x->%d ", d[doff], focus_t); - if (s->confidence[i] > 0x20) { - good_count++; - max_focus = std::max(max_focus, s->focus[i]); - avg_focus += s->focus[i]; - } - } - // self recover override - if (s->self_recover > 1) { - s->focus_err = 200 * ((s->self_recover % 2 == 0) ? 1:-1); // far for even numbers, close for odd - s->self_recover -= 2; - return; - } - - if (good_count < 4) { - s->focus_err = nan(""); - return; - } - - avg_focus /= good_count; - - // outlier rejection - if (abs(avg_focus - max_focus) > 200) { - s->focus_err = nan(""); - return; - } - - s->focus_err = max_focus*1.0; -} - -static void do_autofocus(CameraState *s) { - float lens_true_pos = s->lens_true_pos.load(); - if (!isnan(s->focus_err)) { - // learn lens_true_pos - const float focus_kp = 0.005; - lens_true_pos -= s->focus_err*focus_kp; - } - - // stay off the walls - lens_true_pos = std::clamp(lens_true_pos, float(LP3_AF_DAC_DOWN), float(LP3_AF_DAC_UP)); - s->lens_true_pos.store(lens_true_pos); - actuator_move(s, lens_true_pos); -} - -void camera_autoexposure(CameraState *s, float grey_frac) { - if (s->camera_num == 0) { - CameraExpInfo tmp = road_cam_exp.load(); - tmp.op_id++; - tmp.grey_frac = grey_frac; - road_cam_exp.store(tmp); - } else { - CameraExpInfo tmp = driver_cam_exp.load(); - tmp.op_id++; - tmp.grey_frac = grey_frac; - driver_cam_exp.store(tmp); - } -} - -static void driver_camera_start(CameraState *s) { - set_exposure(s, 1.0, 1.0); - int err = sensor_write_regs(s, start_reg_array, std::size(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); - LOG("sensor start regs: %d", err); -} - -void cameras_open(MultiCameraState *s) { - struct msm_ispif_param_data ispif_params = { - .num = 4, - .entries = { - // road camera - {.vfe_intf = VFE0, .intftype = RDI0, .num_cids = 1, .cids[0] = CID0, .csid = CSID0}, - // driver camera - {.vfe_intf = VFE1, .intftype = RDI0, .num_cids = 1, .cids[0] = CID0, .csid = CSID2}, - // road camera (focus) - {.vfe_intf = VFE0, .intftype = RDI1, .num_cids = 1, .cids[0] = CID1, .csid = CSID0}, - // road camera (stats, for AE) - {.vfe_intf = VFE0, .intftype = RDI2, .num_cids = 1, .cids[0] = CID2, .csid = CSID0}, - }, - }; - s->msmcfg_fd = HANDLE_EINTR(open("/dev/media0", O_RDWR | O_NONBLOCK)); - assert(s->msmcfg_fd >= 0); - - sensors_init(s); - - s->v4l_fd = HANDLE_EINTR(open("/dev/video0", O_RDWR | O_NONBLOCK)); - assert(s->v4l_fd >= 0); - - s->ispif_fd = open_v4l_by_name_and_index("msm_ispif"); - assert(s->ispif_fd >= 0); - - // ISPIF: stop - // memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); - // ispif_cfg_data.cfg_type = ISPIF_STOP_FRAME_BOUNDARY; - // ispif_cfg_data.params = ispif_params; - // err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); - // LOG("ispif stop: %d", err); - - LOG("*** open driver camera ***"); - s->driver_cam.ss[0].bufs = s->driver_cam.buf.camera_bufs.get(); - camera_open(&s->driver_cam, false); - - LOG("*** open road camera ***"); - s->road_cam.ss[0].bufs = s->road_cam.buf.camera_bufs.get(); - s->road_cam.ss[1].bufs = s->focus_bufs; - s->road_cam.ss[2].bufs = s->stats_bufs; - camera_open(&s->road_cam, true); - - if (getenv("CAMERA_TEST")) { - cameras_close(s); - exit(0); - } - - // ISPIF: set vfe info - struct ispif_cfg_data ispif_cfg_data = {.cfg_type = ISPIF_SET_VFE_INFO, .vfe_info.num_vfe = 2}; - int err = HANDLE_EINTR(ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data)); - LOG("ispif set vfe info: %d", err); - - // ISPIF: setup - ispif_cfg_data = {.cfg_type = ISPIF_INIT, .csid_version = 0x30050000 /* CSID_VERSION_V35*/}; - cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif setup"); - - ispif_cfg_data = {.cfg_type = ISPIF_CFG, .params = ispif_params}; - cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif cfg"); - - ispif_cfg_data.cfg_type = ISPIF_START_FRAME_BOUNDARY; - cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif start_frame_boundary"); - - driver_camera_start(&s->driver_cam); - road_camera_start(&s->road_cam); -} - - -static void camera_close(CameraState *s) { - // ISP: STOP_STREAM - s->stream_cfg.cmd = STOP_STREAM; - cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg, "isp stop stream"); - - for (int i = 0; i < 3; i++) { - StreamState *ss = &s->ss[i]; - if (ss->stream_req.axi_stream_handle != 0) { - cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_BUF, &ss->buf_request, "isp release buf"); - - struct msm_vfe_axi_stream_release_cmd stream_release = { - .stream_handle = ss->stream_req.axi_stream_handle, - }; - cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_STREAM, &stream_release, "isp release stream"); - } - } -} - -const char* get_isp_event_name(uint32_t type) { - switch (type) { - case ISP_EVENT_REG_UPDATE: return "ISP_EVENT_REG_UPDATE"; - case ISP_EVENT_EPOCH_0: return "ISP_EVENT_EPOCH_0"; - case ISP_EVENT_EPOCH_1: return "ISP_EVENT_EPOCH_1"; - case ISP_EVENT_START_ACK: return "ISP_EVENT_START_ACK"; - case ISP_EVENT_STOP_ACK: return "ISP_EVENT_STOP_ACK"; - case ISP_EVENT_IRQ_VIOLATION: return "ISP_EVENT_IRQ_VIOLATION"; - case ISP_EVENT_STATS_OVERFLOW: return "ISP_EVENT_STATS_OVERFLOW"; - case ISP_EVENT_ERROR: return "ISP_EVENT_ERROR"; - case ISP_EVENT_SOF: return "ISP_EVENT_SOF"; - case ISP_EVENT_EOF: return "ISP_EVENT_EOF"; - case ISP_EVENT_BUF_DONE: return "ISP_EVENT_BUF_DONE"; - case ISP_EVENT_BUF_DIVERT: return "ISP_EVENT_BUF_DIVERT"; - case ISP_EVENT_STATS_NOTIFY: return "ISP_EVENT_STATS_NOTIFY"; - case ISP_EVENT_COMP_STATS_NOTIFY: return "ISP_EVENT_COMP_STATS_NOTIFY"; - case ISP_EVENT_FE_READ_DONE: return "ISP_EVENT_FE_READ_DONE"; - case ISP_EVENT_IOMMU_P_FAULT: return "ISP_EVENT_IOMMU_P_FAULT"; - case ISP_EVENT_HW_FATAL_ERROR: return "ISP_EVENT_HW_FATAL_ERROR"; - case ISP_EVENT_PING_PONG_MISMATCH: return "ISP_EVENT_PING_PONG_MISMATCH"; - case ISP_EVENT_REG_UPDATE_MISSING: return "ISP_EVENT_REG_UPDATE_MISSING"; - case ISP_EVENT_BUF_FATAL_ERROR: return "ISP_EVENT_BUF_FATAL_ERROR"; - case ISP_EVENT_STREAM_UPDATE_DONE: return "ISP_EVENT_STREAM_UPDATE_DONE"; - default: return "unknown"; - } -} - -static FrameMetadata get_frame_metadata(CameraState *s, uint32_t frame_id) { - std::lock_guard lk(s->frame_info_lock); - for (auto &i : s->frame_metadata) { - if (i.frame_id == frame_id) { - return i; - } - } - // should never happen - return (FrameMetadata){ - .frame_id = (uint32_t)-1, - }; -} - -static void ops_thread(MultiCameraState *s) { - int last_road_cam_op_id = 0; - int last_driver_cam_op_id = 0; - - CameraExpInfo road_cam_op; - CameraExpInfo driver_cam_op; - - util::set_thread_name("camera_settings"); - while(!do_exit) { - road_cam_op = road_cam_exp.load(); - if (road_cam_op.op_id != last_road_cam_op_id) { - do_autoexposure(&s->road_cam, road_cam_op.grey_frac); - do_autofocus(&s->road_cam); - last_road_cam_op_id = road_cam_op.op_id; - } - - driver_cam_op = driver_cam_exp.load(); - if (driver_cam_op.op_id != last_driver_cam_op_id) { - do_autoexposure(&s->driver_cam, driver_cam_op.grey_frac); - last_driver_cam_op_id = driver_cam_op.op_id; - } - - util::sleep_for(50); - } -} - -static void setup_self_recover(CameraState *c, const uint16_t *lapres, size_t lapres_size) { - const float lens_true_pos = c->lens_true_pos.load(); - int self_recover = c->self_recover.load(); - if (self_recover < 2 && (lens_true_pos < (LP3_AF_DAC_DOWN + 1) || lens_true_pos > (LP3_AF_DAC_UP - 1)) && is_blur(lapres, lapres_size)) { - // truly stuck, needs help - if (--self_recover < -FOCUS_RECOVER_PATIENCE) { - LOGD("road camera bad state detected. attempting recovery from %.1f, recover state is %d", lens_true_pos, self_recover); - // parity determined by which end is stuck at - self_recover = FOCUS_RECOVER_STEPS + (lens_true_pos < LP3_AF_DAC_M ? 1 : 0); - } - } else if (self_recover < 2 && (lens_true_pos < (LP3_AF_DAC_M - LP3_AF_DAC_3SIG) || lens_true_pos > (LP3_AF_DAC_M + LP3_AF_DAC_3SIG))) { - // in suboptimal position with high prob, but may still recover by itself - if (--self_recover < -(FOCUS_RECOVER_PATIENCE * 3)) { - self_recover = FOCUS_RECOVER_STEPS / 2 + (lens_true_pos < LP3_AF_DAC_M ? 1 : 0); - } - } else if (self_recover < 0) { - self_recover += 1; // reset if fine - } - c->self_recover.store(self_recover); -} - -// called by processing_thread -void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) { - const CameraBuf *b = &c->buf; - const int roi_id = cnt % std::size(s->lapres); // rolling roi - s->lapres[roi_id] = s->lap_conv->Update(b->q, (uint8_t *)b->cur_rgb_buf->addr, roi_id); - setup_self_recover(c, &s->lapres[0], std::size(s->lapres)); - - MessageBuilder msg; - auto framed = msg.initEvent().initRoadCameraState(); - fill_frame_data(framed, b->cur_frame_data); - if (env_send_road) { - framed.setImage(get_frame_image(b)); - } - framed.setFocusVal(s->road_cam.focus); - framed.setFocusConf(s->road_cam.confidence); - framed.setRecoverState(s->road_cam.self_recover); - framed.setSharpnessScore(s->lapres); - framed.setTransform(b->yuv_transform.v); - s->pm->send("roadCameraState", msg); - - if (cnt % 3 == 0) { - const int x = 290, y = 322, width = 560, height = 314; - const int skip = 1; - camera_autoexposure(c, set_exposure_target(b, x, x + width, skip, y, y + height, skip)); - } -} - -void cameras_run(MultiCameraState *s) { - std::vector threads; - threads.push_back(std::thread(ops_thread, s)); - threads.push_back(start_process_thread(s, &s->road_cam, process_road_camera)); - threads.push_back(start_process_thread(s, &s->driver_cam, common_process_driver_camera)); - - CameraState* cameras[2] = {&s->road_cam, &s->driver_cam}; - - while (!do_exit) { - struct pollfd fds[2] = {{.fd = cameras[0]->isp_fd, .events = POLLPRI}, - {.fd = cameras[1]->isp_fd, .events = POLLPRI}}; - int ret = poll(fds, std::size(fds), 1000); - if (ret < 0) { - if (errno == EINTR || errno == EAGAIN) continue; - LOGE("poll failed (%d - %d)", ret, errno); - break; - } - - // process cameras - for (int i=0; i<2; i++) { - if (!fds[i].revents) continue; - - CameraState *c = cameras[i]; - - struct v4l2_event ev = {}; - ret = HANDLE_EINTR(ioctl(c->isp_fd, VIDIOC_DQEVENT, &ev)); - const msm_isp_event_data *isp_event_data = (const msm_isp_event_data *)ev.u.data; - - if (ev.type == ISP_EVENT_BUF_DIVERT) { - const int buf_idx = isp_event_data->u.buf_done.buf_idx; - const int buffer = (isp_event_data->u.buf_done.stream_id & 0xFFFF) - 1; - if (buffer == 0) { - c->buf.camera_bufs_metadata[buf_idx] = get_frame_metadata(c, isp_event_data->frame_id); - c->buf.queue(buf_idx); - } else { - auto &ss = c->ss[buffer]; - if (buffer == 1) { - parse_autofocus(c, (uint8_t *)(ss.bufs[buf_idx].addr)); - } - ss.qbuf_info[buf_idx].dirty_buf = 1; - HANDLE_EINTR(ioctl(c->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &ss.qbuf_info[buf_idx])); - } - - } else if (ev.type == ISP_EVENT_EOF) { - const uint64_t timestamp = (isp_event_data->mono_timestamp.tv_sec * 1000000000ULL + isp_event_data->mono_timestamp.tv_usec * 1000); - std::lock_guard lk(c->frame_info_lock); - c->frame_metadata[c->frame_metadata_idx] = (FrameMetadata){ - .frame_id = isp_event_data->frame_id, - .timestamp_eof = timestamp, - .frame_length = (uint32_t)c->frame_length, - .integ_lines = (uint32_t)c->cur_integ_lines, - .lens_pos = c->cur_lens_pos, - .lens_err = c->focus_err, - .lens_true_pos = c->lens_true_pos, - .gain = c->cur_gain_frac, - .measured_grey_fraction = c->measured_grey_fraction, - .target_grey_fraction = c->target_grey_fraction, - .high_conversion_gain = false, - }; - c->frame_metadata_idx = (c->frame_metadata_idx + 1) % METADATA_BUF_COUNT; - - } else if (ev.type == ISP_EVENT_ERROR) { - LOGE("ISP_EVENT_ERROR! err type: 0x%08x", isp_event_data->u.error_info.err_type); - } - } - } - - LOG(" ************** STOPPING **************"); - - for (auto &t : threads) t.join(); - - cameras_close(s); -} - -void cameras_close(MultiCameraState *s) { - camera_close(&s->road_cam); - camera_close(&s->driver_cam); - for (int i = 0; i < FRAME_BUF_COUNT; i++) { - s->focus_bufs[i].free(); - s->stats_bufs[i].free(); - } - - delete s->lap_conv; - delete s->sm; - delete s->pm; -} diff --git a/selfdrive/camerad/cameras/camera_qcom.h b/selfdrive/camerad/cameras/camera_qcom.h deleted file mode 100644 index 87bbe4b7e7..0000000000 --- a/selfdrive/camerad/cameras/camera_qcom.h +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once - -#include -#include -#include - -#include "cereal/messaging/messaging.h" -#include "cereal/visionipc/visionbuf.h" -#include "selfdrive/camerad/cameras/camera_common.h" -#include "selfdrive/camerad/imgproc/utils.h" -#include "selfdrive/camerad/include/msm_cam_sensor.h" -#include "selfdrive/camerad/include/msmb_camera.h" -#include "selfdrive/camerad/include/msmb_isp.h" -#include "selfdrive/camerad/include/msmb_ispif.h" -#include "selfdrive/common/mat.h" -#include "selfdrive/common/util.h" - -#define FRAME_BUF_COUNT 4 -#define METADATA_BUF_COUNT 4 - -#define NUM_FOCUS 8 - -#define LP3_AF_DAC_DOWN 366 -#define LP3_AF_DAC_UP 634 -#define LP3_AF_DAC_M 440 -#define LP3_AF_DAC_3SIG 52 - -#define FOCUS_RECOVER_PATIENCE 50 // 2.5 seconds of complete blur -#define FOCUS_RECOVER_STEPS 240 // 6 seconds - -typedef struct CameraState CameraState; - -typedef int (*camera_apply_exposure_func)(CameraState *s, int gain, int integ_lines, uint32_t frame_length); - -typedef struct StreamState { - struct msm_isp_buf_request buf_request; - struct msm_vfe_axi_stream_request_cmd stream_req; - struct msm_isp_qbuf_info qbuf_info[FRAME_BUF_COUNT]; - VisionBuf *bufs; -} StreamState; - -typedef struct CameraState { - int camera_num; - int camera_id; - - int fps; - CameraInfo ci; - - unique_fd csid_fd; - unique_fd csiphy_fd; - unique_fd sensor_fd; - unique_fd isp_fd; - - struct msm_vfe_axi_stream_cfg_cmd stream_cfg; - - StreamState ss[3]; - CameraBuf buf; - - std::mutex frame_info_lock; - FrameMetadata frame_metadata[METADATA_BUF_COUNT]; - int frame_metadata_idx; - - // exposure - uint32_t pixel_clock, line_length_pclk; - uint32_t frame_length; - unsigned int max_gain; - float cur_exposure_frac, cur_gain_frac; - int cur_gain, cur_integ_lines; - - float measured_grey_fraction; - float target_grey_fraction; - - std::atomic digital_gain; - camera_apply_exposure_func apply_exposure; - - // rear camera only,used for focusing - unique_fd actuator_fd; - std::atomic focus_err; - std::atomic lens_true_pos; - std::atomic self_recover; // af recovery counter, neg is patience, pos is active - uint16_t cur_step_pos; - uint16_t cur_lens_pos; - int16_t focus[NUM_FOCUS]; - uint8_t confidence[NUM_FOCUS]; -} CameraState; - - -typedef struct MultiCameraState { - unique_fd ispif_fd; - unique_fd msmcfg_fd; - unique_fd v4l_fd; - uint16_t lapres[(ROI_X_MAX-ROI_X_MIN+1)*(ROI_Y_MAX-ROI_Y_MIN+1)]; - - VisionBuf focus_bufs[FRAME_BUF_COUNT]; - VisionBuf stats_bufs[FRAME_BUF_COUNT]; - - CameraState road_cam; - CameraState driver_cam; - - SubMaster *sm; - PubMaster *pm; - LapConv *lap_conv; -} MultiCameraState; - -void actuator_move(CameraState *s, uint16_t target); -int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type); diff --git a/selfdrive/camerad/main.cc b/selfdrive/camerad/main.cc index 668410d6f7..58edaedd9b 100644 --- a/selfdrive/camerad/main.cc +++ b/selfdrive/camerad/main.cc @@ -7,11 +7,11 @@ #include "selfdrive/hardware/hw.h" int main(int argc, char *argv[]) { - if (!Hardware::PC()) { + if (Hardware::TICI()) { int ret; ret = util::set_realtime_priority(53); assert(ret == 0); - ret = util::set_core_affinity({Hardware::EON() ? 2 : 6}); + ret = util::set_core_affinity({6}); assert(ret == 0 || Params().getBool("IsOffroad")); // failure ok while offroad due to offlining cores } diff --git a/selfdrive/camerad/test/test_camerad.py b/selfdrive/camerad/test/test_camerad.py index ff37ad1f31..c311c17169 100755 --- a/selfdrive/camerad/test/test_camerad.py +++ b/selfdrive/camerad/test/test_camerad.py @@ -4,11 +4,9 @@ import time import unittest import cereal.messaging as messaging +from selfdrive.hardware import TICI from selfdrive.test.helpers import with_processes -# only tests for EON and TICI -from selfdrive.hardware import EON, TICI - TEST_TIMESPAN = 30 # random.randint(60, 180) # seconds SKIP_FRAME_TOLERANCE = 0 LAG_FRAME_TOLERANCE = 2 # ms @@ -26,7 +24,7 @@ if TICI: class TestCamerad(unittest.TestCase): @classmethod def setUpClass(cls): - if not (EON or TICI): + if not TICI: raise unittest.SkipTest @with_processes(['camerad']) diff --git a/selfdrive/camerad/test/test_exposure.py b/selfdrive/camerad/test/test_exposure.py index 6ed69627b5..31bcc28681 100755 --- a/selfdrive/camerad/test/test_exposure.py +++ b/selfdrive/camerad/test/test_exposure.py @@ -6,7 +6,7 @@ import numpy as np from selfdrive.test.helpers import with_processes from selfdrive.camerad.snapshot.snapshot import get_snapshots -from selfdrive.hardware import EON, TICI +from selfdrive.hardware import TICI TEST_TIME = 45 REPEAT = 5 @@ -14,7 +14,7 @@ REPEAT = 5 class TestCamerad(unittest.TestCase): @classmethod def setUpClass(cls): - if not (EON or TICI): + if not TICI: raise unittest.SkipTest def _numpy_rgb2gray(self, im): diff --git a/selfdrive/clocksd/clocksd.cc b/selfdrive/clocksd/clocksd.cc index c24ffa41d9..a6a92fc058 100644 --- a/selfdrive/clocksd/clocksd.cc +++ b/selfdrive/clocksd/clocksd.cc @@ -21,16 +21,6 @@ ExitHandler do_exit; -#ifdef QCOM -namespace { - int64_t arm_cntpct() { - int64_t v; - asm volatile("mrs %0, cntpct_el0" : "=r"(v)); - return v; - } -} -#endif - int main() { setpriority(PRIO_PROCESS, 0, -13); PubMaster pm({"clocks"}); @@ -65,10 +55,6 @@ int main() { uint64_t monotonic_raw = nanos_monotonic_raw(); uint64_t wall_time = nanos_since_epoch(); -#ifdef QCOM - uint64_t modem_uptime_v = arm_cntpct() / 19200ULL; // 19.2 mhz clock -#endif - MessageBuilder msg; auto clocks = msg.initEvent().initClocks(); @@ -76,9 +62,6 @@ int main() { clocks.setMonotonicNanos(monotonic); clocks.setMonotonicRawNanos(monotonic_raw); clocks.setWallTimeNanos(wall_time); -#ifdef QCOM - clocks.setModemUptimeMillis(modem_uptime_v); -#endif pm.send("clocks", msg); } diff --git a/selfdrive/common/SConscript b/selfdrive/common/SConscript index 8dfeecbdd7..e53cb7615d 100644 --- a/selfdrive/common/SConscript +++ b/selfdrive/common/SConscript @@ -22,9 +22,7 @@ files = [ 'visionimg.cc', ] -if arch == "aarch64": - _gpu_libs = ['gui', 'adreno_utils'] -elif arch == "larch64": +if arch == "larch64": _gpu_libs = ["GLESv2"] else: _gpu_libs = ["GL"] diff --git a/selfdrive/common/modeldata.h b/selfdrive/common/modeldata.h index 9ebf7d5ff0..6b30e60506 100644 --- a/selfdrive/common/modeldata.h +++ b/selfdrive/common/modeldata.h @@ -32,13 +32,9 @@ namespace tici_dm_crop { const int width = 954; }; -const mat3 fcam_intrinsic_matrix = - Hardware::EON() ? (mat3){{910., 0., 1164.0 / 2, - 0., 910., 874.0 / 2, - 0., 0., 1.}} - : (mat3){{2648.0, 0.0, 1928.0 / 2, - 0.0, 2648.0, 1208.0 / 2, - 0.0, 0.0, 1.0}}; +const mat3 fcam_intrinsic_matrix = (mat3){{2648.0, 0.0, 1928.0 / 2, + 0.0, 2648.0, 1208.0 / 2, + 0.0, 0.0, 1.0}}; // tici ecam focal probably wrong? magnification is not consistent across frame // Need to retrain model before this can be changed @@ -47,7 +43,7 @@ const mat3 ecam_intrinsic_matrix = (mat3){{567.0, 0.0, 1928.0 / 2, 0.0, 0.0, 1.0}}; static inline mat3 get_model_yuv_transform(bool bayer = true) { - float db_s = Hardware::EON() ? 0.5 : 1.0; // debayering does a 2x downscale on EON + float db_s = 1.0; const mat3 transform = (mat3){{ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 0c36511be7..29687b1a0e 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -166,7 +166,6 @@ std::unordered_map keys = { {"ApiCache_Owner", PERSISTENT}, {"Offroad_BadNvme", CLEAR_ON_MANAGER_START}, {"Offroad_CarUnrecognized", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, - {"Offroad_ChargeDisabled", CLEAR_ON_MANAGER_START }, {"Offroad_ConnectivityNeeded", CLEAR_ON_MANAGER_START}, {"Offroad_ConnectivityNeededPrompt", CLEAR_ON_MANAGER_START}, {"Offroad_InvalidTime", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/common/swaglog.cc b/selfdrive/common/swaglog.cc index 618421194c..1110855cd3 100644 --- a/selfdrive/common/swaglog.cc +++ b/selfdrive/common/swaglog.cc @@ -50,9 +50,7 @@ class SwaglogState : public LogState { ctx_j["dirty"] = !getenv("CLEAN"); // device type - if (Hardware::EON()) { - ctx_j["device"] = "eon"; - } else if (Hardware::TICI()) { + if (Hardware::TICI()) { ctx_j["device"] = "tici"; } else { ctx_j["device"] = "pc"; diff --git a/selfdrive/common/tests/test_swaglog.cc b/selfdrive/common/tests/test_swaglog.cc index 1d00def63d..47c5504638 100644 --- a/selfdrive/common/tests/test_swaglog.cc +++ b/selfdrive/common/tests/test_swaglog.cc @@ -57,9 +57,7 @@ void recv_log(int thread_cnt, int thread_msg_cnt) { REQUIRE(ctx["version"].string_value() == COMMA_VERSION); std::string device = "pc"; - if (Hardware::EON()) { - device = "eon"; - } else if (Hardware::TICI()) { + if (Hardware::TICI()) { device = "tici"; } REQUIRE(ctx["device"].string_value() == device); diff --git a/selfdrive/common/visionimg.cc b/selfdrive/common/visionimg.cc index a98aabc36c..b67f0e202d 100644 --- a/selfdrive/common/visionimg.cc +++ b/selfdrive/common/visionimg.cc @@ -2,54 +2,6 @@ #include -#ifdef QCOM -#include -#include -#include -#include -#define GL_GLEXT_PROTOTYPES -#include -using namespace android; - -EGLImageTexture::EGLImageTexture(const VisionBuf *buf) { - const int bpp = 3; - assert((buf->len % buf->stride) == 0); - assert((buf->stride % bpp) == 0); - - const int format = HAL_PIXEL_FORMAT_RGB_888; - private_handle = new private_handle_t(buf->fd, buf->len, - private_handle_t::PRIV_FLAGS_USES_ION|private_handle_t::PRIV_FLAGS_FRAMEBUFFER, - 0, format, - buf->stride/bpp, buf->len/buf->stride, - buf->width, buf->height); - - // GraphicBuffer is ref counted by EGLClientBuffer(ANativeWindowBuffer), no need and not possible to release. - GraphicBuffer* gb = new GraphicBuffer(buf->width, buf->height, (PixelFormat)format, - GraphicBuffer::USAGE_HW_TEXTURE, buf->stride/bpp, (private_handle_t*)private_handle, false); - - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - assert(display != EGL_NO_DISPLAY); - - EGLint img_attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; - img_khr = eglCreateImageKHR(display, EGL_NO_CONTEXT, - EGL_NATIVE_BUFFER_ANDROID, gb->getNativeBuffer(), img_attrs); - assert(img_khr != EGL_NO_IMAGE_KHR); - - glGenTextures(1, &frame_tex); - glBindTexture(GL_TEXTURE_2D, frame_tex); - glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, img_khr); -} - -EGLImageTexture::~EGLImageTexture() { - glDeleteTextures(1, &frame_tex); - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - assert(display != EGL_NO_DISPLAY); - eglDestroyImageKHR(display, img_khr); - delete (private_handle_t*)private_handle; -} - -#else // ifdef QCOM - EGLImageTexture::EGLImageTexture(const VisionBuf *buf) { glGenTextures(1, &frame_tex); glBindTexture(GL_TEXTURE_2D, frame_tex); @@ -60,4 +12,3 @@ EGLImageTexture::EGLImageTexture(const VisionBuf *buf) { EGLImageTexture::~EGLImageTexture() { glDeleteTextures(1, &frame_tex); } -#endif // ifdef QCOM diff --git a/selfdrive/common/visionimg.h b/selfdrive/common/visionimg.h index e8917f3bd6..0cb41a32b8 100644 --- a/selfdrive/common/visionimg.h +++ b/selfdrive/common/visionimg.h @@ -8,20 +8,9 @@ #include #endif -#ifdef QCOM -#include -#define EGL_EGLEXT_PROTOTYPES -#include -#undef Status -#endif - class EGLImageTexture { public: EGLImageTexture(const VisionBuf *buf); ~EGLImageTexture(); GLuint frame_tex = 0; -#ifdef QCOM - void *private_handle = nullptr; - EGLImageKHR img_khr = 0; -#endif }; diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 43f0352d9e..f098657fb9 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -26,7 +26,7 @@ from selfdrive.controls.lib.events import Events, ET from selfdrive.controls.lib.alertmanager import AlertManager, set_offroad_alert from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.locationd.calibrationd import Calibration -from selfdrive.hardware import HARDWARE, TICI, EON +from selfdrive.hardware import HARDWARE, TICI from selfdrive.manager.process_config import managed_processes SOFT_DISABLE_TIME = 3 # seconds @@ -36,9 +36,8 @@ LANE_DEPARTURE_THRESHOLD = 0.1 REPLAY = "REPLAY" in os.environ SIMULATION = "SIMULATION" in os.environ NOSENSOR = "NOSENSOR" in os.environ -IGNORE_PROCESSES = {"rtshield", "uploader", "deleter", "loggerd", "logmessaged", "tombstoned", - "logcatd", "proclogd", "clocksd", "updated", "timezoned", "manage_athenad", - "statsd", "shutdownd"} | \ +IGNORE_PROCESSES = {"uploader", "deleter", "loggerd", "logmessaged", "tombstoned", "statsd", + "logcatd", "proclogd", "clocksd", "updated", "timezoned", "manage_athenad"} | \ {k for k, v in managed_processes.items() if not v.enabled} ThermalStatus = log.DeviceState.ThermalStatus @@ -220,11 +219,7 @@ class Controls: if not self.CP.notCar: self.events.add_from_msg(self.sm['driverMonitoringState'].events) - # Create events for battery, temperature, disk space, and memory - if EON and (self.sm['peripheralState'].pandaType != PandaType.uno) and \ - self.sm['deviceState'].batteryPercent < 1 and self.sm['deviceState'].chargingError: - # at zero percent battery, while discharging, OP should not allowed - self.events.add(EventName.lowBattery) + # Create events for temperature, disk space, and memory if self.sm['deviceState'].thermalStatus >= ThermalStatus.red: self.events.add(EventName.overheat) if self.sm['deviceState'].freeSpacePercent < 7 and not SIMULATION: @@ -235,7 +230,7 @@ class Controls: self.events.add(EventName.lowMemory) # TODO: enable this once loggerd CPU usage is more reasonable - #cpus = list(self.sm['deviceState'].cpuUsagePercent)[:(-1 if EON else None)] + #cpus = list(self.sm['deviceState'].cpuUsagePercent) #if max(cpus, default=0) > 95 and not SIMULATION: # self.events.add(EventName.highCpuUsage) diff --git a/selfdrive/controls/lib/alerts_offroad.json b/selfdrive/controls/lib/alerts_offroad.json index 4f0ffa794d..2f85ea917a 100644 --- a/selfdrive/controls/lib/alerts_offroad.json +++ b/selfdrive/controls/lib/alerts_offroad.json @@ -1,8 +1,4 @@ { - "Offroad_ChargeDisabled": { - "text": "EON charging disabled after car being off for more than 30 hours. Turn ignition on to start charging again.", - "severity": 0 - }, "Offroad_TemperatureTooHigh": { "text": "Device temperature too high. System won't start.", "severity": 1 diff --git a/selfdrive/controls/lib/lane_planner.py b/selfdrive/controls/lib/lane_planner.py index 0230255ef9..aedf61a073 100644 --- a/selfdrive/controls/lib/lane_planner.py +++ b/selfdrive/controls/lib/lane_planner.py @@ -3,7 +3,7 @@ from cereal import log from common.filter_simple import FirstOrderFilter from common.numpy_fast import interp from common.realtime import DT_MDL -from selfdrive.hardware import EON, TICI +from selfdrive.hardware import TICI from selfdrive.swaglog import cloudlog @@ -13,9 +13,7 @@ TRAJECTORY_SIZE = 33 # the model knows the difference between TICI and EON # so a path offset is not needed PATH_OFFSET = 0.00 -if EON: - CAMERA_OFFSET = -0.06 -elif TICI: +if TICI: CAMERA_OFFSET = 0.04 else: CAMERA_OFFSET = 0.0 diff --git a/selfdrive/controls/lib/lateral_mpc_lib/SConscript b/selfdrive/controls/lib/lateral_mpc_lib/SConscript index 76f7fadce7..df1e2a2a1a 100644 --- a/selfdrive/controls/lib/lateral_mpc_lib/SConscript +++ b/selfdrive/controls/lib/lateral_mpc_lib/SConscript @@ -48,7 +48,6 @@ acados_templates_dir = '#pyextra/acados_template/c_templates_tera' source_list = ['lat_mpc.py', f'{acados_dir}/include/acados_c/ocp_nlp_interface.h', - f'{acados_dir}/aarch64/lib/libacados.so', f'{acados_dir}/x86_64/lib/libacados.so', f'{acados_dir}/larch64/lib/libacados.so', f'{acados_templates_dir}/acados_solver.in.c', diff --git a/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript b/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript index fd0da63a37..5a9e69c297 100644 --- a/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript +++ b/selfdrive/controls/lib/longitudinal_mpc_lib/SConscript @@ -55,7 +55,6 @@ acados_templates_dir = '#pyextra/acados_template/c_templates_tera' source_list = ['long_mpc.py', f'{acados_dir}/include/acados_c/ocp_nlp_interface.h', - f'{acados_dir}/aarch64/lib/libacados.so', f'{acados_dir}/x86_64/lib/libacados.so', f'{acados_dir}/larch64/lib/libacados.so', f'{acados_templates_dir}/acados_solver.in.c', diff --git a/selfdrive/debug/README.md b/selfdrive/debug/README.md index d49db25d09..f6903170a2 100644 --- a/selfdrive/debug/README.md +++ b/selfdrive/debug/README.md @@ -52,7 +52,7 @@ optional arguments: -h, --help show this help message and exit --debug enable ISO-TP/UDS stack debugging output -This tool is meant to run directly on a vehicle-installed comma two or comma three, with +This tool is meant to run directly on a vehicle-installed comma three, with the openpilot/tmux processes stopped. It should also work on a separate PC with a USB- attached comma panda. Vehicle ignition must be on. Recommend engine not be running when making changes. Must turn ignition off and on again for any changes to take effect. diff --git a/selfdrive/debug/adb.sh b/selfdrive/debug/adb.sh index 8a04d4aefd..919a82fefc 100755 --- a/selfdrive/debug/adb.sh +++ b/selfdrive/debug/adb.sh @@ -4,12 +4,7 @@ set -e PORT=5555 setprop service.adb.tcp.port $PORT -if [ -f /EON ]; then - stop adbd - start adbd -else - sudo systemctl start adbd -fi +sudo systemctl start adbd IP=$(echo $SSH_CONNECTION | awk '{ print $3}') echo "then, connect on your computer:" diff --git a/selfdrive/debug/vw_mqb_config.py b/selfdrive/debug/vw_mqb_config.py index 1dd28d371f..c55a058159 100755 --- a/selfdrive/debug/vw_mqb_config.py +++ b/selfdrive/debug/vw_mqb_config.py @@ -23,7 +23,7 @@ if __name__ == "__main__": desc_text = "Shows Volkswagen EPS software and coding info, and enables or disables Heading Control Assist " + \ "(Lane Assist). Useful for enabling HCA on cars without factory Lane Assist that want to use " + \ "openpilot integrated at the CAN gateway (J533)." - epilog_text = "This tool is meant to run directly on a vehicle-installed comma two or comma three, with the " + \ + epilog_text = "This tool is meant to run directly on a vehicle-installed comma three, with the " + \ "openpilot/tmux processes stopped. It should also work on a separate PC with a USB-attached comma " + \ "panda. Vehicle ignition must be on. Recommend engine not be running when making changes. Must " + \ "turn ignition off and on again for any changes to take effect." diff --git a/selfdrive/hardware/__init__.py b/selfdrive/hardware/__init__.py index 3babf1bb5d..03dfce86d7 100644 --- a/selfdrive/hardware/__init__.py +++ b/selfdrive/hardware/__init__.py @@ -2,18 +2,14 @@ import os from typing import cast from selfdrive.hardware.base import HardwareBase -from selfdrive.hardware.eon.hardware import Android from selfdrive.hardware.tici.hardware import Tici from selfdrive.hardware.pc.hardware import Pc -EON = os.path.isfile('/EON') TICI = os.path.isfile('/TICI') -PC = not (EON or TICI) +PC = not TICI -if EON: - HARDWARE = cast(HardwareBase, Android()) -elif TICI: +if TICI: HARDWARE = cast(HardwareBase, Tici()) else: HARDWARE = cast(HardwareBase, Pc()) diff --git a/selfdrive/hardware/base.h b/selfdrive/hardware/base.h index 05e55cc034..2826d09700 100644 --- a/selfdrive/hardware/base.h +++ b/selfdrive/hardware/base.h @@ -20,6 +20,5 @@ public: static void set_ssh_enabled(bool enabled) {} static bool PC() { return false; } - static bool EON() { return false; } static bool TICI() { return false; } }; diff --git a/selfdrive/hardware/eon/__init__.py b/selfdrive/hardware/eon/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/selfdrive/hardware/eon/androidd.py b/selfdrive/hardware/eon/androidd.py deleted file mode 100755 index 3d91468b90..0000000000 --- a/selfdrive/hardware/eon/androidd.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python3 -import os -import time -import psutil -from typing import Optional - -import cereal.messaging as messaging -from common.realtime import set_core_affinity, set_realtime_priority -from selfdrive.swaglog import cloudlog - - -MAX_MODEM_CRASHES = 3 -MODEM_PATH = "/sys/devices/soc/2080000.qcom,mss/subsys5" -WATCHED_PROCS = ["zygote", "zygote64", "system_server", "/system/bin/servicemanager", "/system/bin/surfaceflinger"] - - -def get_modem_crash_count() -> Optional[int]: - try: - with open(os.path.join(MODEM_PATH, "crash_count")) as f: - return int(f.read()) - except Exception: - cloudlog.exception("Error reading modem crash count") - return None - -def get_modem_state() -> str: - try: - with open(os.path.join(MODEM_PATH, "state")) as f: - return f.read().strip() - except Exception: - cloudlog.exception("Error reading modem state") - return "" - -def main(): - set_core_affinity(1) - set_realtime_priority(1) - - procs = {} - crash_count = 0 - modem_killed = False - modem_state = "ONLINE" - androidLog = messaging.sub_sock('androidLog') - - while True: - # check critical android services - if any(p is None or not p.is_running() for p in procs.values()) or not len(procs): - cur = {p: None for p in WATCHED_PROCS} - for p in psutil.process_iter(attrs=['cmdline']): - cmdline = None if not len(p.info['cmdline']) else p.info['cmdline'][0] - if cmdline in WATCHED_PROCS: - cur[cmdline] = p - - if len(procs): - for p in WATCHED_PROCS: - if cur[p] != procs[p]: - cloudlog.event("android service pid changed", proc=p, cur=cur[p], prev=procs[p], error=True) - procs.update(cur) - - # log caught NetworkPolicy exceptions - msgs = messaging.drain_sock(androidLog) - for m in msgs: - try: - if m.androidLog.tag == "NetworkPolicy" and m.androidLog.message.startswith("problem with advise persist threshold"): - cloudlog.event("network policy exception caught", androidLog=m.androidLog, error=True) - except UnicodeDecodeError: - pass - - if os.path.exists(MODEM_PATH): - # check modem state - state = get_modem_state() - if state != modem_state and not modem_killed: - cloudlog.event("modem state changed", state=state) - modem_state = state - - # check modem crashes - cnt = get_modem_crash_count() - if cnt is not None: - if cnt > crash_count: - cloudlog.event("modem crash", count=cnt) - crash_count = cnt - - # handle excessive modem crashes - if crash_count > MAX_MODEM_CRASHES and not modem_killed: - cloudlog.event("killing modem", error=True) - with open("/sys/kernel/debug/msm_subsys/modem", "w") as f: - f.write("put") - modem_killed = True - - time.sleep(1) - -if __name__ == "__main__": - main() diff --git a/selfdrive/hardware/eon/hardware.h b/selfdrive/hardware/eon/hardware.h deleted file mode 100644 index bcd1aaba74..0000000000 --- a/selfdrive/hardware/eon/hardware.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include -#include - -#include -#include -#include - -#include "selfdrive/common/util.h" -#include "selfdrive/hardware/base.h" - -class HardwareEon : public HardwareNone { -public: - static constexpr float MAX_VOLUME = 1.0; - static constexpr float MIN_VOLUME = 0.5; - - static bool EON() { return true; } - static std::string get_os_version() { - return "NEOS " + util::read_file("/VERSION"); - }; - - static void reboot() { std::system("reboot"); }; - static void poweroff() { std::system("LD_LIBRARY_PATH= svc power shutdown"); }; - static void set_brightness(int percent) { - std::ofstream brightness_control("/sys/class/leds/lcd-backlight/brightness"); - if (brightness_control.is_open()) { - brightness_control << (int)(percent * (255/100.)) << "\n"; - brightness_control.close(); - } - }; - static void set_display_power(bool on) { - auto dtoken = android::SurfaceComposerClient::getBuiltInDisplay(android::ISurfaceComposer::eDisplayIdMain); - android::SurfaceComposerClient::setDisplayPowerMode(dtoken, on ? HWC_POWER_MODE_NORMAL : HWC_POWER_MODE_OFF); - }; - - static bool get_ssh_enabled() { - return std::system("getprop persist.neos.ssh | grep -qF '1'") == 0; - }; - static void set_ssh_enabled(bool enabled) { - std::string cmd = util::string_format("setprop persist.neos.ssh %d", enabled ? 1 : 0); - std::system(cmd.c_str()); - }; - - // android only - inline static bool launched_activity = false; - static void check_activity() { - int ret = std::system("dumpsys SurfaceFlinger --list | grep -Fq 'com.android.settings'"); - launched_activity = ret == 0; - } - - static void close_activities() { - if(launched_activity) { - std::system("pm disable com.android.settings && pm enable com.android.settings"); - } - } - - static void launch_activity(std::string activity, std::string opts = "") { - if (!launched_activity) { - std::string cmd = "am start -n " + activity + " " + opts + - " --ez extra_prefs_show_button_bar true \ - --es extra_prefs_set_next_text ''"; - std::system(cmd.c_str()); - } - launched_activity = true; - } - static void launch_wifi() { - launch_activity("com.android.settings/.wifi.WifiPickerActivity", "-a android.net.wifi.PICK_WIFI_NETWORK"); - } - static void launch_tethering() { - launch_activity("com.android.settings/.TetherSettings"); - } -}; diff --git a/selfdrive/hardware/eon/hardware.py b/selfdrive/hardware/eon/hardware.py deleted file mode 100644 index bd2a01cf1e..0000000000 --- a/selfdrive/hardware/eon/hardware.py +++ /dev/null @@ -1,425 +0,0 @@ -import binascii -import itertools -import os -import re -import serial -import struct -import subprocess -from typing import List, Union - -from cereal import log -from selfdrive.hardware.base import HardwareBase, ThermalConfig - -try: - from common.params import Params -except Exception: - # openpilot is not built yet - Params = None - -NetworkType = log.DeviceState.NetworkType -NetworkStrength = log.DeviceState.NetworkStrength - -MODEM_PATH = "/dev/smd11" - -def service_call(call: List[str]) -> Union[bytes, None]: - try: - ret = subprocess.check_output(["service", "call", *call], encoding='utf8').strip() - if 'Parcel' not in ret: - return None - return parse_service_call_bytes(ret) - except subprocess.CalledProcessError: - return None - - -def parse_service_call_unpack(r, fmt) -> Union[bytes, None]: - try: - return struct.unpack(fmt, r)[0] - except Exception: - return None - - -def parse_service_call_string(r: bytes) -> Union[str, None]: - try: - r = r[8:] # Cut off length field - r_str = r.decode('utf_16_be') - - # All pairs of two characters seem to be swapped. Not sure why - result = "" - for a, b, in itertools.zip_longest(r_str[::2], r_str[1::2], fillvalue='\x00'): - result += b + a - - return result.replace('\x00', '') - except Exception: - return None - - -def parse_service_call_bytes(ret: str) -> Union[bytes, None]: - try: - r = b"" - for hex_part in re.findall(r'[ (]([0-9a-f]{8})', ret): - r += binascii.unhexlify(hex_part) - return r - except Exception: - return None - - -def getprop(key: str) -> Union[str, None]: - try: - return subprocess.check_output(["getprop", key], encoding='utf8').strip() - except subprocess.CalledProcessError: - return None - - -class Android(HardwareBase): - def get_os_version(self): - with open("/VERSION") as f: - return f.read().strip() - - def get_device_type(self): - try: - if int(Params().get("LastPeripheralPandaType")) == log.PandaState.PandaType.uno: - return "two" - except Exception: - pass - return "eon" - - def get_sound_card_online(self): - return (os.path.isfile('/proc/asound/card0/state') and - open('/proc/asound/card0/state').read().strip() == 'ONLINE') - - def get_imei(self, slot): - slot = str(slot) - if slot not in ("0", "1"): - raise ValueError("SIM slot must be 0 or 1") - - return parse_service_call_string(service_call(["iphonesubinfo", "3", "i32", str(slot)])) - - def get_serial(self): - ret = getprop("ro.serialno") - if len(ret) == 0: - ret = "cccccccc" - return ret - - def get_subscriber_info(self): - ret = parse_service_call_string(service_call(["iphonesubinfo", "7"])) - if ret is None or len(ret) < 8: - return "" - return ret - - def reboot(self, reason=None): - # e.g. reason="recovery" to go into recover mode - if reason is None: - reason_args = ["null"] - else: - reason_args = ["s16", reason] - - subprocess.check_output([ - "service", "call", "power", "16", # IPowerManager.reboot - "i32", "0", # no confirmation, - *reason_args, - "i32", "1" # wait - ]) - - def uninstall(self): - with open('/cache/recovery/command', 'w') as f: - f.write('--wipe_data\n') - # IPowerManager.reboot(confirm=false, reason="recovery", wait=true) - self.reboot(reason="recovery") - - def get_sim_info(self): - # Used for athena - # TODO: build using methods from this class - sim_state = getprop("gsm.sim.state").split(",") - network_type = getprop("gsm.network.type").split(',') - mcc_mnc = getprop("gsm.sim.operator.numeric") or None - - sim_id = parse_service_call_string(service_call(['iphonesubinfo', '11'])) - cell_data_state = parse_service_call_unpack(service_call(['phone', '46']), ">q") - cell_data_connected = (cell_data_state == 2) - - return { - 'sim_id': sim_id, - 'mcc_mnc': mcc_mnc, - 'network_type': network_type, - 'sim_state': sim_state, - 'data_connected': cell_data_connected - } - - def get_network_info(self): - msg = log.DeviceState.NetworkInfo.new_message() - msg.state = getprop("gsm.sim.state") or "" - msg.technology = getprop("gsm.network.type") or "" - msg.operator = getprop("gsm.sim.operator.numeric") or "" - - try: - modem = serial.Serial(MODEM_PATH, 115200, timeout=0.1) - modem.write(b"AT$QCRSRP?\r") - msg.extra = modem.read_until(b"OK\r\n").decode('utf-8') - - rsrp = msg.extra.split("$QCRSRP: ")[1].split("\r")[0].split(",") - msg.channel = int(rsrp[1]) - except Exception: - pass - - return msg - - def get_network_type(self): - wifi_check = parse_service_call_string(service_call(["connectivity", "2"])) - if wifi_check is None: - return NetworkType.none - elif 'WIFI' in wifi_check: - return NetworkType.wifi - else: - cell_check = parse_service_call_unpack(service_call(['phone', '59']), ">q") - # from TelephonyManager.java - cell_networks = { - 0: NetworkType.none, - 1: NetworkType.cell2G, - 2: NetworkType.cell2G, - 3: NetworkType.cell3G, - 4: NetworkType.cell2G, - 5: NetworkType.cell3G, - 6: NetworkType.cell3G, - 7: NetworkType.cell3G, - 8: NetworkType.cell3G, - 9: NetworkType.cell3G, - 10: NetworkType.cell3G, - 11: NetworkType.cell2G, - 12: NetworkType.cell3G, - 13: NetworkType.cell4G, - 14: NetworkType.cell4G, - 15: NetworkType.cell3G, - 16: NetworkType.cell2G, - 17: NetworkType.cell3G, - 18: NetworkType.cell4G, - 19: NetworkType.cell4G - } - return cell_networks.get(cell_check, NetworkType.none) - - def get_network_strength(self, network_type): - network_strength = NetworkStrength.unknown - - # from SignalStrength.java - def get_lte_level(rsrp, rssnr): - INT_MAX = 2147483647 - if rsrp == INT_MAX: - lvl_rsrp = NetworkStrength.unknown - elif rsrp >= -95: - lvl_rsrp = NetworkStrength.great - elif rsrp >= -105: - lvl_rsrp = NetworkStrength.good - elif rsrp >= -115: - lvl_rsrp = NetworkStrength.moderate - else: - lvl_rsrp = NetworkStrength.poor - if rssnr == INT_MAX: - lvl_rssnr = NetworkStrength.unknown - elif rssnr >= 45: - lvl_rssnr = NetworkStrength.great - elif rssnr >= 10: - lvl_rssnr = NetworkStrength.good - elif rssnr >= -30: - lvl_rssnr = NetworkStrength.moderate - else: - lvl_rssnr = NetworkStrength.poor - return max(lvl_rsrp, lvl_rssnr) - - def get_tdscdma_level(tdscmadbm): - lvl = NetworkStrength.unknown - if tdscmadbm > -25: - lvl = NetworkStrength.unknown - elif tdscmadbm >= -49: - lvl = NetworkStrength.great - elif tdscmadbm >= -73: - lvl = NetworkStrength.good - elif tdscmadbm >= -97: - lvl = NetworkStrength.moderate - elif tdscmadbm >= -110: - lvl = NetworkStrength.poor - return lvl - - def get_gsm_level(asu): - if asu <= 2 or asu == 99: - lvl = NetworkStrength.unknown - elif asu >= 12: - lvl = NetworkStrength.great - elif asu >= 8: - lvl = NetworkStrength.good - elif asu >= 5: - lvl = NetworkStrength.moderate - else: - lvl = NetworkStrength.poor - return lvl - - def get_evdo_level(evdodbm, evdosnr): - lvl_evdodbm = NetworkStrength.unknown - lvl_evdosnr = NetworkStrength.unknown - if evdodbm >= -65: - lvl_evdodbm = NetworkStrength.great - elif evdodbm >= -75: - lvl_evdodbm = NetworkStrength.good - elif evdodbm >= -90: - lvl_evdodbm = NetworkStrength.moderate - elif evdodbm >= -105: - lvl_evdodbm = NetworkStrength.poor - if evdosnr >= 7: - lvl_evdosnr = NetworkStrength.great - elif evdosnr >= 5: - lvl_evdosnr = NetworkStrength.good - elif evdosnr >= 3: - lvl_evdosnr = NetworkStrength.moderate - elif evdosnr >= 1: - lvl_evdosnr = NetworkStrength.poor - return max(lvl_evdodbm, lvl_evdosnr) - - def get_cdma_level(cdmadbm, cdmaecio): - lvl_cdmadbm = NetworkStrength.unknown - lvl_cdmaecio = NetworkStrength.unknown - if cdmadbm >= -75: - lvl_cdmadbm = NetworkStrength.great - elif cdmadbm >= -85: - lvl_cdmadbm = NetworkStrength.good - elif cdmadbm >= -95: - lvl_cdmadbm = NetworkStrength.moderate - elif cdmadbm >= -100: - lvl_cdmadbm = NetworkStrength.poor - if cdmaecio >= -90: - lvl_cdmaecio = NetworkStrength.great - elif cdmaecio >= -110: - lvl_cdmaecio = NetworkStrength.good - elif cdmaecio >= -130: - lvl_cdmaecio = NetworkStrength.moderate - elif cdmaecio >= -150: - lvl_cdmaecio = NetworkStrength.poor - return max(lvl_cdmadbm, lvl_cdmaecio) - - if network_type == NetworkType.none: - return network_strength - if network_type == NetworkType.wifi: - out = subprocess.check_output('dumpsys connectivity', shell=True).decode('utf-8') - network_strength = NetworkStrength.unknown - for line in out.split('\n'): - signal_str = "SignalStrength: " - if signal_str in line: - lvl_idx_start = line.find(signal_str) + len(signal_str) - lvl_idx_end = line.find(']', lvl_idx_start) - lvl = int(line[lvl_idx_start : lvl_idx_end]) - if lvl >= -50: - network_strength = NetworkStrength.great - elif lvl >= -60: - network_strength = NetworkStrength.good - elif lvl >= -70: - network_strength = NetworkStrength.moderate - else: - network_strength = NetworkStrength.poor - return network_strength - else: - # check cell strength - out = subprocess.check_output('dumpsys telephony.registry', shell=True).decode('utf-8') - for line in out.split('\n'): - if "mSignalStrength" in line: - arr = line.split(' ') - ns = 0 - if ("gsm" in arr[14]): - rsrp = int(arr[9]) - rssnr = int(arr[11]) - ns = get_lte_level(rsrp, rssnr) - if ns == NetworkStrength.unknown: - tdscmadbm = int(arr[13]) - ns = get_tdscdma_level(tdscmadbm) - if ns == NetworkStrength.unknown: - asu = int(arr[1]) - ns = get_gsm_level(asu) - else: - cdmadbm = int(arr[3]) - cdmaecio = int(arr[4]) - evdodbm = int(arr[5]) - evdosnr = int(arr[7]) - lvl_cdma = get_cdma_level(cdmadbm, cdmaecio) - lvl_edmo = get_evdo_level(evdodbm, evdosnr) - if lvl_edmo == NetworkStrength.unknown: - ns = lvl_cdma - elif lvl_cdma == NetworkStrength.unknown: - ns = lvl_edmo - else: - ns = min(lvl_cdma, lvl_edmo) - network_strength = max(network_strength, ns) - - return network_strength - - def get_battery_capacity(self): - return self.read_param_file("/sys/class/power_supply/battery/capacity", int, 100) - - def get_battery_status(self): - # This does not correspond with actual charging or not. - # If a USB cable is plugged in, it responds with 'Charging', even when charging is disabled - return self.read_param_file("/sys/class/power_supply/battery/status", lambda x: x.strip(), '') - - def get_battery_current(self): - return self.read_param_file("/sys/class/power_supply/battery/current_now", int) - - def get_battery_voltage(self): - return self.read_param_file("/sys/class/power_supply/battery/voltage_now", int) - - def get_battery_charging(self): - # This does correspond with actually charging - return self.read_param_file("/sys/class/power_supply/battery/charge_type", lambda x: x.strip() != "N/A", True) - - def set_battery_charging(self, on): - with open('/sys/class/power_supply/battery/charging_enabled', 'w') as f: - f.write(f"{1 if on else 0}\n") - - def get_usb_present(self): - return self.read_param_file("/sys/class/power_supply/usb/present", lambda x: bool(int(x)), False) - - def get_current_power_draw(self): - if self.get_battery_status() == 'Discharging': - # If the battery is discharging, we can use this measurement - # On C2: this is low by about 10-15%, probably mostly due to UNO draw not being factored in - return ((self.get_battery_voltage() / 1000000) * (self.get_battery_current() / 1000000)) - else: - # We don't have a good direct way to measure this if it's not "discharging" - return None - - def shutdown(self): - os.system('LD_LIBRARY_PATH="" svc power shutdown') - - def get_thermal_config(self): - # the thermal sensors on the 820 don't have meaningful names - return ThermalConfig(cpu=((5, 7, 10, 12), 10), gpu=((16,), 10), mem=(2, 10), - bat=("battery", 1000), ambient=("pa_therm0", 1), pmic=(("pm8994_tz",), 1000)) - - def set_screen_brightness(self, percentage): - with open("/sys/class/leds/lcd-backlight/brightness", "w") as f: - f.write(str(int(percentage * 2.55))) - - def get_screen_brightness(self): - try: - with open("/sys/class/leds/lcd-backlight/brightness") as f: - return int(float(f.read()) / 2.55) - except Exception: - return 0 - - def set_power_save(self, powersave_enabled): - pass - - def get_gpu_usage_percent(self): - try: - used, total = open('/sys/devices/soc/b00000.qcom,kgsl-3d0/kgsl/kgsl-3d0/gpubusy').read().strip().split() - perc = 100.0 * int(used) / int(total) - return min(max(perc, 0), 100) - except Exception: - return 0 - - def get_modem_temperatures(self): - # Not sure if we can get this on the LeEco - return [] - - def get_nvme_temperatures(self): - return [] - - def initialize_hardware(self): - pass - - def get_networks(self): - return None diff --git a/selfdrive/hardware/eon/neos.json b/selfdrive/hardware/eon/neos.json deleted file mode 100644 index 4010f7126a..0000000000 --- a/selfdrive/hardware/eon/neos.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ota_url": "https://commadist.azureedge.net/neosupdate/ota-signed-50da8800caa5cbc224acbaa21f3a83d21802a31d89cccfc62a898903a8eb19e7.zip", - "ota_hash": "50da8800caa5cbc224acbaa21f3a83d21802a31d89cccfc62a898903a8eb19e7", - "recovery_url": "https://commadist.azureedge.net/neosupdate/recovery-fe76739438d28ea6111853a737b616afdf340ba75c01c0ee99e6a28c19ecc29f.img", - "recovery_len": 15222060, - "recovery_hash": "fe76739438d28ea6111853a737b616afdf340ba75c01c0ee99e6a28c19ecc29f" -} diff --git a/selfdrive/hardware/eon/neos.py b/selfdrive/hardware/eon/neos.py deleted file mode 100755 index 6f290fbcd1..0000000000 --- a/selfdrive/hardware/eon/neos.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import hashlib -import json -import logging -import os -import requests - -NEOSUPDATE_DIR = "/data/neoupdate" - -RECOVERY_DEV = "/dev/block/bootdevice/by-name/recovery" -RECOVERY_COMMAND = "/cache/recovery/command" - - -def get_fn(url: str): - return os.path.join(NEOSUPDATE_DIR, os.path.basename(url)) - - -def download_file(url: str, fn: str, sha256: str, display_name: str, cloudlog=logging) -> None: - # check if already downloaded - if check_hash(fn, sha256): - cloudlog.info(f"{display_name} already cached") - return - - try: - with open(fn, "ab+") as f: - headers = {"Range": f"bytes={f.tell()}-"} - r = requests.get(url, stream=True, allow_redirects=True, headers=headers) - r.raise_for_status() - - total = int(r.headers['Content-Length']) - if 'Content-Range' in r.headers: - total = int(r.headers['Content-Range'].split('/')[-1]) - - for chunk in r.iter_content(chunk_size=1024 * 1024): - f.write(chunk) - print(f"Downloading {display_name}: {f.tell() / total * 100}", flush=True) - except Exception: - cloudlog.error("download error") - if os.path.isfile(fn): - os.unlink(fn) - raise - - if not check_hash(fn, sha256): - if os.path.isfile(fn): - os.unlink(fn) - raise Exception("downloaded update failed hash check") - - -def check_hash(fn: str, sha256: str, length: int = -1) -> bool: - if not os.path.exists(fn): - return False - - h = hashlib.sha256() - with open(fn, "rb") as f: - while f.tell() != length: - r = min(max(0, length - f.tell()), 1024 * 1024) if length > 0 else 1024 * 1024 - dat = f.read(r) - if not dat: - break - h.update(dat) - return h.hexdigest().lower() == sha256.lower() - - -def flash_update(update_fn: str, out_path: str) -> None: - with open(update_fn, "rb") as update, open(out_path, "w+b") as out: - while True: - dat = update.read(8192) - if len(dat) == 0: - break - out.write(dat) - - -def download_neos_update(manifest_path: str, cloudlog=logging) -> None: - with open(manifest_path) as f: - m = json.load(f) - - os.makedirs(NEOSUPDATE_DIR, exist_ok=True) - - # handle recovery updates - if not check_hash(RECOVERY_DEV, m['recovery_hash'], m['recovery_len']): - cloudlog.info("recovery needs update") - recovery_fn = os.path.join(NEOSUPDATE_DIR, os.path.basename(m['recovery_url'])) - download_file(m['recovery_url'], recovery_fn, m['recovery_hash'], "recovery", cloudlog) - - flash_update(recovery_fn, RECOVERY_DEV) - assert check_hash(RECOVERY_DEV, m['recovery_hash'], m['recovery_len']), "recovery flash corrupted" - cloudlog.info("recovery successfully flashed") - - # download OTA update - download_file(m['ota_url'], get_fn(m['ota_url']), m['ota_hash'], "system", cloudlog) - - -def verify_update_ready(manifest_path: str) -> bool: - with open(manifest_path) as f: - m = json.load(f) - - ota_downloaded = check_hash(get_fn(m['ota_url']), m['ota_hash']) - recovery_flashed = check_hash(RECOVERY_DEV, m['recovery_hash'], m['recovery_len']) - return ota_downloaded and recovery_flashed - - -def perform_ota_update(manifest_path: str) -> None: - with open(manifest_path) as f: - m = json.load(f) - - # reboot into recovery - ota_fn = get_fn(m['ota_url']) - with open(RECOVERY_COMMAND, "w") as rf: - rf.write(f"--update_package={ota_fn}\n") - os.system("service call power 16 i32 0 s16 recovery i32 1") - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="NEOS update utility", - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument("--swap", action="store_true", help="Peform update after downloading") - parser.add_argument("--swap-if-ready", action="store_true", help="Perform update if already downloaded") - parser.add_argument("manifest", help="Manifest json") - args = parser.parse_args() - - logging.basicConfig(level=logging.INFO) - - if args.swap_if_ready: - if verify_update_ready(args.manifest): - perform_ota_update(args.manifest) - else: - download_neos_update(args.manifest, logging) - if args.swap: - perform_ota_update(args.manifest) diff --git a/selfdrive/hardware/eon/shutdownd.py b/selfdrive/hardware/eon/shutdownd.py deleted file mode 100755 index 15112e7d5e..0000000000 --- a/selfdrive/hardware/eon/shutdownd.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -import os -import time -import datetime - -from common.params import Params -from selfdrive.hardware.eon.hardware import getprop -from selfdrive.swaglog import cloudlog - -def main(): - prev = b"" - params = Params() - while True: - with open("/dev/__properties__", 'rb') as f: - cur = f.read() - - if cur != prev: - prev = cur - - # 0 for shutdown, 1 for reboot - prop = getprop("sys.shutdown.requested") - if prop is not None and len(prop) > 0: - os.system("pkill -9 loggerd") - params.put("LastSystemShutdown", f"'{prop}' {datetime.datetime.now()}") - os.sync() - - time.sleep(120) - cloudlog.error('shutdown false positive') - break - - time.sleep(0.1) - -if __name__ == "__main__": - main() diff --git a/selfdrive/hardware/eon/test_neos_updater.py b/selfdrive/hardware/eon/test_neos_updater.py deleted file mode 100755 index e258f943d2..0000000000 --- a/selfdrive/hardware/eon/test_neos_updater.py +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env python3 -import hashlib -import http.server -import json -import os -import unittest -import random -import requests -import shutil -import socketserver -import tempfile -import multiprocessing -from pathlib import Path - -from selfdrive.hardware.eon.neos import RECOVERY_DEV, NEOSUPDATE_DIR, get_fn, download_file, \ - verify_update_ready, download_neos_update - -EON_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__))) -MANIFEST = os.path.join(EON_DIR, "neos.json") - -PORT = 8000 - -def server_thread(port): - socketserver.TCPServer.allow_reuse_address = True - httpd = socketserver.TCPServer(("", port), http.server.SimpleHTTPRequestHandler) - httpd.serve_forever() - - -class TestNeosUpdater(unittest.TestCase): - - @classmethod - def setUpClass(cls): - # generate a fake manifest - cls.manifest = {} - for i in ('ota', 'recovery'): - with tempfile.NamedTemporaryFile(delete=False, dir=os.getcwd()) as f: - dat = os.urandom(random.randint(1000, 100000)) - f.write(dat) - cls.manifest[f"{i}_url"] = f"http://localhost:{PORT}/" + os.path.relpath(f.name) - cls.manifest[F"{i}_hash"] = hashlib.sha256(dat).hexdigest() - if i == "recovery": - cls.manifest["recovery_len"] = len(dat) - - with tempfile.NamedTemporaryFile(delete=False, mode='w') as f: - f.write(json.dumps(cls.manifest)) - cls.fake_manifest = f.name - - @classmethod - def tearDownClass(cls): - os.unlink(cls.fake_manifest) - os.unlink(os.path.basename(cls.manifest['ota_url'])) - os.unlink(os.path.basename(cls.manifest['recovery_url'])) - - def setUp(self): - # server for update files - self.server = multiprocessing.Process(target=server_thread, args=(PORT, )) - self.server.start() - - # clean up - if os.path.exists(NEOSUPDATE_DIR): - shutil.rmtree(NEOSUPDATE_DIR) - - def tearDown(self): - self.server.kill() - self.server.join(1) - - def _corrupt_recovery(self): - with open(RECOVERY_DEV, "wb") as f: - f.write(b'\x00'*100) - - def test_manifest(self): - with open(MANIFEST) as f: - m = json.load(f) - - assert m['ota_hash'] in m['ota_url'] - assert m['recovery_hash'] in m['recovery_url'] - assert m['recovery_len'] > 0 - - for url in (m['ota_url'], m['recovery_url']): - r = requests.head(m['recovery_url']) - r.raise_for_status() - self.assertEqual(r.headers['Content-Type'], "application/octet-stream") - if url == m['recovery_url']: - self.assertEqual(int(r.headers['Content-Length']), m['recovery_len']) - - def test_download_hash_check(self): - os.makedirs(NEOSUPDATE_DIR, exist_ok=True) - Path(get_fn(self.manifest['ota_url'])).touch() - with self.assertRaisesRegex(Exception, "failed hash check"): - download_file(self.manifest['ota_url'], get_fn(self.manifest['ota_url']), - self.manifest['ota_hash']+'a', "system") - - # should've unlinked after the failed hash check, should succeed now - download_file(self.manifest['ota_url'], get_fn(self.manifest['ota_url']), - self.manifest['ota_hash'], "system") - - # TODO: needs an http server that supports Content-Range - #def test_download_resume(self): - # os.makedirs(NEOSUPDATE_DIR, exist_ok=True) - # with open(os.path.basename(self.manifest['ota_url']), "rb") as src, \ - # open(get_fn(self.manifest['ota_url']), "wb") as dest: - # l = dest.write(src.read(8192)) - # assert l == 8192 - # download_file(self.manifest['ota_url'], get_fn(self.manifest['ota_url']), - # self.manifest['ota_hash'], "system") - - def test_download_no_internet(self): - self.server.kill() - os.makedirs(NEOSUPDATE_DIR, exist_ok=True) - # fail, no internet - with self.assertRaises(requests.exceptions.ConnectionError): - download_file(self.manifest['ota_url'], get_fn(self.manifest['ota_url']), - self.manifest['ota_hash'], "system") - - # already cached, ensure we don't hit the server - shutil.copyfile(os.path.basename(self.manifest['ota_url']), get_fn(self.manifest['ota_url'])) - download_file(self.manifest['ota_url'], get_fn(self.manifest['ota_url']), - self.manifest['ota_hash'], "system") - - - def test_download_update(self): - download_neos_update(self.fake_manifest) - self.assertTrue(verify_update_ready(self.fake_manifest)) - - def test_verify_update(self): - # good state - download_neos_update(self.fake_manifest) - self.assertTrue(verify_update_ready(self.fake_manifest)) - - # corrupt recovery - self._corrupt_recovery() - self.assertFalse(verify_update_ready(self.fake_manifest)) - - # back to good state - download_neos_update(self.fake_manifest) - self.assertTrue(verify_update_ready(self.fake_manifest)) - - # corrupt ota - self._corrupt_recovery() - with open(os.path.join(NEOSUPDATE_DIR, os.path.basename(self.manifest['ota_url'])), "ab") as f: - f.write(b'\x00') - self.assertFalse(verify_update_ready(self.fake_manifest)) - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/hardware/eon/update_neos.sh b/selfdrive/hardware/eon/update_neos.sh deleted file mode 100755 index ccc6ecce44..0000000000 --- a/selfdrive/hardware/eon/update_neos.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/bash - -ROOT=$PWD/../../.. -$ROOT/installer/updater/updater "file://$ROOT/installer/updater/update.json" diff --git a/selfdrive/hardware/eon/updater b/selfdrive/hardware/eon/updater deleted file mode 100755 index d1f0f47ae4..0000000000 --- a/selfdrive/hardware/eon/updater +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:93fa3a75fe891d75c3adc515c65dcd899ace6063e16eaf417d202b6befaba3d1 -size 3193008 diff --git a/selfdrive/hardware/hw.h b/selfdrive/hardware/hw.h index f18ede01ec..b221b63db2 100644 --- a/selfdrive/hardware/hw.h +++ b/selfdrive/hardware/hw.h @@ -3,10 +3,7 @@ #include "selfdrive/hardware/base.h" #include "selfdrive/common/util.h" -#ifdef QCOM -#include "selfdrive/hardware/eon/hardware.h" -#define Hardware HardwareEon -#elif QCOM2 +#if QCOM2 #include "selfdrive/hardware/tici/hardware.h" #define Hardware HardwareTici #else diff --git a/selfdrive/logcatd/SConscript b/selfdrive/logcatd/SConscript index 8811f32fe6..6bd7c6ff3e 100644 --- a/selfdrive/logcatd/SConscript +++ b/selfdrive/logcatd/SConscript @@ -1,6 +1,3 @@ -Import('env', 'cereal', 'messaging', 'common', 'arch') +Import('env', 'cereal', 'messaging', 'common') -if arch == "aarch64": - env.Program('logcatd', 'logcatd_android.cc', LIBS=[cereal, messaging, common, 'cutils', 'zmq', 'capnp', 'kj']) -else: - env.Program('logcatd', 'logcatd_systemd.cc', LIBS=[cereal, messaging, common, 'zmq', 'capnp', 'kj', 'systemd', 'json11']) +env.Program('logcatd', 'logcatd_systemd.cc', LIBS=[cereal, messaging, common, 'zmq', 'capnp', 'kj', 'systemd', 'json11']) diff --git a/selfdrive/logcatd/logcatd_android.cc b/selfdrive/logcatd/logcatd_android.cc deleted file mode 100644 index 8c2524d94a..0000000000 --- a/selfdrive/logcatd/logcatd_android.cc +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#include - -#include - -#include "cereal/messaging/messaging.h" - -#undef LOG_ID_KERNEL -#define LOG_ID_KERNEL 5 - -int main() { - std::signal(SIGINT, exit); - std::signal(SIGTERM, exit); - setpriority(PRIO_PROCESS, 0, -15); - - // setup android logging - logger_list *logger_list = android_logger_list_alloc(ANDROID_LOG_RDONLY, 0, 0); - assert(logger_list); - for (auto log_id : {LOG_ID_MAIN, LOG_ID_RADIO, LOG_ID_SYSTEM, LOG_ID_CRASH, (log_id_t)LOG_ID_KERNEL}) { - logger *logger = android_logger_open(logger_list, log_id); - assert(logger); - } - - PubMaster pm({"androidLog"}); - - while (true) { - log_msg log_msg; - int err = android_logger_list_read(logger_list, &log_msg); - if (err <= 0) break; - - AndroidLogEntry entry; - err = android_log_processLogBuffer(&log_msg.entry_v1, &entry); - if (err < 0) continue; - - MessageBuilder msg; - auto androidEntry = msg.initEvent().initAndroidLog(); - androidEntry.setId(log_msg.id()); - androidEntry.setTs(entry.tv_sec * NS_PER_SEC + entry.tv_nsec); - androidEntry.setPriority(entry.priority); - androidEntry.setPid(entry.pid); - androidEntry.setTid(entry.tid); - androidEntry.setTag(entry.tag); - androidEntry.setMessage(entry.message); - pm.send("androidLog", msg); - } - - android_logger_list_free(logger_list); - return 0; -} diff --git a/selfdrive/logcatd/tests/test_logcatd_android.py b/selfdrive/logcatd/tests/test_logcatd_android.py deleted file mode 100755 index 4e0c903dfa..0000000000 --- a/selfdrive/logcatd/tests/test_logcatd_android.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python3 -import os -import random -import string -import time -import unittest -import uuid - -import cereal.messaging as messaging -from selfdrive.test.helpers import with_processes - -class TestLogcatdAndroid(unittest.TestCase): - - @with_processes(['logcatd']) - def test_log(self): - sock = messaging.sub_sock("androidLog", conflate=False) - - # make sure sockets are ready - time.sleep(1) - messaging.drain_sock(sock) - - sent_msgs = {} - for _ in range(random.randint(2, 10)): - # write some log messages - for __ in range(random.randint(5, 50)): - tag = uuid.uuid4().hex - msg = ''.join(random.choice(string.ascii_letters) for _ in range(random.randrange(2, 50))) - sent_msgs[tag] = {'recv_cnt': 0, 'msg': msg} - os.system(f"log -t '{tag}' '{msg}'") - - time.sleep(1) - msgs = messaging.drain_sock(sock) - for m in msgs: - self.assertTrue(m.valid) - self.assertLess(time.monotonic() - (m.logMonoTime / 1e9), 30) - tag = m.androidLog.tag - if tag in sent_msgs: - sent_msgs[tag]['recv_cnt'] += 1 - self.assertEqual(m.androidLog.message.strip(), sent_msgs[tag]['msg']) - - for v in sent_msgs.values(): - self.assertEqual(v['recv_cnt'], 1) - -if __name__ == "__main__": - unittest.main() diff --git a/selfdrive/loggerd/SConscript b/selfdrive/loggerd/SConscript index 76fbcae6c4..001f0b0408 100644 --- a/selfdrive/loggerd/SConscript +++ b/selfdrive/loggerd/SConscript @@ -4,19 +4,14 @@ Import('env', 'arch', 'cereal', 'messaging', 'common', 'visionipc', 'gpucommon') libs = [common, cereal, messaging, visionipc, 'zmq', 'capnp', 'kj', 'z', 'avformat', 'avcodec', 'swscale', 'avutil', - 'yuv', 'bz2', 'OpenCL'] + 'yuv', 'bz2', 'OpenCL', 'pthread'] src = ['logger.cc', 'loggerd.cc'] -if arch in ["aarch64", "larch64"]: +if arch == "larch64": src += ['omx_encoder.cc'] libs += ['OmxCore', 'gsl', 'CB'] + gpucommon - if arch == "aarch64": - libs += ['OmxVenc', 'cutils'] - else: - libs += ['pthread'] else: src += ['raw_logger.cc'] - libs += ['pthread'] if arch == "Darwin": # fix OpenCL diff --git a/selfdrive/loggerd/bootlog.cc b/selfdrive/loggerd/bootlog.cc index a723124847..e7ce308cec 100644 --- a/selfdrive/loggerd/bootlog.cc +++ b/selfdrive/loggerd/bootlog.cc @@ -11,8 +11,6 @@ static kj::Array build_boot_log() { if (Hardware::TICI()) { bootlog_commands.push_back("journalctl"); bootlog_commands.push_back("sudo nvme smart-log --output-format=json /dev/nvme0"); - } else if (Hardware::EON()) { - bootlog_commands.push_back("logcat -d"); } MessageBuilder msg; diff --git a/selfdrive/loggerd/logger.cc b/selfdrive/loggerd/logger.cc index 6ba520d162..f2c34554e3 100644 --- a/selfdrive/loggerd/logger.cc +++ b/selfdrive/loggerd/logger.cc @@ -14,9 +14,6 @@ #include #include #include -#ifdef QCOM -#include -#endif #include "selfdrive/common/params.h" #include "selfdrive/common/swaglog.h" @@ -36,9 +33,7 @@ kj::Array logger_build_init_data() { MessageBuilder msg; auto init = msg.initEvent().initInitData(); - if (Hardware::EON()) { - init.setDeviceType(cereal::InitData::DeviceType::NEO); - } else if (Hardware::TICI()) { + if (Hardware::TICI()) { init.setDeviceType(cereal::InitData::DeviceType::TICI); } else { init.setDeviceType(cereal::InitData::DeviceType::PC); @@ -61,20 +56,6 @@ kj::Array logger_build_init_data() { init.setKernelVersion(util::read_file("/proc/version")); init.setOsVersion(util::read_file("/VERSION")); -#ifdef QCOM - { - std::vector > properties; - property_list(append_property, (void*)&properties); - - auto lentries = init.initAndroidProperties().initEntries(properties.size()); - for (int i=0; i int main(int argc, char** argv) { - if (Hardware::EON()) { - setpriority(PRIO_PROCESS, 0, -20); - } else if (Hardware::TICI()) { + if (Hardware::TICI()) { int ret; ret = util::set_core_affinity({0, 1, 2, 3}); assert(ret == 0); diff --git a/selfdrive/loggerd/tests/test_encoder.py b/selfdrive/loggerd/tests/test_encoder.py index 97c142652f..9479b6256a 100755 --- a/selfdrive/loggerd/tests/test_encoder.py +++ b/selfdrive/loggerd/tests/test_encoder.py @@ -13,27 +13,19 @@ from tqdm import trange from common.params import Params from common.timeout import Timeout -from selfdrive.hardware import EON, TICI +from selfdrive.hardware import TICI from selfdrive.loggerd.config import ROOT from selfdrive.manager.process_config import managed_processes from tools.lib.logreader import LogReader SEGMENT_LENGTH = 2 -if EON: - FULL_SIZE = 1253786 # file size for a 2s segment in bytes - CAMERAS = [ - ("fcamera.hevc", 20, FULL_SIZE, "roadEncodeIdx"), - ("dcamera.hevc", 10, 770920, "driverEncodeIdx"), - ("qcamera.ts", 20, 77066, None), - ] -else: - FULL_SIZE = 2507572 - CAMERAS = [ - ("fcamera.hevc", 20, FULL_SIZE, "roadEncodeIdx"), - ("dcamera.hevc", 20, FULL_SIZE, "driverEncodeIdx"), - ("ecamera.hevc", 20, FULL_SIZE, "wideRoadEncodeIdx"), - ("qcamera.ts", 20, 77066, None), - ] +FULL_SIZE = 2507572 +CAMERAS = [ + ("fcamera.hevc", 20, FULL_SIZE, "roadEncodeIdx"), + ("dcamera.hevc", 20, FULL_SIZE, "driverEncodeIdx"), + ("ecamera.hevc", 20, FULL_SIZE, "wideRoadEncodeIdx"), + ("qcamera.ts", 20, 77066, None), +] # we check frame count, so we don't have to be too strict on size FILE_SIZE_TOLERANCE = 0.5 @@ -44,7 +36,7 @@ class TestEncoder(unittest.TestCase): # TODO: all of loggerd should work on PC @classmethod def setUpClass(cls): - if not (EON or TICI): + if not TICI: raise unittest.SkipTest def setUp(self): @@ -93,8 +85,6 @@ class TestEncoder(unittest.TestCase): if not record_front and "dcamera" in camera: continue - eon_dcam = EON and (camera == 'dcamera.hevc') - file_path = f"{route_prefix_path}--{i}/{camera}" # check file exists @@ -107,7 +97,7 @@ class TestEncoder(unittest.TestCase): cmd = "LD_LIBRARY_PATH=/usr/local/lib " + cmd expected_frames = fps * SEGMENT_LENGTH - frame_tolerance = 1 if eon_dcam else 0 + frame_tolerance = 0 probe = subprocess.check_output(cmd, shell=True, encoding='utf8') frame_count = int(probe.split('\n')[0].strip()) counts.append(frame_count) @@ -140,9 +130,8 @@ class TestEncoder(unittest.TestCase): self.assertTrue(all(valid)) - if not eon_dcam: - self.assertEqual(expected_frames * i, encode_idxs[0]) - first_frames.append(frame_idxs[0]) + self.assertEqual(expected_frames * i, encode_idxs[0]) + first_frames.append(frame_idxs[0]) self.assertEqual(len(set(encode_idxs)), len(encode_idxs)) self.assertEqual(1, len(set(first_frames))) diff --git a/selfdrive/manager/process_config.py b/selfdrive/manager/process_config.py index da4284571f..63790058fe 100644 --- a/selfdrive/manager/process_config.py +++ b/selfdrive/manager/process_config.py @@ -1,6 +1,6 @@ import os -from selfdrive.hardware import EON, TICI, PC +from selfdrive.hardware import TICI, PC from selfdrive.manager.process import PythonProcess, NativeProcess, DaemonProcess WEBCAM = os.getenv("USE_WEBCAM") is not None @@ -16,7 +16,7 @@ procs = [ NativeProcess("modeld", "selfdrive/modeld", ["./modeld"]), NativeProcess("navd", "selfdrive/ui/navd", ["./navd"], enabled=(PC or TICI), persistent=True), NativeProcess("proclogd", "selfdrive/proclogd", ["./proclogd"]), - NativeProcess("sensord", "selfdrive/sensord", ["./sensord"], enabled=not PC, persistent=EON, sigkill=EON), + NativeProcess("sensord", "selfdrive/sensord", ["./sensord"], enabled=not PC), NativeProcess("ubloxd", "selfdrive/locationd", ["./ubloxd"], enabled=(not PC or WEBCAM)), NativeProcess("ui", "selfdrive/ui", ["./ui"], persistent=True, watchdog_max_dt=(5 if TICI else None)), NativeProcess("soundd", "selfdrive/ui/soundd", ["./soundd"], persistent=True), @@ -38,11 +38,6 @@ procs = [ PythonProcess("uploader", "selfdrive.loggerd.uploader", persistent=True), PythonProcess("statsd", "selfdrive.statsd", persistent=True), - # EON only - PythonProcess("rtshield", "selfdrive.rtshield", enabled=EON), - PythonProcess("shutdownd", "selfdrive.hardware.eon.shutdownd", enabled=EON), - PythonProcess("androidd", "selfdrive.hardware.eon.androidd", enabled=EON, persistent=True), - # Experimental PythonProcess("rawgpsd", "selfdrive.sensord.rawgps.rawgpsd", enabled=os.path.isfile("/persist/comma/use-quectel-rawgps")), ] diff --git a/selfdrive/manager/test/test_manager.py b/selfdrive/manager/test/test_manager.py index d16a145031..1750c81b2e 100755 --- a/selfdrive/manager/test/test_manager.py +++ b/selfdrive/manager/test/test_manager.py @@ -5,14 +5,14 @@ import time import unittest import selfdrive.manager.manager as manager -from selfdrive.hardware import EON, TICI, HARDWARE +from selfdrive.hardware import TICI, HARDWARE from selfdrive.manager.process import DaemonProcess from selfdrive.manager.process_config import managed_processes os.environ['FAKEUPLOAD'] = "1" # TODO: make eon fast -MAX_STARTUP_TIME = 30 if EON else 15 +MAX_STARTUP_TIME = 15 ALL_PROCESSES = [p.name for p in managed_processes.values() if (type(p) is not DaemonProcess) and p.enabled and (p.name not in ['updated', 'pandad'])] @@ -50,7 +50,7 @@ class TestManager(unittest.TestCase): self.assertTrue(state.running, f"{p} not running") exit_code = managed_processes[p].stop(retry=False) - if (TICI and p in ['ui', 'navd']) or (EON and p == 'logcatd'): + if (TICI and p in ['ui', 'navd']): # TODO: make Qt UI exit gracefully continue diff --git a/selfdrive/modeld/SConscript b/selfdrive/modeld/SConscript index 20d3fb8acc..77d5787367 100644 --- a/selfdrive/modeld/SConscript +++ b/selfdrive/modeld/SConscript @@ -31,9 +31,8 @@ thneed_src = [ use_thneed = not GetOption('no_thneed') -if arch == "aarch64" or arch == "larch64": - libs += ['gsl', 'CB'] - libs += ['gnustl_shared'] if arch == "aarch64" else ['pthread', 'dl'] +if arch == "larch64": + libs += ['gsl', 'CB', 'pthread', 'dl'] if use_thneed: common_src += thneed_src @@ -64,7 +63,7 @@ else: common_model = lenv.Object(common_src) # build thneed model -if use_thneed and arch in ("aarch64", "larch64"): +if use_thneed and arch == "larch64": fn = File("#models/supercombo").abspath compiler = lenv.Program('thneed/compile', ["thneed/compile.cc"]+common_model, LIBS=libs) cmd = f"cd {Dir('.').abspath} && {compiler[0].abspath} {fn}.dlc {fn}_badweights.thneed --binary" diff --git a/selfdrive/modeld/dmonitoringmodeld b/selfdrive/modeld/dmonitoringmodeld index 9acd7bcc33..f292fe4c0b 100755 --- a/selfdrive/modeld/dmonitoringmodeld +++ b/selfdrive/modeld/dmonitoringmodeld @@ -3,15 +3,10 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd $DIR -if [ -d /system ]; then - if [ -f /TICI ]; then # QCOM2 - export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:/data/pythonpath/third_party/snpe/larch64:$LD_LIBRARY_PATH" - else # QCOM - export LD_LIBRARY_PATH="/data/pythonpath/third_party/snpe/aarch64/:$LD_LIBRARY_PATH" - fi +if [ -f /TICI ]; then + export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:/data/pythonpath/third_party/snpe/larch64:$LD_LIBRARY_PATH" export ADSP_LIBRARY_PATH="/data/pythonpath/third_party/snpe/dsp/" else - # PC export LD_LIBRARY_PATH="$DIR/../../third_party/snpe/x86_64-linux-clang:$DIR/../../openpilot/third_party/snpe/x86_64:$LD_LIBRARY_PATH" fi exec ./_dmonitoringmodeld diff --git a/selfdrive/modeld/modeld b/selfdrive/modeld/modeld index fcf2812cb7..c067cf3d62 100755 --- a/selfdrive/modeld/modeld +++ b/selfdrive/modeld/modeld @@ -3,14 +3,9 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd $DIR -if [ -d /system ]; then - if [ -f /TICI ]; then # QCOM2 - export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:/data/pythonpath/third_party/snpe/larch64:$LD_LIBRARY_PATH" - else # QCOM - export LD_LIBRARY_PATH="/data/pythonpath/third_party/snpe/aarch64/:$LD_LIBRARY_PATH" - fi +if [ -f /TICI ]; then + export LD_LIBRARY_PATH="/usr/lib/aarch64-linux-gnu:/data/pythonpath/third_party/snpe/larch64:$LD_LIBRARY_PATH" else - # PC export LD_LIBRARY_PATH="$DIR/../../third_party/snpe/x86_64-linux-clang:$DIR/../../openpilot/third_party/snpe/x86_64:$LD_LIBRARY_PATH" fi exec ./_modeld diff --git a/selfdrive/modeld/modeld.cc b/selfdrive/modeld/modeld.cc index 2714370106..dd0bafff31 100644 --- a/selfdrive/modeld/modeld.cc +++ b/selfdrive/modeld/modeld.cc @@ -160,11 +160,11 @@ void run_model(ModelState &model, VisionIpcClient &vipc_client_main, VisionIpcCl } int main(int argc, char **argv) { - if (!Hardware::PC()) { + if (Hardware::TICI()) { int ret; ret = util::set_realtime_priority(54); assert(ret == 0); - util::set_core_affinity({Hardware::EON() ? 2 : 7}); + util::set_core_affinity({7}); assert(ret == 0); } diff --git a/selfdrive/modeld/runners/snpemodel.cc b/selfdrive/modeld/runners/snpemodel.cc index 0d394ca511..44fa6ce298 100644 --- a/selfdrive/modeld/runners/snpemodel.cc +++ b/selfdrive/modeld/runners/snpemodel.cc @@ -18,7 +18,7 @@ SNPEModel::SNPEModel(const char *path, float *loutput, size_t loutput_size, int output = loutput; output_size = loutput_size; use_extra = luse_extra; -#if defined(QCOM) || defined(QCOM2) +#ifdef QCOM2 if (runtime==USE_GPU_RUNTIME) { Runtime = zdl::DlSystem::Runtime_t::GPU; } else if (runtime==USE_DSP_RUNTIME) { @@ -39,7 +39,7 @@ SNPEModel::SNPEModel(const char *path, float *loutput, size_t loutput_size, int // create model runner zdl::SNPE::SNPEBuilder snpeBuilder(container.get()); while (!snpe) { -#if defined(QCOM) || defined(QCOM2) +#ifdef QCOM2 snpe = snpeBuilder.setOutputLayers({}) .setRuntimeProcessor(Runtime) .setUseUserSuppliedBuffers(true) diff --git a/selfdrive/modeld/runners/snpemodel.h b/selfdrive/modeld/runners/snpemodel.h index 584c636802..6e9c33f89c 100644 --- a/selfdrive/modeld/runners/snpemodel.h +++ b/selfdrive/modeld/runners/snpemodel.h @@ -38,7 +38,7 @@ public: private: std::string model_data; -#if defined(QCOM) || defined(QCOM2) +#ifdef QCOM2 zdl::DlSystem::Runtime_t Runtime; #endif diff --git a/selfdrive/modeld/thneed/thneed.cc b/selfdrive/modeld/thneed/thneed.cc index e2dc9b72f2..470ff219b0 100644 --- a/selfdrive/modeld/thneed/thneed.cc +++ b/selfdrive/modeld/thneed/thneed.cc @@ -433,7 +433,7 @@ cl_program thneed_clCreateProgramWithSource(cl_context context, cl_uint count, c } void *dlsym(void *handle, const char *symbol) { -#if defined(QCOM) || defined(QCOM2) +#ifdef QCOM2 void *(*my_dlsym)(void *handle, const char *symbol) = (void *(*)(void *handle, const char *symbol))((uintptr_t)dlopen + DLSYM_OFFSET); #else #error "Unsupported platform for thneed" diff --git a/selfdrive/sensord/SConscript b/selfdrive/sensord/SConscript index 186e302bc3..db32887e7f 100644 --- a/selfdrive/sensord/SConscript +++ b/selfdrive/sensord/SConscript @@ -1,22 +1,19 @@ Import('env', 'arch', 'common', 'cereal', 'messaging') -if arch == "aarch64": - env.Program('_sensord', 'sensors_qcom.cc', LIBS=['hardware', common, cereal, messaging, 'capnp', 'zmq', 'kj']) -else: - sensors = [ - 'sensors/file_sensor.cc', - 'sensors/i2c_sensor.cc', - 'sensors/light_sensor.cc', - 'sensors/bmx055_accel.cc', - 'sensors/bmx055_gyro.cc', - 'sensors/bmx055_magn.cc', - 'sensors/bmx055_temp.cc', - 'sensors/lsm6ds3_accel.cc', - 'sensors/lsm6ds3_gyro.cc', - 'sensors/lsm6ds3_temp.cc', - 'sensors/mmc5603nj_magn.cc', - ] - libs = [common, cereal, messaging, 'capnp', 'zmq', 'kj'] - if arch == "larch64": - libs.append('i2c') - env.Program('_sensord', ['sensors_qcom2.cc'] + sensors, LIBS=libs) +sensors = [ + 'sensors/file_sensor.cc', + 'sensors/i2c_sensor.cc', + 'sensors/light_sensor.cc', + 'sensors/bmx055_accel.cc', + 'sensors/bmx055_gyro.cc', + 'sensors/bmx055_magn.cc', + 'sensors/bmx055_temp.cc', + 'sensors/lsm6ds3_accel.cc', + 'sensors/lsm6ds3_gyro.cc', + 'sensors/lsm6ds3_temp.cc', + 'sensors/mmc5603nj_magn.cc', +] +libs = [common, cereal, messaging, 'capnp', 'zmq', 'kj'] +if arch == "larch64": + libs.append('i2c') +env.Program('_sensord', ['sensors_qcom2.cc'] + sensors, LIBS=libs) diff --git a/selfdrive/sensord/sensors_qcom.cc b/selfdrive/sensord/sensors_qcom.cc deleted file mode 100644 index fcdb9a72d7..0000000000 --- a/selfdrive/sensord/sensors_qcom.cc +++ /dev/null @@ -1,228 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "cereal/messaging/messaging.h" -#include "selfdrive/common/swaglog.h" -#include "selfdrive/common/timing.h" -#include "selfdrive/common/util.h" - -// ACCELEROMETER_UNCALIBRATED is only in Android O -// https://developer.android.com/reference/android/hardware/Sensor.html#STRING_TYPE_ACCELEROMETER_UNCALIBRATED - -#define SENSOR_ACCELEROMETER 1 -#define SENSOR_MAGNETOMETER 2 -#define SENSOR_GYRO 4 -#define SENSOR_MAGNETOMETER_UNCALIBRATED 3 -#define SENSOR_GYRO_UNCALIBRATED 5 -#define SENSOR_PROXIMITY 6 -#define SENSOR_LIGHT 7 - -ExitHandler do_exit; -volatile sig_atomic_t re_init_sensors = 0; - -namespace { - -void sigpipe_handler(int sig) { - LOGE("SIGPIPE received"); - re_init_sensors = true; -} - -void sensor_loop() { - LOG("*** sensor loop"); - - uint64_t frame = 0; - bool low_power_mode = false; - - while (!do_exit) { - SubMaster sm({"deviceState"}); - PubMaster pm({"sensorEvents"}); - - struct sensors_poll_device_t* device; - struct sensors_module_t* module; - - hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); - sensors_open(&module->common, &device); - - // required - struct sensor_t const* list; - int count = module->get_sensors_list(module, &list); - LOG("%d sensors found", count); - - if (getenv("SENSOR_TEST")) { - exit(count); - } - - for (int i = 0; i < count; i++) { - LOGD("sensor %4d: %4d %60s %d-%ld us", i, list[i].handle, list[i].name, list[i].minDelay, list[i].maxDelay); - } - - std::set sensor_types = { - SENSOR_TYPE_ACCELEROMETER, - SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED, - SENSOR_TYPE_MAGNETIC_FIELD, - SENSOR_TYPE_GYROSCOPE_UNCALIBRATED, - SENSOR_TYPE_GYROSCOPE, - SENSOR_TYPE_PROXIMITY, - SENSOR_TYPE_LIGHT, - }; - - std::map sensors = { - {SENSOR_GYRO_UNCALIBRATED, ms2ns(10)}, - {SENSOR_MAGNETOMETER_UNCALIBRATED, ms2ns(100)}, - {SENSOR_ACCELEROMETER, ms2ns(10)}, - {SENSOR_GYRO, ms2ns(10)}, - {SENSOR_MAGNETOMETER, ms2ns(100)}, - {SENSOR_PROXIMITY, ms2ns(100)}, - {SENSOR_LIGHT, ms2ns(100)} - }; - - // sensors needed while offroad - std::set offroad_sensors = { - SENSOR_LIGHT, - SENSOR_ACCELEROMETER, - SENSOR_GYRO_UNCALIBRATED, - }; - - // init all the sensors - for (auto &s : sensors) { - device->activate(device, s.first, 0); - device->activate(device, s.first, 1); - device->setDelay(device, s.first, s.second); - } - - // TODO: why is this 16? - static const size_t numEvents = 16; - sensors_event_t buffer[numEvents]; - - while (!do_exit) { - int n = device->poll(device, buffer, numEvents); - if (n == 0) continue; - if (n < 0) { - LOG("sensor_loop poll failed: %d", n); - continue; - } - - int log_events = 0; - for (int i=0; i < n; i++) { - if (sensor_types.find(buffer[i].type) != sensor_types.end()) { - log_events++; - } - } - - MessageBuilder msg; - auto sensor_events = msg.initEvent().initSensorEvents(log_events); - - int log_i = 0; - for (int i = 0; i < n; i++) { - - const sensors_event_t& data = buffer[i]; - - if (sensor_types.find(data.type) == sensor_types.end()) { - continue; - } - - auto log_event = sensor_events[log_i]; - log_event.setSource(cereal::SensorEventData::SensorSource::ANDROID); - log_event.setVersion(data.version); - log_event.setSensor(data.sensor); - log_event.setType(data.type); - log_event.setTimestamp(data.timestamp); - - switch (data.type) { - case SENSOR_TYPE_ACCELEROMETER: { - auto svec = log_event.initAcceleration(); - svec.setV(data.acceleration.v); - svec.setStatus(data.acceleration.status); - break; - } - case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: { - auto svec = log_event.initMagneticUncalibrated(); - // assuming the uncalib and bias floats are contiguous in memory - kj::ArrayPtr vs(&data.uncalibrated_magnetic.uncalib[0], 6); - svec.setV(vs); - break; - } - case SENSOR_TYPE_MAGNETIC_FIELD: { - auto svec = log_event.initMagnetic(); - svec.setV(data.magnetic.v); - svec.setStatus(data.magnetic.status); - break; - } - case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: { - auto svec = log_event.initGyroUncalibrated(); - // assuming the uncalib and bias floats are contiguous in memory - kj::ArrayPtr vs(&data.uncalibrated_gyro.uncalib[0], 6); - svec.setV(vs); - break; - } - case SENSOR_TYPE_GYROSCOPE: { - auto svec = log_event.initGyro(); - svec.setV(data.gyro.v); - svec.setStatus(data.gyro.status); - break; - } - case SENSOR_TYPE_PROXIMITY: { - log_event.setProximity(data.distance); - break; - } - case SENSOR_TYPE_LIGHT: - log_event.setLight(data.light); - break; - } - - log_i++; - } - - pm.send("sensorEvents", msg); - - if (re_init_sensors) { - LOGE("Resetting sensors"); - re_init_sensors = false; - break; - } - - // Check whether to go into low power mode at 5Hz - if (frame % 20 == 0) { - sm.update(0); - bool offroad = !sm["deviceState"].getDeviceState().getStarted(); - if (low_power_mode != offroad) { - for (auto &s : sensors) { - device->activate(device, s.first, 0); - if (!offroad || offroad_sensors.find(s.first) != offroad_sensors.end()) { - device->activate(device, s.first, 1); - } - } - low_power_mode = offroad; - } - } - - frame++; - } - sensors_close(device); - } -} - -}// Namespace end - -int main(int argc, char *argv[]) { - setpriority(PRIO_PROCESS, 0, -18); - signal(SIGPIPE, (sighandler_t)sigpipe_handler); - - sensor_loop(); - - return 0; -} diff --git a/selfdrive/test/process_replay/model_replay.py b/selfdrive/test/process_replay/model_replay.py index 0028371e81..1befb69aa4 100755 --- a/selfdrive/test/process_replay/model_replay.py +++ b/selfdrive/test/process_replay/model_replay.py @@ -21,13 +21,8 @@ from selfdrive.version import get_commit from tools.lib.framereader import FrameReader from tools.lib.logreader import LogReader -TICI_TEST_ROUTE = "4cf7a6ad03080c90|2021-09-29--13-46-36" -EON_TEST_ROUTE = "303055c0002aefd1|2021-11-22--18-36-32" +TEST_ROUTE = "4cf7a6ad03080c90|2021-09-29--13-46-36" SEGMENT = 0 -if TICI: - TEST_ROUTE = TICI_TEST_ROUTE -else: - TEST_ROUTE = EON_TEST_ROUTE SEND_EXTRA_INPUTS = bool(os.getenv("SEND_EXTRA_INPUTS", "0")) diff --git a/selfdrive/test/setup_device_ci.sh b/selfdrive/test/setup_device_ci.sh index f2f76299f2..1b518ddb21 100755 --- a/selfdrive/test/setup_device_ci.sh +++ b/selfdrive/test/setup_device_ci.sh @@ -21,44 +21,23 @@ umount /data/safe_staging/merged/ || true sudo umount /data/safe_staging/merged/ || true export KEYS_PARAM_PATH="/data/params/d/GithubSshKeys" -if [ -f "/EON" ]; then - export KEYS_PATH="/data/data/com.termux/files/home/setup_keys" - export CONTINUE_PATH="/data/data/com.termux/files/continue.sh" - - if ! grep -F "$KEYS_PATH" /usr/etc/ssh/sshd_config; then - echo "setting up keys" - mount -o rw,remount /system - sed -i "s,$KEYS_PARAM_PATH,$KEYS_PATH," /usr/etc/ssh/sshd_config - mount -o ro,remount /system - fi - - # these can get pretty big - rm -rf /data/core - rm -rf /data/neoupdate - rm -rf /data/safe_staging -else - export KEYS_PATH="/usr/comma/setup_keys" - export CONTINUE_PATH="/data/continue.sh" - - if ! grep -F "$KEYS_PATH" /etc/ssh/sshd_config; then - echo "setting up keys" - sudo mount -o rw,remount / - sudo systemctl enable ssh - sudo sed -i "s,$KEYS_PARAM_PATH,$KEYS_PATH," /etc/ssh/sshd_config - sudo mount -o ro,remount / - fi +export KEYS_PATH="/usr/comma/setup_keys" +export CONTINUE_PATH="/data/continue.sh" + +if ! grep -F "$KEYS_PATH" /etc/ssh/sshd_config; then + echo "setting up keys" + sudo mount -o rw,remount / + sudo systemctl enable ssh + sudo sed -i "s,$KEYS_PARAM_PATH,$KEYS_PATH," /etc/ssh/sshd_config + sudo mount -o ro,remount / fi tee $CONTINUE_PATH << EOF #!/usr/bin/bash while true; do - if [ -f /EON ]; then - setprop persist.neos.ssh 1 - else - if ! sudo systemctl is-active -q ssh; then - sudo systemctl start ssh - fi + if ! sudo systemctl is-active -q ssh; then + sudo systemctl start ssh fi sleep 10s done diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index d6d9f49bca..a5fefcb6dd 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -15,26 +15,25 @@ from common.basedir import BASEDIR from common.timeout import Timeout from common.params import Params from selfdrive.controls.lib.events import EVENTS, ET -from selfdrive.hardware import EON, TICI from selfdrive.loggerd.config import ROOT from selfdrive.test.helpers import set_params_enabled, release_only from tools.lib.logreader import LogReader # Baseline CPU usage by process PROCS = { - "selfdrive.controls.controlsd": 55.0, - "./loggerd": 45.0, + "selfdrive.controls.controlsd": 31.0, + "./loggerd": 70.0, + "./camerad": 41.0, "./locationd": 9.1, - "selfdrive.controls.plannerd": 22.6, - "./_ui": 20.0, - "selfdrive.locationd.paramsd": 14.0, - "./camerad": 9.16, + "selfdrive.controls.plannerd": 11.7, + "./_ui": 33.0, + "selfdrive.locationd.paramsd": 5.0, "./_sensord": 6.17, - "selfdrive.controls.radard": 7.0, + "selfdrive.controls.radard": 4.5, "./_modeld": 4.48, "./boardd": 3.63, - "./_dmonitoringmodeld": 2.67, - "selfdrive.thermald.thermald": 5.36, + "./_dmonitoringmodeld": 10.0, + "selfdrive.thermald.thermald": 3.87, "selfdrive.locationd.calibrationd": 2.0, "./_soundd": 1.0, "selfdrive.monitoring.dmonitoringd": 1.90, @@ -46,26 +45,6 @@ PROCS = { "./logcatd": 0, } -if EON: - PROCS.update({ - "selfdrive.hardware.eon.androidd": 0.4, - "selfdrive.hardware.eon.shutdownd": 0.4, - }) - -if TICI: - PROCS.update({ - "./loggerd": 70.0, - "selfdrive.controls.controlsd": 31.0, - "./camerad": 41.0, - "./_ui": 33.0, - "selfdrive.controls.plannerd": 11.7, - "./_dmonitoringmodeld": 10.0, - "selfdrive.locationd.paramsd": 5.0, - "selfdrive.controls.radard": 4.5, - "selfdrive.thermald.thermald": 3.87, - }) - - TIMINGS = { # rtols: max/min, rsd "can": [2.5, 0.35], @@ -82,15 +61,8 @@ TIMINGS = { "modelV2": [2.5, 0.35], "driverState": [2.5, 0.35], "liveLocationKalman": [2.5, 0.35], + "wideRoadCameraState": [1.5, 0.35], } -if EON: - TIMINGS.update({ - "roadCameraState": [2.5, 0.45], - }) -if TICI: - TIMINGS.update({ - "wideRoadCameraState": [1.5, 0.35], - }) def cputime_total(ct): @@ -232,12 +204,10 @@ class TestOnroad(unittest.TestCase): result += "----------------- Model Timing -----------------\n" result += "------------------------------------------------\n" # TODO: this went up when plannerd cpu usage increased, why? - cfgs = [("driverState", 0.028, 0.026)] - if EON: - cfgs += [("modelV2", 0.045, 0.04)] - else: - cfgs += [("modelV2", 0.038, 0.036), ("driverState", 0.028, 0.026)] - + cfgs = [ + ("modelV2", 0.038, 0.036), + ("driverState", 0.028, 0.026), + ] for (s, instant_max, avg_max) in cfgs: ts = [getattr(getattr(m, s), "modelExecutionTime") for m in self.lr if m.which() == s] self.assertLess(min(ts), instant_max, f"high '{s}' execution time: {min(ts)}") diff --git a/selfdrive/thermald/fan_controller.py b/selfdrive/thermald/fan_controller.py index f111b4edf7..fd9de2ac0f 100644 --- a/selfdrive/thermald/fan_controller.py +++ b/selfdrive/thermald/fan_controller.py @@ -1,8 +1,6 @@ #!/usr/bin/env python3 - -import os -from smbus2 import SMBus from abc import ABC, abstractmethod + from common.realtime import DT_TRML from common.numpy_fast import interp from selfdrive.swaglog import cloudlog @@ -14,69 +12,6 @@ class BaseFanController(ABC): pass -class EonFanController(BaseFanController): - # Temp thresholds to control fan speed - high hysteresis - TEMP_THRS_H = [50., 65., 80., 10000] - # Temp thresholds to control fan speed - low hysteresis - TEMP_THRS_L = [42.5, 57.5, 72.5, 10000] - # Fan speed options - FAN_SPEEDS = [0, 16384, 32768, 65535] - - def __init__(self) -> None: - super().__init__() - cloudlog.info("Setting up EON fan handler") - - self.fan_speed = -1 - self.setup_eon_fan() - - def setup_eon_fan(self) -> None: - os.system("echo 2 > /sys/module/dwc3_msm/parameters/otg_switch") - - def set_eon_fan(self, speed: int) -> None: - if self.fan_speed != speed: - # FIXME: this is such an ugly hack to get the right index - val = speed // 16384 - - bus = SMBus(7, force=True) - try: - i = [0x1, 0x3 | 0, 0x3 | 0x08, 0x3 | 0x10][val] - bus.write_i2c_block_data(0x3d, 0, [i]) - except OSError: - # tusb320 - if val == 0: - bus.write_i2c_block_data(0x67, 0xa, [0]) - else: - bus.write_i2c_block_data(0x67, 0xa, [0x20]) - bus.write_i2c_block_data(0x67, 0x8, [(val - 1) << 6]) - bus.close() - self.fan_speed = speed - - def update(self, max_cpu_temp: float, ignition: bool) -> int: - new_speed_h = next(speed for speed, temp_h in zip(self.FAN_SPEEDS, self.TEMP_THRS_H) if temp_h > max_cpu_temp) - new_speed_l = next(speed for speed, temp_l in zip(self.FAN_SPEEDS, self.TEMP_THRS_L) if temp_l > max_cpu_temp) - - if new_speed_h > self.fan_speed: - self.set_eon_fan(new_speed_h) - elif new_speed_l < self.fan_speed: - self.set_eon_fan(new_speed_l) - - return self.fan_speed - - -class UnoFanController(BaseFanController): - def __init__(self) -> None: - super().__init__() - cloudlog.info("Setting up UNO fan handler") - - def update(self, max_cpu_temp: float, ignition: bool) -> int: - new_speed = int(interp(max_cpu_temp, [40.0, 80.0], [0, 80])) - - if not ignition: - new_speed = min(30, new_speed) - - return new_speed - - class TiciFanController(BaseFanController): def __init__(self) -> None: super().__init__() diff --git a/selfdrive/thermald/tests/test_fan_controller.py b/selfdrive/thermald/tests/test_fan_controller.py index 8865b1f98b..857866f64e 100755 --- a/selfdrive/thermald/tests/test_fan_controller.py +++ b/selfdrive/thermald/tests/test_fan_controller.py @@ -1,13 +1,11 @@ #!/usr/bin/env python3 import unittest -from unittest.mock import Mock, MagicMock, patch +from unittest.mock import Mock, patch from parameterized import parameterized -with patch("smbus2.SMBus", new=MagicMock()): - from selfdrive.thermald.fan_controller import EonFanController, UnoFanController, TiciFanController +from selfdrive.thermald.fan_controller import TiciFanController -ALL_CONTROLLERS = [(EonFanController, ), (UnoFanController,), (TiciFanController,)] -GEN2_CONTROLLERS = [(UnoFanController,), (TiciFanController,)] +ALL_CONTROLLERS = [(TiciFanController,)] def patched_controller(controller_class): with patch("os.system", new=Mock()): @@ -28,7 +26,7 @@ class TestFanController(unittest.TestCase): self.wind_up(controller) self.assertGreaterEqual(controller.update(max_cpu_temp=100, ignition=True), 70) - @parameterized.expand(GEN2_CONTROLLERS) + @parameterized.expand(ALL_CONTROLLERS) def test_offroad_limits(self, controller_class): controller = patched_controller(controller_class) self.wind_up(controller) @@ -40,7 +38,7 @@ class TestFanController(unittest.TestCase): self.wind_down(controller) self.assertEqual(controller.update(max_cpu_temp=10, ignition=False), 0) - @parameterized.expand(GEN2_CONTROLLERS) + @parameterized.expand(ALL_CONTROLLERS) def test_limited(self, controller_class): controller = patched_controller(controller_class) self.wind_up(controller, ignition=True) diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index 2fbf48d170..f959c7c4d8 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -17,12 +17,12 @@ from common.filter_simple import FirstOrderFilter from common.params import Params from common.realtime import DT_TRML, sec_since_boot from selfdrive.controls.lib.alertmanager import set_offroad_alert -from selfdrive.hardware import EON, HARDWARE, PC, TICI +from selfdrive.hardware import HARDWARE, TICI from selfdrive.loggerd.config import get_available_percent from selfdrive.statsd import statlog from selfdrive.swaglog import cloudlog from selfdrive.thermald.power_monitoring import PowerMonitoring -from selfdrive.thermald.fan_controller import EonFanController, UnoFanController, TiciFanController +from selfdrive.thermald.fan_controller import TiciFanController from selfdrive.version import terms_version, training_version ThermalStatus = log.DeviceState.ThermalStatus @@ -174,7 +174,6 @@ def thermald_thread(end_event, hw_queue): started_ts = None started_seen = False thermal_status = ThermalStatus.green - usb_power = True last_hw_state = HardwareState( network_type=NetworkType.none, @@ -189,7 +188,6 @@ def thermald_thread(end_event, hw_queue): temp_filter = FirstOrderFilter(0., TEMP_TAU, DT_TRML) should_start_prev = False in_car = False - is_uno = False engaged_prev = False params = Params() @@ -216,18 +214,11 @@ def thermald_thread(end_event, hw_queue): pandaState = pandaStates[0] in_car = pandaState.harnessStatus != log.PandaState.HarnessStatus.notConnected - usb_power = peripheralState.usbPowerMode != log.PeripheralState.UsbPowerMode.client # Setup fan handler on first connect to panda if fan_controller is None and peripheralState.pandaType != log.PandaState.PandaType.unknown: - is_uno = peripheralState.pandaType == log.PandaState.PandaType.uno - if TICI: fan_controller = TiciFanController() - elif is_uno or PC: - fan_controller = UnoFanController() - else: - fan_controller = EonFanController() try: last_hw_state = hw_queue.get_nowait() @@ -380,9 +371,6 @@ def thermald_thread(end_event, hw_queue): msg.deviceState.thermalStatus = thermal_status pm.send("deviceState", msg) - if EON and not is_uno: - set_offroad_alert_if_changed("Offroad_ChargeDisabled", (not usb_power)) - should_start_prev = should_start startup_conditions_prev = startup_conditions.copy() @@ -409,9 +397,6 @@ def thermald_thread(end_event, hw_queue): # report to server once every 10 minutes if (count % int(600. / DT_TRML)) == 0: - if EON and started_ts is None and msg.deviceState.memoryUsagePercent > 40: - cloudlog.event("High offroad memory usage", mem=msg.deviceState.memoryUsagePercent) - cloudlog.event("STATUS_PACKET", count=count, pandaStates=[strip_deprecated_keys(p.to_dict()) for p in pandaStates], diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index 7526de685a..d4e1f7dead 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -7,9 +7,6 @@ base_libs = [gpucommon, common, messaging, cereal, visionipc, transformations, ' maps = arch in ['larch64', 'x86_64'] -if arch == 'aarch64': - base_libs += ['log', 'utils', 'gui', 'ui', 'CB', 'gsl', 'adreno_utils', 'cutils', 'uuid'] - if maps and arch == 'x86_64': rpath = [Dir(f"#third_party/mapbox-gl-native-qt/{arch}").srcnode().abspath] qt_env["RPATH"] += rpath @@ -22,10 +19,7 @@ widgets_src = ["qt/util.cc", "qt/widgets/input.cc", "qt/widgets/drive_stats.cc", "qt/widgets/ssh_keys.cc", "qt/widgets/toggle.cc", "qt/widgets/controls.cc", "qt/widgets/offroad_alerts.cc", "qt/widgets/prime.cc", "qt/widgets/keyboard.cc", "qt/widgets/scrollview.cc", "qt/widgets/cameraview.cc", "#third_party/qrcode/QrCode.cc", "qt/api.cc", - "qt/request_repeater.cc", "qt/qt_window.cc"] - -if arch != 'aarch64': - widgets_src += ["qt/offroad/networking.cc", "qt/offroad/wifiManager.cc"] + "qt/request_repeater.cc", "qt/qt_window.cc", "qt/offroad/networking.cc", "qt/offroad/wifiManager.cc"] qt_env['CPPDEFINES'] = [] if maps: @@ -63,7 +57,7 @@ qt_env.Program("_ui", qt_src + [asset_obj], LIBS=qt_libs) # setup and factory resetter -if arch != 'aarch64' and GetOption('extras'): +if GetOption('extras'): qt_env.Program("qt/setup/reset", ["qt/setup/reset.cc"], LIBS=qt_libs) qt_env.Program("qt/setup/setup", ["qt/setup/setup.cc", asset_obj], LIBS=qt_libs + ['curl', 'common', 'json11']) @@ -80,8 +74,8 @@ if GetOption('extras'): senv = qt_env.Clone() senv['LINKFLAGS'].append('-Wl,-strip-debug') - release = "release3" if arch == 'larch64' else "release2" - dashcam = "dashcam3" if arch == 'larch64' else "dashcam" + release = "release3" + dashcam = "dashcam3" installers = [ ("openpilot", release), ("openpilot_test", f"{release}-staging"), diff --git a/selfdrive/ui/installer/installer.cc b/selfdrive/ui/installer/installer.cc index 5366a0eac6..3588026ba6 100644 --- a/selfdrive/ui/installer/installer.cc +++ b/selfdrive/ui/installer/installer.cc @@ -25,12 +25,7 @@ const std::string GIT_URL = get_str("https://github.com/commaai/openpilot.git" " const std::string BRANCH_STR = get_str(BRANCH "? "); #define GIT_SSH_URL "git@github.com:commaai/openpilot.git" - -#ifdef QCOM - #define CONTINUE_PATH "/data/data/com.termux/files/continue.sh" -#else - #define CONTINUE_PATH "/data/continue.sh" -#endif +#define CONTINUE_PATH "/data/continue.sh" const QString CACHE_PATH = "/data/openpilot.cache"; @@ -212,12 +207,8 @@ void Installer::cloneFinished(int exitCode, QProcess::ExitStatus exitStatus) { run("chmod +x /data/continue.sh.new"); run("mv /data/continue.sh.new " CONTINUE_PATH); -#ifdef QCOM - QTimer::singleShot(100, &QCoreApplication::quit); -#else // wait for the installed software's UI to take over QTimer::singleShot(60 * 1000, &QCoreApplication::quit); -#endif } int main(int argc, char *argv[]) { diff --git a/selfdrive/ui/main.cc b/selfdrive/ui/main.cc index 8477bc8966..cffa459622 100644 --- a/selfdrive/ui/main.cc +++ b/selfdrive/ui/main.cc @@ -1,7 +1,6 @@ #include #include -#include #include "selfdrive/hardware/hw.h" #include "selfdrive/ui/qt/qt_window.h" @@ -14,12 +13,6 @@ int main(int argc, char *argv[]) { qInstallMessageHandler(swagLogMessageHandler); initApp(argc, argv); - if (Hardware::EON()) { - QSslConfiguration ssl = QSslConfiguration::defaultConfiguration(); - ssl.setCaCertificates(QSslCertificate::fromPath("/usr/etc/tls/cert.pem")); - QSslConfiguration::setDefaultConfiguration(ssl); - } - QApplication a(argc, argv); MainWindow w; setMainWindow(&w); diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index 23a040dd56..ec686ba1f0 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -6,9 +6,7 @@ #include -#ifndef QCOM #include "selfdrive/ui/qt/offroad/networking.h" -#endif #ifdef ENABLE_MAPS #include "selfdrive/ui/qt/maps/map_settings.h" @@ -290,57 +288,8 @@ void SoftwarePanel::updateLabels() { osVersionLbl->setText(QString::fromStdString(Hardware::get_os_version()).trimmed()); } -C2NetworkPanel::C2NetworkPanel(QWidget *parent) : QWidget(parent) { - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setContentsMargins(50, 0, 50, 0); - - ListWidget *list = new ListWidget(); - list->setSpacing(30); - // wifi + tethering buttons -#ifdef QCOM - auto wifiBtn = new ButtonControl("Wi-Fi Settings", "OPEN"); - QObject::connect(wifiBtn, &ButtonControl::clicked, [=]() { HardwareEon::launch_wifi(); }); - list->addItem(wifiBtn); - - auto tetheringBtn = new ButtonControl("Tethering Settings", "OPEN"); - QObject::connect(tetheringBtn, &ButtonControl::clicked, [=]() { HardwareEon::launch_tethering(); }); - list->addItem(tetheringBtn); -#endif - ipaddress = new LabelControl("IP Address", ""); - list->addItem(ipaddress); - - // SSH key management - list->addItem(new SshToggle()); - list->addItem(new SshControl()); - layout->addWidget(list); - layout->addStretch(1); -} - -void C2NetworkPanel::showEvent(QShowEvent *event) { - ipaddress->setText(getIPAddress()); -} - -QString C2NetworkPanel::getIPAddress() { - std::string result = util::check_output("ifconfig wlan0"); - if (result.empty()) return ""; - - const std::string inetaddrr = "inet addr:"; - std::string::size_type begin = result.find(inetaddrr); - if (begin == std::string::npos) return ""; - - begin += inetaddrr.length(); - std::string::size_type end = result.find(' ', begin); - if (end == std::string::npos) return ""; - - return result.substr(begin, end - begin).c_str(); -} - QWidget *network_panel(QWidget *parent) { -#ifdef QCOM - return new C2NetworkPanel(parent); -#else return new Networking(parent); -#endif } void SettingsWindow::showEvent(QShowEvent *event) { @@ -457,9 +406,3 @@ SettingsWindow::SettingsWindow(QWidget *parent) : QFrame(parent) { } )"); } - -void SettingsWindow::hideEvent(QHideEvent *event) { -#ifdef QCOM - HardwareEon::close_activities(); -#endif -} diff --git a/selfdrive/ui/qt/offroad/settings.h b/selfdrive/ui/qt/offroad/settings.h index c3acf3d94a..160f10f99f 100644 --- a/selfdrive/ui/qt/offroad/settings.h +++ b/selfdrive/ui/qt/offroad/settings.h @@ -19,7 +19,6 @@ public: explicit SettingsWindow(QWidget *parent = 0); protected: - void hideEvent(QHideEvent *event) override; void showEvent(QShowEvent *event) override; signals: @@ -76,14 +75,3 @@ private: Params params; QFileSystemWatcher *fs_watch; }; - -class C2NetworkPanel: public QWidget { - Q_OBJECT -public: - explicit C2NetworkPanel(QWidget* parent = nullptr); - -private: - void showEvent(QShowEvent *event) override; - QString getIPAddress(); - LabelControl *ipaddress; -}; diff --git a/selfdrive/ui/qt/setup/updater.cc b/selfdrive/ui/qt/setup/updater.cc index 6345d80db8..b906b5739d 100644 --- a/selfdrive/ui/qt/setup/updater.cc +++ b/selfdrive/ui/qt/setup/updater.cc @@ -6,10 +6,7 @@ #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/qt_window.h" #include "selfdrive/ui/qt/setup/updater.h" - -#ifndef QCOM #include "selfdrive/ui/qt/offroad/networking.h" -#endif Updater::Updater(const QString &updater_path, const QString &manifest_path, QWidget *parent) : updater(updater_path), manifest(manifest_path), QStackedWidget(parent) { @@ -43,11 +40,7 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid QPushButton *connect = new QPushButton("Connect to Wi-Fi"); connect->setObjectName("navBtn"); QObject::connect(connect, &QPushButton::clicked, [=]() { -#ifndef QCOM setCurrentWidget(wifi); -#else - HardwareEon::launch_wifi(); -#endif }); hlayout->addWidget(connect); @@ -64,11 +57,9 @@ Updater::Updater(const QString &updater_path, const QString &manifest_path, QWid QVBoxLayout *layout = new QVBoxLayout(wifi); layout->setContentsMargins(100, 100, 100, 100); -#ifndef QCOM Networking *networking = new Networking(this, false); networking->setStyleSheet("Networking { background-color: #292929; border-radius: 13px; }"); layout->addWidget(networking, 1); -#endif QPushButton *back = new QPushButton("Back"); back->setObjectName("navBtn"); @@ -175,20 +166,6 @@ void Updater::updateFinished(int exitCode, QProcess::ExitStatus exitStatus) { } } -bool Updater::eventFilter(QObject *obj, QEvent *event) { -#ifdef QCOM - // filter out touches while in android activity - const static QSet filter_events({QEvent::MouseButtonPress, QEvent::MouseMove, QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd}); - if (HardwareEon::launched_activity && filter_events.contains(event->type())) { - HardwareEon::check_activity(); - if (HardwareEon::launched_activity) { - return true; - } - } -#endif - return false; -} - int main(int argc, char *argv[]) { initApp(argc, argv); QApplication a(argc, argv); diff --git a/selfdrive/ui/qt/setup/updater.h b/selfdrive/ui/qt/setup/updater.h index 32aef43f59..ce46c0aabd 100644 --- a/selfdrive/ui/qt/setup/updater.h +++ b/selfdrive/ui/qt/setup/updater.h @@ -19,8 +19,6 @@ private slots: void updateFinished(int exitCode, QProcess::ExitStatus exitStatus); private: - bool eventFilter(QObject *obj, QEvent *event) override; - QProcess proc; QString updater, manifest; diff --git a/selfdrive/ui/qt/spinner_aarch64 b/selfdrive/ui/qt/spinner_aarch64 deleted file mode 100755 index 0ad9192c98..0000000000 --- a/selfdrive/ui/qt/spinner_aarch64 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:56a3413e09c42849a190031665a2bdabf628a495fd3c8e181c8e863c22a7cd64 -size 3166352 diff --git a/selfdrive/ui/qt/text_aarch64 b/selfdrive/ui/qt/text_aarch64 deleted file mode 100755 index 78d19b0ac0..0000000000 --- a/selfdrive/ui/qt/text_aarch64 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8c33f9f4090720b23f3c70cf1fe5b3bda23f31fe17a20f769279bf14dbb1178e -size 3214400 diff --git a/selfdrive/ui/qt/util.cc b/selfdrive/ui/qt/util.cc index 967b7d15d1..e38052ea59 100644 --- a/selfdrive/ui/qt/util.cc +++ b/selfdrive/ui/qt/util.cc @@ -102,9 +102,6 @@ void initApp(int argc, char *argv[]) { #endif setQtSurfaceFormat(); - if (Hardware::EON()) { - QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - } } void swagLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { diff --git a/selfdrive/ui/qt/widgets/cameraview.cc b/selfdrive/ui/qt/widgets/cameraview.cc index ed40094f73..d5069819e7 100644 --- a/selfdrive/ui/qt/widgets/cameraview.cc +++ b/selfdrive/ui/qt/widgets/cameraview.cc @@ -38,10 +38,6 @@ const char frame_fragment_shader[] = "out vec4 colorOut;\n" "void main() {\n" " colorOut = texture(uTexture, vTexCoord.xy);\n" -#ifdef QCOM - " vec3 dz = vec3(0.0627f, 0.0627f, 0.0627f);\n" - " colorOut.rgb = ((vec3(1.0f, 1.0f, 1.0f) - dz) * colorOut.rgb / vec3(1.0f, 1.0f, 1.0f)) + dz;\n" -#endif "}\n"; const mat4 device_transform = {{ @@ -256,20 +252,18 @@ void CameraViewWidget::vipcThread() { std::unique_ptr surface; std::unique_ptr gl_buffer; - if (!Hardware::EON()) { - ctx = std::make_unique(); - ctx->setFormat(context()->format()); - ctx->setShareContext(context()); - ctx->create(); - assert(ctx->isValid()); - - surface = std::make_unique(); - surface->setFormat(ctx->format()); - surface->create(); - ctx->makeCurrent(surface.get()); - assert(QOpenGLContext::currentContext() == ctx.get()); - initializeOpenGLFunctions(); - } + ctx = std::make_unique(); + ctx->setFormat(context()->format()); + ctx->setShareContext(context()); + ctx->create(); + assert(ctx->isValid()); + + surface = std::make_unique(); + surface->setFormat(ctx->format()); + surface->create(); + ctx->makeCurrent(surface.get()); + assert(QOpenGLContext::currentContext() == ctx.get()); + initializeOpenGLFunctions(); while (!QThread::currentThread()->isInterruptionRequested()) { if (!vipc_client || cur_stream_type != stream_type) { @@ -283,13 +277,11 @@ void CameraViewWidget::vipcThread() { continue; } - if (!Hardware::EON()) { - gl_buffer.reset(new QOpenGLBuffer(QOpenGLBuffer::PixelUnpackBuffer)); - gl_buffer->create(); - gl_buffer->bind(); - gl_buffer->setUsagePattern(QOpenGLBuffer::StreamDraw); - gl_buffer->allocate(vipc_client->buffers[0].len); - } + gl_buffer.reset(new QOpenGLBuffer(QOpenGLBuffer::PixelUnpackBuffer)); + gl_buffer->create(); + gl_buffer->bind(); + gl_buffer->setUsagePattern(QOpenGLBuffer::StreamDraw); + gl_buffer->allocate(vipc_client->buffers[0].len); emit vipcThreadConnected(vipc_client.get()); } @@ -297,29 +289,29 @@ void CameraViewWidget::vipcThread() { if (VisionBuf *buf = vipc_client->recv(nullptr, 1000)) { { std::lock_guard lk(lock); - if (!Hardware::EON()) { - void *texture_buffer = gl_buffer->map(QOpenGLBuffer::WriteOnly); - if (texture_buffer == nullptr) { - LOGE("gl_buffer->map returned nullptr"); - continue; - } + void *texture_buffer = gl_buffer->map(QOpenGLBuffer::WriteOnly); - memcpy(texture_buffer, buf->addr, buf->len); - gl_buffer->unmap(); + if (texture_buffer == nullptr) { + LOGE("gl_buffer->map returned nullptr"); + continue; + } - // copy pixels from PBO to texture object - glBindTexture(GL_TEXTURE_2D, texture[buf->idx]->frame_tex); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, buf->width, buf->height, GL_RGB, GL_UNSIGNED_BYTE, 0); - glBindTexture(GL_TEXTURE_2D, 0); - assert(glGetError() == GL_NO_ERROR); + memcpy(texture_buffer, buf->addr, buf->len); + gl_buffer->unmap(); - wait_fence.reset(new WaitFence()); + // copy pixels from PBO to texture object + glBindTexture(GL_TEXTURE_2D, texture[buf->idx]->frame_tex); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, buf->width, buf->height, GL_RGB, GL_UNSIGNED_BYTE, 0); + glBindTexture(GL_TEXTURE_2D, 0); + assert(glGetError() == GL_NO_ERROR); + + wait_fence.reset(new WaitFence()); + + // Ensure the fence is in the GPU command queue, or waiting on it might block + // https://www.khronos.org/opengl/wiki/Sync_Object#Flushing_and_contexts + glFlush(); - // Ensure the fence is in the GPU command queue, or waiting on it might block - // https://www.khronos.org/opengl/wiki/Sync_Object#Flushing_and_contexts - glFlush(); - } latest_texture_id = buf->idx; } // Schedule update. update() will be invoked on the gui thread. diff --git a/selfdrive/ui/qt/window.cc b/selfdrive/ui/qt/window.cc index 76d5a39d44..fb21f6f7af 100644 --- a/selfdrive/ui/qt/window.cc +++ b/selfdrive/ui/qt/window.cc @@ -85,15 +85,6 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (evts.contains(event->type())) { device.resetInteractiveTimout(); -#ifdef QCOM - // filter out touches while in android activity - if (HardwareEon::launched_activity) { - HardwareEon::check_activity(); - if (HardwareEon::launched_activity) { - return true; - } - } -#endif } return false; } diff --git a/selfdrive/ui/spinner b/selfdrive/ui/spinner index 4a75ca25a4..6c8e533cc8 100755 --- a/selfdrive/ui/spinner +++ b/selfdrive/ui/spinner @@ -1,8 +1,6 @@ #!/bin/sh -if [ -f /EON ] && [ ! -f qt/spinner ]; then - cp qt/spinner_aarch64 qt/spinner -elif [ -f /TICI ] && [ ! -f qt/spinner ]; then +if [ -f /TICI ] && [ ! -f qt/spinner ]; then cp qt/spinner_larch64 qt/spinner fi diff --git a/selfdrive/ui/text b/selfdrive/ui/text index a7177c656f..2577e3006b 100755 --- a/selfdrive/ui/text +++ b/selfdrive/ui/text @@ -1,8 +1,6 @@ #!/bin/sh -if [ -f /EON ] && [ ! -f qt/text ]; then - cp qt/text_aarch64 qt/text -elif [ -f /TICI ] && [ ! -f qt/text ]; then +if [ -f /TICI ] && [ ! -f qt/text ]; then cp qt/text_larch64 qt/text fi diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 6825506e66..583c03a5d5 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -166,17 +166,7 @@ static void update_state(UIState *s) { } } } - if (!Hardware::TICI() && sm.updated("roadCameraState")) { - auto camera_state = sm["roadCameraState"].getRoadCameraState(); - - float max_lines = Hardware::EON() ? 5408 : 1904; - float max_gain = Hardware::EON() ? 1.0: 10.0; - float max_ev = max_lines * max_gain; - - float ev = camera_state.getGain() * float(camera_state.getIntegLines()); - - scene.light_sensor = std::clamp(1.0 - (ev / max_ev), 0.0, 1.0); - } else if (Hardware::TICI() && sm.updated("wideRoadCameraState")) { + if (Hardware::TICI() && sm.updated("wideRoadCameraState")) { auto camera_state = sm["wideRoadCameraState"].getWideRoadCameraState(); float max_lines = 1618; diff --git a/selfdrive/ui/ui.h b/selfdrive/ui/ui.h index 49ced57ea2..e3415b8830 100644 --- a/selfdrive/ui/ui.h +++ b/selfdrive/ui/ui.h @@ -24,8 +24,8 @@ typedef cereal::CarControl::HUDControl::AudibleAlert AudibleAlert; // TODO: this is also hardcoded in common/transformations/camera.py // TODO: choose based on frame input size -const float y_offset = Hardware::EON() ? 0.0 : 150.0; -const float ZOOM = Hardware::EON() ? 2138.5 : 2912.8; +const float y_offset = 150.0; +const float ZOOM = 2912.8; struct Alert { QString text1; diff --git a/selfdrive/updated.py b/selfdrive/updated.py index 2cbe8eb208..02cc27a27c 100755 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -37,7 +37,7 @@ from typing import List, Tuple, Optional from common.basedir import BASEDIR from common.markdown import parse_markdown from common.params import Params -from selfdrive.hardware import EON, TICI, HARDWARE +from selfdrive.hardware import TICI, HARDWARE from selfdrive.swaglog import cloudlog from selfdrive.controls.lib.alertmanager import set_offroad_alert from selfdrive.version import is_tested_branch @@ -283,42 +283,6 @@ def handle_agnos_update(wait_helper: WaitTimeHelper) -> None: set_offroad_alert("Offroad_NeosUpdate", False) -def handle_neos_update(wait_helper: WaitTimeHelper) -> None: - from selfdrive.hardware.eon.neos import download_neos_update - - cur_neos = HARDWARE.get_os_version() - updated_neos = run(["bash", "-c", r"unset REQUIRED_NEOS_VERSION && source launch_env.sh && \ - echo -n $REQUIRED_NEOS_VERSION"], OVERLAY_MERGED).strip() - - cloudlog.info(f"NEOS version check: {cur_neos} vs {updated_neos}") - if cur_neos == updated_neos: - return - - cloudlog.info(f"Beginning background download for NEOS {updated_neos}") - set_offroad_alert("Offroad_NeosUpdate", True) - - update_manifest = os.path.join(OVERLAY_MERGED, "selfdrive/hardware/eon/neos.json") - - neos_downloaded = False - start_time = time.monotonic() - # Try to download for one day - while not neos_downloaded and not wait_helper.shutdown and \ - (time.monotonic() - start_time < 60*60*24): - wait_helper.ready_event.clear() - try: - download_neos_update(update_manifest, cloudlog) - neos_downloaded = True - except Exception: - cloudlog.info("NEOS background download failed, retrying") - wait_helper.sleep(120) - - # If the download failed, we'll show the alert again when we retry - set_offroad_alert("Offroad_NeosUpdate", False) - if not neos_downloaded: - raise Exception("Failed to download NEOS update") - cloudlog.info(f"NEOS background download successful, took {time.monotonic() - start_time} seconds") - - def check_git_fetch_result(fetch_txt: str) -> bool: err_msg = "Failed to add the host to the list of known hosts (/data/data/com.termux/files/home/.ssh/known_hosts).\n" return len(fetch_txt) > 0 and (fetch_txt != err_msg) @@ -360,9 +324,7 @@ def fetch_update(wait_helper: WaitTimeHelper) -> bool: ] cloudlog.info("git reset success: %s", '\n'.join(r)) - if EON: - handle_neos_update(wait_helper) - elif TICI: + if TICI: handle_agnos_update(wait_helper) # Create the finalized, ready-to-swap update diff --git a/selfdrive/version.py b/selfdrive/version.py index 9b18edc432..5517fe728a 100644 --- a/selfdrive/version.py +++ b/selfdrive/version.py @@ -7,7 +7,7 @@ from functools import lru_cache from common.basedir import BASEDIR from selfdrive.swaglog import cloudlog -TESTED_BRANCHES = ['devel', 'release2-staging', 'release3-staging', 'dashcam-staging', 'release2', 'release3', 'dashcam'] +TESTED_BRANCHES = ['devel', 'release3-staging', 'dashcam3-staging', 'release3', 'dashcam3'] training_version: bytes = b"0.2.0" terms_version: bytes = b"2" diff --git a/third_party/acados/aarch64/lib/libacados.so b/third_party/acados/aarch64/lib/libacados.so deleted file mode 100755 index 2d7a6e5928..0000000000 --- a/third_party/acados/aarch64/lib/libacados.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fa02515dd1229ea78c0354189112f1d5ca777f581803d4344f744e80e3b2aa91 -size 576129 diff --git a/third_party/acados/aarch64/lib/libblasfeo.so b/third_party/acados/aarch64/lib/libblasfeo.so deleted file mode 100755 index c5551be974..0000000000 --- a/third_party/acados/aarch64/lib/libblasfeo.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ed4929ed8af91c883a28d53e491eca6e970cebc09669a3499db4cd380c937a9a -size 1200745 diff --git a/third_party/acados/aarch64/lib/libhpipm.so b/third_party/acados/aarch64/lib/libhpipm.so deleted file mode 100755 index a6cfdd7e98..0000000000 --- a/third_party/acados/aarch64/lib/libhpipm.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d6873d1bf018369aaf13cabe5d870d3154656668b31647df0a1a648b3bb383dc -size 1324409 diff --git a/third_party/acados/aarch64/lib/libqpOASES_e.so b/third_party/acados/aarch64/lib/libqpOASES_e.so deleted file mode 120000 index 14048625a1..0000000000 --- a/third_party/acados/aarch64/lib/libqpOASES_e.so +++ /dev/null @@ -1 +0,0 @@ -libqpOASES_e.so.3.1 \ No newline at end of file diff --git a/third_party/acados/aarch64/lib/libqpOASES_e.so.3.1 b/third_party/acados/aarch64/lib/libqpOASES_e.so.3.1 deleted file mode 100755 index 857c159384..0000000000 --- a/third_party/acados/aarch64/lib/libqpOASES_e.so.3.1 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:17841debecba17ce4bb1150820c61f9d965c3cb045f46afc8b20ee286dd42350 -size 218545 diff --git a/third_party/acados/aarch64/t_renderer b/third_party/acados/aarch64/t_renderer deleted file mode 100755 index a7ba8cf2fc..0000000000 --- a/third_party/acados/aarch64/t_renderer +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c3f13c06f967ae8c785c73e716c9e0ce9f4688b55fde0d798d4fa077a1edb0ad -size 4498992 diff --git a/third_party/acados/build.sh b/third_party/acados/build.sh index e0f603e682..0b14a4cec9 100755 --- a/third_party/acados/build.sh +++ b/third_party/acados/build.sh @@ -7,9 +7,6 @@ BLAS_TARGET="X64_AUTOMATIC" if [ -f /TICI ]; then ARCHNAME="larch64" BLAS_TARGET="ARMV8A_ARM_CORTEX_A57" -elif [ -f /EON ]; then - ARCHNAME="aarch64" - BLAS_TARGET="ARMV8A_ARM_CORTEX_A57" fi if [ ! -d acados_repo/ ]; then @@ -40,38 +37,7 @@ rm -rf $DIR/../../pyextra/acados_template cp -r $DIR/acados_repo/interfaces/acados_template/acados_template $DIR/../../pyextra #pip3 install -e $DIR/acados/interfaces/acados_template -# hack to workaround no rpath on android -if [ -f /EON ]; then - pushd $INSTALL_DIR/lib - for lib in $(ls .); do - if ! readlink $lib; then - patchelf --set-soname $PWD/$lib $lib - - if [ "$lib" = "libacados.so" ]; then - for nlib in "libhpipm.so" "libblasfeo.so" "libqpOASES_e.so.3.1"; do - patchelf --replace-needed $nlib $PWD/$nlib $lib - done - fi - - if [ "$lib" = "libhpipm.so" ]; then - patchelf --replace-needed libblasfeo.so $PWD/libblasfeo.so $lib - fi - - # pad extra byte to workaround bionic linker bug - # https://android.googlesource.com/platform/bionic/+/93ce35434ca5af43a7449e289959543f0a2426fa%5E%21/#F0 - dd if=/dev/zero bs=1 count=1 >> $lib - fi - done - popd - - cd $DIR - git checkout $INSTALL_DIR/t_renderer -fi - # build tera -# build with commaai/termux-packages for NEOS -if [ ! -f /EON ]; then - cd $DIR/acados_repo/interfaces/acados_template/tera_renderer/ - cargo build --verbose --release - cp target/release/t_renderer $INSTALL_DIR/ -fi +cd $DIR/acados_repo/interfaces/acados_template/tera_renderer/ +cargo build --verbose --release +cp target/release/t_renderer $INSTALL_DIR/ diff --git a/third_party/android_frameworks_native/get.txt b/third_party/android_frameworks_native/get.txt deleted file mode 100644 index 277bdcb6a8..0000000000 --- a/third_party/android_frameworks_native/get.txt +++ /dev/null @@ -1,3 +0,0 @@ -git clone https://github.com/CyanogenMod/android_frameworks_native.git && cd android_frameworks_native -git reset --hard b22bca465e55618a949d9cbdea665a1a3a831241 -cp -r include ~/one/third_party/android_frameworks_native/ diff --git a/third_party/android_frameworks_native/include/android/asset_manager.h b/third_party/android_frameworks_native/include/android/asset_manager.h deleted file mode 100644 index d65483968e..0000000000 --- a/third_party/android_frameworks_native/include/android/asset_manager.h +++ /dev/null @@ -1,215 +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. - */ - -/** - * @addtogroup Asset - * @{ - */ - -/** - * @file asset_manager.h - */ - -#ifndef ANDROID_ASSET_MANAGER_H -#define ANDROID_ASSET_MANAGER_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct AAssetManager; -/** - * {@link AAssetManager} provides access to an application's raw assets by - * creating {@link AAsset} objects. - * - * AAssetManager is a wrapper to the low-level native implementation - * of the java {@link AAssetManager}, a pointer can be obtained using - * AAssetManager_fromJava(). - * - * The asset hierarchy may be examined like a filesystem, using - * {@link AAssetDir} objects to peruse a single directory. - * - * A native {@link AAssetManager} pointer may be shared across multiple threads. - */ -typedef struct AAssetManager AAssetManager; - -struct AAssetDir; -/** - * {@link AAssetDir} provides access to a chunk of the asset hierarchy as if - * it were a single directory. The contents are populated by the - * {@link AAssetManager}. - * - * The list of files will be sorted in ascending order by ASCII value. - */ -typedef struct AAssetDir AAssetDir; - -struct AAsset; -/** - * {@link AAsset} provides access to a read-only asset. - * - * {@link AAsset} objects are NOT thread-safe, and should not be shared across - * threads. - */ -typedef struct AAsset AAsset; - -/** Available access modes for opening assets with {@link AAssetManager_open} */ -enum { - /** No specific information about how data will be accessed. **/ - AASSET_MODE_UNKNOWN = 0, - /** Read chunks, and seek forward and backward. */ - AASSET_MODE_RANDOM = 1, - /** Read sequentially, with an occasional forward seek. */ - AASSET_MODE_STREAMING = 2, - /** Caller plans to ask for a read-only buffer with all data. */ - AASSET_MODE_BUFFER = 3 -}; - - -/** - * Open the named directory within the asset hierarchy. The directory can then - * be inspected with the AAssetDir functions. To open the top-level directory, - * pass in "" as the dirName. - * - * The object returned here should be freed by calling AAssetDir_close(). - */ -AAssetDir* AAssetManager_openDir(AAssetManager* mgr, const char* dirName); - -/** - * Open an asset. - * - * The object returned here should be freed by calling AAsset_close(). - */ -AAsset* AAssetManager_open(AAssetManager* mgr, const char* filename, int mode); - -/** - * Iterate over the files in an asset directory. A NULL string is returned - * when all the file names have been returned. - * - * The returned file name is suitable for passing to AAssetManager_open(). - * - * The string returned here is owned by the AssetDir implementation and is not - * guaranteed to remain valid if any other calls are made on this AAssetDir - * instance. - */ -const char* AAssetDir_getNextFileName(AAssetDir* assetDir); - -/** - * Reset the iteration state of AAssetDir_getNextFileName() to the beginning. - */ -void AAssetDir_rewind(AAssetDir* assetDir); - -/** - * Close an opened AAssetDir, freeing any related resources. - */ -void AAssetDir_close(AAssetDir* assetDir); - -/** - * Attempt to read 'count' bytes of data from the current offset. - * - * Returns the number of bytes read, zero on EOF, or < 0 on error. - */ -int AAsset_read(AAsset* asset, void* buf, size_t count); - -/** - * Seek to the specified offset within the asset data. 'whence' uses the - * same constants as lseek()/fseek(). - * - * Returns the new position on success, or (off_t) -1 on error. - */ -off_t AAsset_seek(AAsset* asset, off_t offset, int whence); - -/** - * Seek to the specified offset within the asset data. 'whence' uses the - * same constants as lseek()/fseek(). - * - * Uses 64-bit data type for large files as opposed to the 32-bit type used - * by AAsset_seek. - * - * Returns the new position on success, or (off64_t) -1 on error. - */ -off64_t AAsset_seek64(AAsset* asset, off64_t offset, int whence); - -/** - * Close the asset, freeing all associated resources. - */ -void AAsset_close(AAsset* asset); - -/** - * Get a pointer to a buffer holding the entire contents of the assset. - * - * Returns NULL on failure. - */ -const void* AAsset_getBuffer(AAsset* asset); - -/** - * Report the total size of the asset data. - */ -off_t AAsset_getLength(AAsset* asset); - -/** - * Report the total size of the asset data. Reports the size using a 64-bit - * number insted of 32-bit as AAsset_getLength. - */ -off64_t AAsset_getLength64(AAsset* asset); - -/** - * Report the total amount of asset data that can be read from the current position. - */ -off_t AAsset_getRemainingLength(AAsset* asset); - -/** - * Report the total amount of asset data that can be read from the current position. - * - * Uses a 64-bit number instead of a 32-bit number as AAsset_getRemainingLength does. - */ -off64_t AAsset_getRemainingLength64(AAsset* asset); - -/** - * Open a new file descriptor that can be used to read the asset data. If the - * start or length cannot be represented by a 32-bit number, it will be - * truncated. If the file is large, use AAsset_openFileDescriptor64 instead. - * - * Returns < 0 if direct fd access is not possible (for example, if the asset is - * compressed). - */ -int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength); - -/** - * Open a new file descriptor that can be used to read the asset data. - * - * Uses a 64-bit number for the offset and length instead of 32-bit instead of - * as AAsset_openFileDescriptor does. - * - * Returns < 0 if direct fd access is not possible (for example, if the asset is - * compressed). - */ -int AAsset_openFileDescriptor64(AAsset* asset, off64_t* outStart, off64_t* outLength); - -/** - * Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not - * mmapped). - */ -int AAsset_isAllocated(AAsset* asset); - - - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_ASSET_MANAGER_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/asset_manager_jni.h b/third_party/android_frameworks_native/include/android/asset_manager_jni.h deleted file mode 100644 index dcee17e10f..0000000000 --- a/third_party/android_frameworks_native/include/android/asset_manager_jni.h +++ /dev/null @@ -1,50 +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. - */ - -/** - * @addtogroup Asset - * @{ - */ - -/** - * @file asset_manager_jni.h - */ - -#ifndef ANDROID_ASSET_MANAGER_JNI_H -#define ANDROID_ASSET_MANAGER_JNI_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager - * object. Note that the caller is responsible for obtaining and holding a VM reference - * to the jobject to prevent its being garbage collected while the native object is - * in use. - */ -AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_ASSET_MANAGER_JNI_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/bitmap.h b/third_party/android_frameworks_native/include/android/bitmap.h deleted file mode 100644 index 261e64fac9..0000000000 --- a/third_party/android_frameworks_native/include/android/bitmap.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -/** - * @addtogroup Bitmap - * @{ - */ - -/** - * @file bitmap.h - */ - -#ifndef ANDROID_BITMAP_H -#define ANDROID_BITMAP_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** AndroidBitmap functions result code. */ -enum { - /** Operation was successful. */ - ANDROID_BITMAP_RESULT_SUCCESS = 0, - /** Bad parameter. */ - ANDROID_BITMAP_RESULT_BAD_PARAMETER = -1, - /** JNI exception occured. */ - ANDROID_BITMAP_RESULT_JNI_EXCEPTION = -2, - /** Allocation failed. */ - ANDROID_BITMAP_RESULT_ALLOCATION_FAILED = -3, -}; - -/** Backward compatibility: this macro used to be misspelled. */ -#define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS - -/** Bitmap pixel format. */ -enum AndroidBitmapFormat { - /** No format. */ - ANDROID_BITMAP_FORMAT_NONE = 0, - /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/ - ANDROID_BITMAP_FORMAT_RGBA_8888 = 1, - /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/ - ANDROID_BITMAP_FORMAT_RGB_565 = 4, - /** Red: 4 bits, Green: 4 bits, Blue: 4 bits, Alpha: 4 bits. **/ - ANDROID_BITMAP_FORMAT_RGBA_4444 = 7, - /** Deprecated. */ - ANDROID_BITMAP_FORMAT_A_8 = 8, -}; - -/** Bitmap info, see AndroidBitmap_getInfo(). */ -typedef struct { - /** The bitmap width in pixels. */ - uint32_t width; - /** The bitmap height in pixels. */ - uint32_t height; - /** The number of byte per row. */ - uint32_t stride; - /** The bitmap pixel format. See {@link AndroidBitmapFormat} */ - int32_t format; - /** Unused. */ - uint32_t flags; // 0 for now -} AndroidBitmapInfo; - -/** - * Given a java bitmap object, fill out the AndroidBitmapInfo struct for it. - * If the call fails, the info parameter will be ignored. - */ -int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, - AndroidBitmapInfo* info); - -/** - * Given a java bitmap object, attempt to lock the pixel address. - * Locking will ensure that the memory for the pixels will not move - * until the unlockPixels call, and ensure that, if the pixels had been - * previously purged, they will have been restored. - * - * If this call succeeds, it must be balanced by a call to - * AndroidBitmap_unlockPixels, after which time the address of the pixels should - * no longer be used. - * - * If this succeeds, *addrPtr will be set to the pixel address. If the call - * fails, addrPtr will be ignored. - */ -int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr); - -/** - * Call this to balance a successful call to AndroidBitmap_lockPixels. - */ -int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap); - -#ifdef __cplusplus -} -#endif - -#endif - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/configuration.h b/third_party/android_frameworks_native/include/android/configuration.h deleted file mode 100644 index 81f71a92cb..0000000000 --- a/third_party/android_frameworks_native/include/android/configuration.h +++ /dev/null @@ -1,708 +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. - */ - -/** - * @addtogroup Configuration - * @{ - */ - -/** - * @file configuration.h - */ - -#ifndef ANDROID_CONFIGURATION_H -#define ANDROID_CONFIGURATION_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct AConfiguration; -/** - * {@link AConfiguration} is an opaque type used to get and set - * various subsystem configurations. - * - * A {@link AConfiguration} pointer can be obtained using: - * - AConfiguration_new() - * - AConfiguration_fromAssetManager() - */ -typedef struct AConfiguration AConfiguration; - - -/** - * Define flags and constants for various subsystem configurations. - */ -enum { - /** Orientation: not specified. */ - ACONFIGURATION_ORIENTATION_ANY = 0x0000, - /** - * Orientation: value corresponding to the - * port - * resource qualifier. - */ - ACONFIGURATION_ORIENTATION_PORT = 0x0001, - /** - * Orientation: value corresponding to the - * land - * resource qualifier. - */ - ACONFIGURATION_ORIENTATION_LAND = 0x0002, - /** @deprecated Not currently supported or used. */ - ACONFIGURATION_ORIENTATION_SQUARE = 0x0003, - - /** Touchscreen: not specified. */ - ACONFIGURATION_TOUCHSCREEN_ANY = 0x0000, - /** - * Touchscreen: value corresponding to the - * notouch - * resource qualifier. - */ - ACONFIGURATION_TOUCHSCREEN_NOTOUCH = 0x0001, - /** @deprecated Not currently supported or used. */ - ACONFIGURATION_TOUCHSCREEN_STYLUS = 0x0002, - /** - * Touchscreen: value corresponding to the - * finger - * resource qualifier. - */ - ACONFIGURATION_TOUCHSCREEN_FINGER = 0x0003, - - /** Density: default density. */ - ACONFIGURATION_DENSITY_DEFAULT = 0, - /** - * Density: value corresponding to the - * ldpi - * resource qualifier. - */ - ACONFIGURATION_DENSITY_LOW = 120, - /** - * Density: value corresponding to the - * mdpi - * resource qualifier. - */ - ACONFIGURATION_DENSITY_MEDIUM = 160, - /** - * Density: value corresponding to the - * tvdpi - * resource qualifier. - */ - ACONFIGURATION_DENSITY_TV = 213, - /** - * Density: value corresponding to the - * hdpi - * resource qualifier. - */ - ACONFIGURATION_DENSITY_HIGH = 240, - /** - * Density: value corresponding to the - * xhdpi - * resource qualifier. - */ - ACONFIGURATION_DENSITY_XHIGH = 320, - /** - * Density: value corresponding to the - * xxhdpi - * resource qualifier. - */ - ACONFIGURATION_DENSITY_XXHIGH = 480, - /** - * Density: value corresponding to the - * xxxhdpi - * resource qualifier. - */ - ACONFIGURATION_DENSITY_XXXHIGH = 640, - /** Density: any density. */ - ACONFIGURATION_DENSITY_ANY = 0xfffe, - /** Density: no density specified. */ - ACONFIGURATION_DENSITY_NONE = 0xffff, - - /** Keyboard: not specified. */ - ACONFIGURATION_KEYBOARD_ANY = 0x0000, - /** - * Keyboard: value corresponding to the - * nokeys - * resource qualifier. - */ - ACONFIGURATION_KEYBOARD_NOKEYS = 0x0001, - /** - * Keyboard: value corresponding to the - * qwerty - * resource qualifier. - */ - ACONFIGURATION_KEYBOARD_QWERTY = 0x0002, - /** - * Keyboard: value corresponding to the - * 12key - * resource qualifier. - */ - ACONFIGURATION_KEYBOARD_12KEY = 0x0003, - - /** Navigation: not specified. */ - ACONFIGURATION_NAVIGATION_ANY = 0x0000, - /** - * Navigation: value corresponding to the - * nonav - * resource qualifier. - */ - ACONFIGURATION_NAVIGATION_NONAV = 0x0001, - /** - * Navigation: value corresponding to the - * dpad - * resource qualifier. - */ - ACONFIGURATION_NAVIGATION_DPAD = 0x0002, - /** - * Navigation: value corresponding to the - * trackball - * resource qualifier. - */ - ACONFIGURATION_NAVIGATION_TRACKBALL = 0x0003, - /** - * Navigation: value corresponding to the - * wheel - * resource qualifier. - */ - ACONFIGURATION_NAVIGATION_WHEEL = 0x0004, - - /** Keyboard availability: not specified. */ - ACONFIGURATION_KEYSHIDDEN_ANY = 0x0000, - /** - * Keyboard availability: value corresponding to the - * keysexposed - * resource qualifier. - */ - ACONFIGURATION_KEYSHIDDEN_NO = 0x0001, - /** - * Keyboard availability: value corresponding to the - * keyshidden - * resource qualifier. - */ - ACONFIGURATION_KEYSHIDDEN_YES = 0x0002, - /** - * Keyboard availability: value corresponding to the - * keyssoft - * resource qualifier. - */ - ACONFIGURATION_KEYSHIDDEN_SOFT = 0x0003, - - /** Navigation availability: not specified. */ - ACONFIGURATION_NAVHIDDEN_ANY = 0x0000, - /** - * Navigation availability: value corresponding to the - * navexposed - * resource qualifier. - */ - ACONFIGURATION_NAVHIDDEN_NO = 0x0001, - /** - * Navigation availability: value corresponding to the - * navhidden - * resource qualifier. - */ - ACONFIGURATION_NAVHIDDEN_YES = 0x0002, - - /** Screen size: not specified. */ - ACONFIGURATION_SCREENSIZE_ANY = 0x00, - /** - * Screen size: value indicating the screen is at least - * approximately 320x426 dp units, corresponding to the - * small - * resource qualifier. - */ - ACONFIGURATION_SCREENSIZE_SMALL = 0x01, - /** - * Screen size: value indicating the screen is at least - * approximately 320x470 dp units, corresponding to the - * normal - * resource qualifier. - */ - ACONFIGURATION_SCREENSIZE_NORMAL = 0x02, - /** - * Screen size: value indicating the screen is at least - * approximately 480x640 dp units, corresponding to the - * large - * resource qualifier. - */ - ACONFIGURATION_SCREENSIZE_LARGE = 0x03, - /** - * Screen size: value indicating the screen is at least - * approximately 720x960 dp units, corresponding to the - * xlarge - * resource qualifier. - */ - ACONFIGURATION_SCREENSIZE_XLARGE = 0x04, - - /** Screen layout: not specified. */ - ACONFIGURATION_SCREENLONG_ANY = 0x00, - /** - * Screen layout: value that corresponds to the - * notlong - * resource qualifier. - */ - ACONFIGURATION_SCREENLONG_NO = 0x1, - /** - * Screen layout: value that corresponds to the - * long - * resource qualifier. - */ - ACONFIGURATION_SCREENLONG_YES = 0x2, - - ACONFIGURATION_SCREENROUND_ANY = 0x00, - ACONFIGURATION_SCREENROUND_NO = 0x1, - ACONFIGURATION_SCREENROUND_YES = 0x2, - - /** UI mode: not specified. */ - ACONFIGURATION_UI_MODE_TYPE_ANY = 0x00, - /** - * UI mode: value that corresponds to - * no - * UI mode type resource qualifier specified. - */ - ACONFIGURATION_UI_MODE_TYPE_NORMAL = 0x01, - /** - * UI mode: value that corresponds to - * desk resource qualifier specified. - */ - ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02, - /** - * UI mode: value that corresponds to - * car resource qualifier specified. - */ - ACONFIGURATION_UI_MODE_TYPE_CAR = 0x03, - /** - * UI mode: value that corresponds to - * television resource qualifier specified. - */ - ACONFIGURATION_UI_MODE_TYPE_TELEVISION = 0x04, - /** - * UI mode: value that corresponds to - * appliance resource qualifier specified. - */ - ACONFIGURATION_UI_MODE_TYPE_APPLIANCE = 0x05, - /** - * UI mode: value that corresponds to - * watch resource qualifier specified. - */ - ACONFIGURATION_UI_MODE_TYPE_WATCH = 0x06, - - /** UI night mode: not specified.*/ - ACONFIGURATION_UI_MODE_NIGHT_ANY = 0x00, - /** - * UI night mode: value that corresponds to - * notnight resource qualifier specified. - */ - ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1, - /** - * UI night mode: value that corresponds to - * night resource qualifier specified. - */ - ACONFIGURATION_UI_MODE_NIGHT_YES = 0x2, - - /** Screen width DPI: not specified. */ - ACONFIGURATION_SCREEN_WIDTH_DP_ANY = 0x0000, - - /** Screen height DPI: not specified. */ - ACONFIGURATION_SCREEN_HEIGHT_DP_ANY = 0x0000, - - /** Smallest screen width DPI: not specified.*/ - ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY = 0x0000, - - /** Layout direction: not specified. */ - ACONFIGURATION_LAYOUTDIR_ANY = 0x00, - /** - * Layout direction: value that corresponds to - * ldltr resource qualifier specified. - */ - ACONFIGURATION_LAYOUTDIR_LTR = 0x01, - /** - * Layout direction: value that corresponds to - * ldrtl resource qualifier specified. - */ - ACONFIGURATION_LAYOUTDIR_RTL = 0x02, - - /** - * Bit mask for - * mcc - * configuration. - */ - ACONFIGURATION_MCC = 0x0001, - /** - * Bit mask for - * mnc - * configuration. - */ - ACONFIGURATION_MNC = 0x0002, - /** - * Bit mask for - * locale - * configuration. - */ - ACONFIGURATION_LOCALE = 0x0004, - /** - * Bit mask for - * touchscreen - * configuration. - */ - ACONFIGURATION_TOUCHSCREEN = 0x0008, - /** - * Bit mask for - * keyboard - * configuration. - */ - ACONFIGURATION_KEYBOARD = 0x0010, - /** - * Bit mask for - * keyboardHidden - * configuration. - */ - ACONFIGURATION_KEYBOARD_HIDDEN = 0x0020, - /** - * Bit mask for - * navigation - * configuration. - */ - ACONFIGURATION_NAVIGATION = 0x0040, - /** - * Bit mask for - * orientation - * configuration. - */ - ACONFIGURATION_ORIENTATION = 0x0080, - /** - * Bit mask for - * density - * configuration. - */ - ACONFIGURATION_DENSITY = 0x0100, - /** - * Bit mask for - * screen size - * configuration. - */ - ACONFIGURATION_SCREEN_SIZE = 0x0200, - /** - * Bit mask for - * platform version - * configuration. - */ - ACONFIGURATION_VERSION = 0x0400, - /** - * Bit mask for screen layout configuration. - */ - ACONFIGURATION_SCREEN_LAYOUT = 0x0800, - /** - * Bit mask for - * ui mode - * configuration. - */ - ACONFIGURATION_UI_MODE = 0x1000, - /** - * Bit mask for - * smallest screen width - * configuration. - */ - ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000, - /** - * Bit mask for - * layout direction - * configuration. - */ - ACONFIGURATION_LAYOUTDIR = 0x4000, - ACONFIGURATION_SCREEN_ROUND = 0x8000, - /** - * Constant used to to represent MNC (Mobile Network Code) zero. - * 0 cannot be used, since it is used to represent an undefined MNC. - */ - ACONFIGURATION_MNC_ZERO = 0xffff, -}; - -/** - * Create a new AConfiguration, initialized with no values set. - */ -AConfiguration* AConfiguration_new(); - -/** - * Free an AConfiguration that was previously created with - * AConfiguration_new(). - */ -void AConfiguration_delete(AConfiguration* config); - -/** - * Create and return a new AConfiguration based on the current configuration in - * use in the given {@link AAssetManager}. - */ -void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am); - -/** - * Copy the contents of 'src' to 'dest'. - */ -void AConfiguration_copy(AConfiguration* dest, AConfiguration* src); - -/** - * Return the current MCC set in the configuration. 0 if not set. - */ -int32_t AConfiguration_getMcc(AConfiguration* config); - -/** - * Set the current MCC in the configuration. 0 to clear. - */ -void AConfiguration_setMcc(AConfiguration* config, int32_t mcc); - -/** - * Return the current MNC set in the configuration. 0 if not set. - */ -int32_t AConfiguration_getMnc(AConfiguration* config); - -/** - * Set the current MNC in the configuration. 0 to clear. - */ -void AConfiguration_setMnc(AConfiguration* config, int32_t mnc); - -/** - * Return the current language code set in the configuration. The output will - * be filled with an array of two characters. They are not 0-terminated. If - * a language is not set, they will be 0. - */ -void AConfiguration_getLanguage(AConfiguration* config, char* outLanguage); - -/** - * Set the current language code in the configuration, from the first two - * characters in the string. - */ -void AConfiguration_setLanguage(AConfiguration* config, const char* language); - -/** - * Return the current country code set in the configuration. The output will - * be filled with an array of two characters. They are not 0-terminated. If - * a country is not set, they will be 0. - */ -void AConfiguration_getCountry(AConfiguration* config, char* outCountry); - -/** - * Set the current country code in the configuration, from the first two - * characters in the string. - */ -void AConfiguration_setCountry(AConfiguration* config, const char* country); - -/** - * Return the current ACONFIGURATION_ORIENTATION_* set in the configuration. - */ -int32_t AConfiguration_getOrientation(AConfiguration* config); - -/** - * Set the current orientation in the configuration. - */ -void AConfiguration_setOrientation(AConfiguration* config, int32_t orientation); - -/** - * Return the current ACONFIGURATION_TOUCHSCREEN_* set in the configuration. - */ -int32_t AConfiguration_getTouchscreen(AConfiguration* config); - -/** - * Set the current touchscreen in the configuration. - */ -void AConfiguration_setTouchscreen(AConfiguration* config, int32_t touchscreen); - -/** - * Return the current ACONFIGURATION_DENSITY_* set in the configuration. - */ -int32_t AConfiguration_getDensity(AConfiguration* config); - -/** - * Set the current density in the configuration. - */ -void AConfiguration_setDensity(AConfiguration* config, int32_t density); - -/** - * Return the current ACONFIGURATION_KEYBOARD_* set in the configuration. - */ -int32_t AConfiguration_getKeyboard(AConfiguration* config); - -/** - * Set the current keyboard in the configuration. - */ -void AConfiguration_setKeyboard(AConfiguration* config, int32_t keyboard); - -/** - * Return the current ACONFIGURATION_NAVIGATION_* set in the configuration. - */ -int32_t AConfiguration_getNavigation(AConfiguration* config); - -/** - * Set the current navigation in the configuration. - */ -void AConfiguration_setNavigation(AConfiguration* config, int32_t navigation); - -/** - * Return the current ACONFIGURATION_KEYSHIDDEN_* set in the configuration. - */ -int32_t AConfiguration_getKeysHidden(AConfiguration* config); - -/** - * Set the current keys hidden in the configuration. - */ -void AConfiguration_setKeysHidden(AConfiguration* config, int32_t keysHidden); - -/** - * Return the current ACONFIGURATION_NAVHIDDEN_* set in the configuration. - */ -int32_t AConfiguration_getNavHidden(AConfiguration* config); - -/** - * Set the current nav hidden in the configuration. - */ -void AConfiguration_setNavHidden(AConfiguration* config, int32_t navHidden); - -/** - * Return the current SDK (API) version set in the configuration. - */ -int32_t AConfiguration_getSdkVersion(AConfiguration* config); - -/** - * Set the current SDK version in the configuration. - */ -void AConfiguration_setSdkVersion(AConfiguration* config, int32_t sdkVersion); - -/** - * Return the current ACONFIGURATION_SCREENSIZE_* set in the configuration. - */ -int32_t AConfiguration_getScreenSize(AConfiguration* config); - -/** - * Set the current screen size in the configuration. - */ -void AConfiguration_setScreenSize(AConfiguration* config, int32_t screenSize); - -/** - * Return the current ACONFIGURATION_SCREENLONG_* set in the configuration. - */ -int32_t AConfiguration_getScreenLong(AConfiguration* config); - -/** - * Set the current screen long in the configuration. - */ -void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong); - -/** - * Return the current ACONFIGURATION_SCREENROUND_* set in the configuration. - */ -int32_t AConfiguration_getScreenRound(AConfiguration* config); - -/** - * Set the current screen round in the configuration. - */ -void AConfiguration_setScreenRound(AConfiguration* config, int32_t screenRound); - -/** - * Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration. - */ -int32_t AConfiguration_getUiModeType(AConfiguration* config); - -/** - * Set the current UI mode type in the configuration. - */ -void AConfiguration_setUiModeType(AConfiguration* config, int32_t uiModeType); - -/** - * Return the current ACONFIGURATION_UI_MODE_NIGHT_* set in the configuration. - */ -int32_t AConfiguration_getUiModeNight(AConfiguration* config); - -/** - * Set the current UI mode night in the configuration. - */ -void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight); - -/** - * Return the current configuration screen width in dp units, or - * ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set. - */ -int32_t AConfiguration_getScreenWidthDp(AConfiguration* config); - -/** - * Set the configuration's current screen width in dp units. - */ -void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value); - -/** - * Return the current configuration screen height in dp units, or - * ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set. - */ -int32_t AConfiguration_getScreenHeightDp(AConfiguration* config); - -/** - * Set the configuration's current screen width in dp units. - */ -void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value); - -/** - * Return the configuration's smallest screen width in dp units, or - * ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set. - */ -int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config); - -/** - * Set the configuration's smallest screen width in dp units. - */ -void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value); - -/** - * Return the configuration's layout direction, or - * ACONFIGURATION_LAYOUTDIR_ANY if not set. - */ -int32_t AConfiguration_getLayoutDirection(AConfiguration* config); - -/** - * Set the configuration's layout direction. - */ -void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value); - -/** - * Perform a diff between two configurations. Returns a bit mask of - * ACONFIGURATION_* constants, each bit set meaning that configuration element - * is different between them. - */ -int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2); - -/** - * Determine whether 'base' is a valid configuration for use within the - * environment 'requested'. Returns 0 if there are any values in 'base' - * that conflict with 'requested'. Returns 1 if it does not conflict. - */ -int32_t AConfiguration_match(AConfiguration* base, AConfiguration* requested); - -/** - * Determine whether the configuration in 'test' is better than the existing - * configuration in 'base'. If 'requested' is non-NULL, this decision is based - * on the overall configuration given there. If it is NULL, this decision is - * simply based on which configuration is more specific. Returns non-0 if - * 'test' is better than 'base'. - * - * This assumes you have already filtered the configurations with - * AConfiguration_match(). - */ -int32_t AConfiguration_isBetterThan(AConfiguration* base, AConfiguration* test, - AConfiguration* requested); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_CONFIGURATION_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/input.h b/third_party/android_frameworks_native/include/android/input.h deleted file mode 100644 index 46cf89c7e1..0000000000 --- a/third_party/android_frameworks_native/include/android/input.h +++ /dev/null @@ -1,1317 +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. - */ - -/** - * @addtogroup Input - * @{ - */ - -/** - * @file input.h - */ - -#ifndef _ANDROID_INPUT_H -#define _ANDROID_INPUT_H - -/****************************************************************** - * - * IMPORTANT NOTICE: - * - * This file is part of Android's set of stable system headers - * exposed by the Android NDK (Native Development Kit). - * - * Third-party source AND binary code relies on the definitions - * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. - * - * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) - * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS - * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY - * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES - */ - -/* - * Structures and functions to receive and process input events in - * native code. - * - * NOTE: These functions MUST be implemented by /system/lib/libui.so - */ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Key states (may be returned by queries about the current state of a - * particular key code, scan code or switch). - */ -enum { - /** The key state is unknown or the requested key itself is not supported. */ - AKEY_STATE_UNKNOWN = -1, - - /** The key is up. */ - AKEY_STATE_UP = 0, - - /** The key is down. */ - AKEY_STATE_DOWN = 1, - - /** The key is down but is a virtual key press that is being emulated by the system. */ - AKEY_STATE_VIRTUAL = 2 -}; - -/** - * Meta key / modifer state. - */ -enum { - /** No meta keys are pressed. */ - AMETA_NONE = 0, - - /** This mask is used to check whether one of the ALT meta keys is pressed. */ - AMETA_ALT_ON = 0x02, - - /** This mask is used to check whether the left ALT meta key is pressed. */ - AMETA_ALT_LEFT_ON = 0x10, - - /** This mask is used to check whether the right ALT meta key is pressed. */ - AMETA_ALT_RIGHT_ON = 0x20, - - /** This mask is used to check whether one of the SHIFT meta keys is pressed. */ - AMETA_SHIFT_ON = 0x01, - - /** This mask is used to check whether the left SHIFT meta key is pressed. */ - AMETA_SHIFT_LEFT_ON = 0x40, - - /** This mask is used to check whether the right SHIFT meta key is pressed. */ - AMETA_SHIFT_RIGHT_ON = 0x80, - - /** This mask is used to check whether the SYM meta key is pressed. */ - AMETA_SYM_ON = 0x04, - - /** This mask is used to check whether the FUNCTION meta key is pressed. */ - AMETA_FUNCTION_ON = 0x08, - - /** This mask is used to check whether one of the CTRL meta keys is pressed. */ - AMETA_CTRL_ON = 0x1000, - - /** This mask is used to check whether the left CTRL meta key is pressed. */ - AMETA_CTRL_LEFT_ON = 0x2000, - - /** This mask is used to check whether the right CTRL meta key is pressed. */ - AMETA_CTRL_RIGHT_ON = 0x4000, - - /** This mask is used to check whether one of the META meta keys is pressed. */ - AMETA_META_ON = 0x10000, - - /** This mask is used to check whether the left META meta key is pressed. */ - AMETA_META_LEFT_ON = 0x20000, - - /** This mask is used to check whether the right META meta key is pressed. */ - AMETA_META_RIGHT_ON = 0x40000, - - /** This mask is used to check whether the CAPS LOCK meta key is on. */ - AMETA_CAPS_LOCK_ON = 0x100000, - - /** This mask is used to check whether the NUM LOCK meta key is on. */ - AMETA_NUM_LOCK_ON = 0x200000, - - /** This mask is used to check whether the SCROLL LOCK meta key is on. */ - AMETA_SCROLL_LOCK_ON = 0x400000, -}; - -struct AInputEvent; -/** - * Input events. - * - * Input events are opaque structures. Use the provided accessors functions to - * read their properties. - */ -typedef struct AInputEvent AInputEvent; - -/** - * Input event types. - */ -enum { - /** Indicates that the input event is a key event. */ - AINPUT_EVENT_TYPE_KEY = 1, - - /** Indicates that the input event is a motion event. */ - AINPUT_EVENT_TYPE_MOTION = 2 -}; - -/** - * Key event actions. - */ -enum { - /** The key has been pressed down. */ - AKEY_EVENT_ACTION_DOWN = 0, - - /** The key has been released. */ - AKEY_EVENT_ACTION_UP = 1, - - /** - * Multiple duplicate key events have occurred in a row, or a - * complex string is being delivered. The repeat_count property - * of the key event contains the number of times the given key - * code should be executed. - */ - AKEY_EVENT_ACTION_MULTIPLE = 2 -}; - -/** - * Key event flags. - */ -enum { - /** This mask is set if the device woke because of this key event. */ - AKEY_EVENT_FLAG_WOKE_HERE = 0x1, - - /** This mask is set if the key event was generated by a software keyboard. */ - AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2, - - /** This mask is set if we don't want the key event to cause us to leave touch mode. */ - AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4, - - /** - * This mask is set if an event was known to come from a trusted - * part of the system. That is, the event is known to come from - * the user, and could not have been spoofed by a third party - * component. - */ - AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8, - - /** - * This mask is used for compatibility, to identify enter keys that are - * coming from an IME whose enter key has been auto-labelled "next" or - * "done". This allows TextView to dispatch these as normal enter keys - * for old applications, but still do the appropriate action when - * receiving them. - */ - AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10, - - /** - * When associated with up key events, this indicates that the key press - * has been canceled. Typically this is used with virtual touch screen - * keys, where the user can slide from the virtual key area on to the - * display: in that case, the application will receive a canceled up - * event and should not perform the action normally associated with the - * key. Note that for this to work, the application can not perform an - * action for a key until it receives an up or the long press timeout has - * expired. - */ - AKEY_EVENT_FLAG_CANCELED = 0x20, - - /** - * This key event was generated by a virtual (on-screen) hard key area. - * Typically this is an area of the touchscreen, outside of the regular - * display, dedicated to "hardware" buttons. - */ - AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40, - - /** - * This flag is set for the first key repeat that occurs after the - * long press timeout. - */ - AKEY_EVENT_FLAG_LONG_PRESS = 0x80, - - /** - * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long - * press action was executed while it was down. - */ - AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100, - - /** - * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being - * tracked from its initial down. That is, somebody requested that tracking - * started on the key down and a long press has not caused - * the tracking to be canceled. - */ - AKEY_EVENT_FLAG_TRACKING = 0x200, - - /** - * Set when a key event has been synthesized to implement default behavior - * for an event that the application did not handle. - * Fallback key events are generated by unhandled trackball motions - * (to emulate a directional keypad) and by certain unhandled key presses - * that are declared in the key map (such as special function numeric keypad - * keys when numlock is off). - */ - AKEY_EVENT_FLAG_FALLBACK = 0x400, -}; - -/** - * Bit shift for the action bits holding the pointer index as - * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK. - */ -#define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 - -/** Motion event actions */ -enum { - /** Bit mask of the parts of the action code that are the action itself. */ - AMOTION_EVENT_ACTION_MASK = 0xff, - - /** - * Bits in the action code that represent a pointer index, used with - * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting - * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer - * index where the data for the pointer going up or down can be found. - */ - AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00, - - /** A pressed gesture has started, the motion contains the initial starting location. */ - AMOTION_EVENT_ACTION_DOWN = 0, - - /** - * A pressed gesture has finished, the motion contains the final release location - * as well as any intermediate points since the last down or move event. - */ - AMOTION_EVENT_ACTION_UP = 1, - - /** - * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and - * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as - * any intermediate points since the last down or move event. - */ - AMOTION_EVENT_ACTION_MOVE = 2, - - /** - * The current gesture has been aborted. - * You will not receive any more points in it. You should treat this as - * an up event, but not perform any action that you normally would. - */ - AMOTION_EVENT_ACTION_CANCEL = 3, - - /** - * A movement has happened outside of the normal bounds of the UI element. - * This does not provide a full gesture, but only the initial location of the movement/touch. - */ - AMOTION_EVENT_ACTION_OUTSIDE = 4, - - /** - * A non-primary pointer has gone down. - * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. - */ - AMOTION_EVENT_ACTION_POINTER_DOWN = 5, - - /** - * A non-primary pointer has gone up. - * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. - */ - AMOTION_EVENT_ACTION_POINTER_UP = 6, - - /** - * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE). - * The motion contains the most recent point, as well as any intermediate points since - * the last hover move event. - */ - AMOTION_EVENT_ACTION_HOVER_MOVE = 7, - - /** - * The motion event contains relative vertical and/or horizontal scroll offsets. - * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL - * and AMOTION_EVENT_AXIS_HSCROLL. - * The pointer may or may not be down when this event is dispatched. - * This action is always delivered to the winder under the pointer, which - * may not be the window currently touched. - */ - AMOTION_EVENT_ACTION_SCROLL = 8, - - /** The pointer is not down but has entered the boundaries of a window or view. */ - AMOTION_EVENT_ACTION_HOVER_ENTER = 9, - - /** The pointer is not down but has exited the boundaries of a window or view. */ - AMOTION_EVENT_ACTION_HOVER_EXIT = 10, - - /* One or more buttons have been pressed. */ - AMOTION_EVENT_ACTION_BUTTON_PRESS = 11, - - /* One or more buttons have been released. */ - AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12, -}; - -/** - * Motion event flags. - */ -enum { - /** - * This flag indicates that the window that received this motion event is partly - * or wholly obscured by another visible window above it. This flag is set to true - * even if the event did not directly pass through the obscured area. - * A security sensitive application can check this flag to identify situations in which - * a malicious application may have covered up part of its content for the purpose - * of misleading the user or hijacking touches. An appropriate response might be - * to drop the suspect touches or to take additional precautions to confirm the user's - * actual intent. - */ - AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1, -}; - -/** - * Motion event edge touch flags. - */ -enum { - /** No edges intersected. */ - AMOTION_EVENT_EDGE_FLAG_NONE = 0, - - /** Flag indicating the motion event intersected the top edge of the screen. */ - AMOTION_EVENT_EDGE_FLAG_TOP = 0x01, - - /** Flag indicating the motion event intersected the bottom edge of the screen. */ - AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02, - - /** Flag indicating the motion event intersected the left edge of the screen. */ - AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04, - - /** Flag indicating the motion event intersected the right edge of the screen. */ - AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08 -}; - -/** - * Constants that identify each individual axis of a motion event. - * @anchor AMOTION_EVENT_AXIS - */ -enum { - /** - * Axis constant: X axis of a motion event. - * - * - For a touch screen, reports the absolute X screen position of the center of - * the touch contact area. The units are display pixels. - * - For a touch pad, reports the absolute X surface position of the center of the touch - * contact area. The units are device-dependent. - * - For a mouse, reports the absolute X screen position of the mouse pointer. - * The units are display pixels. - * - For a trackball, reports the relative horizontal displacement of the trackball. - * The value is normalized to a range from -1.0 (left) to 1.0 (right). - * - For a joystick, reports the absolute X position of the joystick. - * The value is normalized to a range from -1.0 (left) to 1.0 (right). - */ - AMOTION_EVENT_AXIS_X = 0, - /** - * Axis constant: Y axis of a motion event. - * - * - For a touch screen, reports the absolute Y screen position of the center of - * the touch contact area. The units are display pixels. - * - For a touch pad, reports the absolute Y surface position of the center of the touch - * contact area. The units are device-dependent. - * - For a mouse, reports the absolute Y screen position of the mouse pointer. - * The units are display pixels. - * - For a trackball, reports the relative vertical displacement of the trackball. - * The value is normalized to a range from -1.0 (up) to 1.0 (down). - * - For a joystick, reports the absolute Y position of the joystick. - * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near). - */ - AMOTION_EVENT_AXIS_Y = 1, - /** - * Axis constant: Pressure axis of a motion event. - * - * - For a touch screen or touch pad, reports the approximate pressure applied to the surface - * by a finger or other tool. The value is normalized to a range from - * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1 - * may be generated depending on the calibration of the input device. - * - For a trackball, the value is set to 1 if the trackball button is pressed - * or 0 otherwise. - * - For a mouse, the value is set to 1 if the primary mouse button is pressed - * or 0 otherwise. - */ - AMOTION_EVENT_AXIS_PRESSURE = 2, - /** - * Axis constant: Size axis of a motion event. - * - * - For a touch screen or touch pad, reports the approximate size of the contact area in - * relation to the maximum detectable size for the device. The value is normalized - * to a range from 0 (smallest detectable size) to 1 (largest detectable size), - * although it is not a linear scale. This value is of limited use. - * To obtain calibrated size information, see - * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}. - */ - AMOTION_EVENT_AXIS_SIZE = 3, - /** - * Axis constant: TouchMajor axis of a motion event. - * - * - For a touch screen, reports the length of the major axis of an ellipse that - * represents the touch area at the point of contact. - * The units are display pixels. - * - For a touch pad, reports the length of the major axis of an ellipse that - * represents the touch area at the point of contact. - * The units are device-dependent. - */ - AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4, - /** - * Axis constant: TouchMinor axis of a motion event. - * - * - For a touch screen, reports the length of the minor axis of an ellipse that - * represents the touch area at the point of contact. - * The units are display pixels. - * - For a touch pad, reports the length of the minor axis of an ellipse that - * represents the touch area at the point of contact. - * The units are device-dependent. - * - * When the touch is circular, the major and minor axis lengths will be equal to one another. - */ - AMOTION_EVENT_AXIS_TOUCH_MINOR = 5, - /** - * Axis constant: ToolMajor axis of a motion event. - * - * - For a touch screen, reports the length of the major axis of an ellipse that - * represents the size of the approaching finger or tool used to make contact. - * - For a touch pad, reports the length of the major axis of an ellipse that - * represents the size of the approaching finger or tool used to make contact. - * The units are device-dependent. - * - * When the touch is circular, the major and minor axis lengths will be equal to one another. - * - * The tool size may be larger than the touch size since the tool may not be fully - * in contact with the touch sensor. - */ - AMOTION_EVENT_AXIS_TOOL_MAJOR = 6, - /** - * Axis constant: ToolMinor axis of a motion event. - * - * - For a touch screen, reports the length of the minor axis of an ellipse that - * represents the size of the approaching finger or tool used to make contact. - * - For a touch pad, reports the length of the minor axis of an ellipse that - * represents the size of the approaching finger or tool used to make contact. - * The units are device-dependent. - * - * When the touch is circular, the major and minor axis lengths will be equal to one another. - * - * The tool size may be larger than the touch size since the tool may not be fully - * in contact with the touch sensor. - */ - AMOTION_EVENT_AXIS_TOOL_MINOR = 7, - /** - * Axis constant: Orientation axis of a motion event. - * - * - For a touch screen or touch pad, reports the orientation of the finger - * or tool in radians relative to the vertical plane of the device. - * An angle of 0 radians indicates that the major axis of contact is oriented - * upwards, is perfectly circular or is of unknown orientation. A positive angle - * indicates that the major axis of contact is oriented to the right. A negative angle - * indicates that the major axis of contact is oriented to the left. - * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians - * (finger pointing fully right). - * - For a stylus, the orientation indicates the direction in which the stylus - * is pointing in relation to the vertical axis of the current orientation of the screen. - * The range is from -PI radians to PI radians, where 0 is pointing up, - * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians - * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}. - */ - AMOTION_EVENT_AXIS_ORIENTATION = 8, - /** - * Axis constant: Vertical Scroll axis of a motion event. - * - * - For a mouse, reports the relative movement of the vertical scroll wheel. - * The value is normalized to a range from -1.0 (down) to 1.0 (up). - * - * This axis should be used to scroll views vertically. - */ - AMOTION_EVENT_AXIS_VSCROLL = 9, - /** - * Axis constant: Horizontal Scroll axis of a motion event. - * - * - For a mouse, reports the relative movement of the horizontal scroll wheel. - * The value is normalized to a range from -1.0 (left) to 1.0 (right). - * - * This axis should be used to scroll views horizontally. - */ - AMOTION_EVENT_AXIS_HSCROLL = 10, - /** - * Axis constant: Z axis of a motion event. - * - * - For a joystick, reports the absolute Z position of the joystick. - * The value is normalized to a range from -1.0 (high) to 1.0 (low). - * On game pads with two analog joysticks, this axis is often reinterpreted - * to report the absolute X position of the second joystick instead. - */ - AMOTION_EVENT_AXIS_Z = 11, - /** - * Axis constant: X Rotation axis of a motion event. - * - * - For a joystick, reports the absolute rotation angle about the X axis. - * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). - */ - AMOTION_EVENT_AXIS_RX = 12, - /** - * Axis constant: Y Rotation axis of a motion event. - * - * - For a joystick, reports the absolute rotation angle about the Y axis. - * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). - */ - AMOTION_EVENT_AXIS_RY = 13, - /** - * Axis constant: Z Rotation axis of a motion event. - * - * - For a joystick, reports the absolute rotation angle about the Z axis. - * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). - * On game pads with two analog joysticks, this axis is often reinterpreted - * to report the absolute Y position of the second joystick instead. - */ - AMOTION_EVENT_AXIS_RZ = 14, - /** - * Axis constant: Hat X axis of a motion event. - * - * - For a joystick, reports the absolute X position of the directional hat control. - * The value is normalized to a range from -1.0 (left) to 1.0 (right). - */ - AMOTION_EVENT_AXIS_HAT_X = 15, - /** - * Axis constant: Hat Y axis of a motion event. - * - * - For a joystick, reports the absolute Y position of the directional hat control. - * The value is normalized to a range from -1.0 (up) to 1.0 (down). - */ - AMOTION_EVENT_AXIS_HAT_Y = 16, - /** - * Axis constant: Left Trigger axis of a motion event. - * - * - For a joystick, reports the absolute position of the left trigger control. - * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). - */ - AMOTION_EVENT_AXIS_LTRIGGER = 17, - /** - * Axis constant: Right Trigger axis of a motion event. - * - * - For a joystick, reports the absolute position of the right trigger control. - * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). - */ - AMOTION_EVENT_AXIS_RTRIGGER = 18, - /** - * Axis constant: Throttle axis of a motion event. - * - * - For a joystick, reports the absolute position of the throttle control. - * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed). - */ - AMOTION_EVENT_AXIS_THROTTLE = 19, - /** - * Axis constant: Rudder axis of a motion event. - * - * - For a joystick, reports the absolute position of the rudder control. - * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). - */ - AMOTION_EVENT_AXIS_RUDDER = 20, - /** - * Axis constant: Wheel axis of a motion event. - * - * - For a joystick, reports the absolute position of the steering wheel control. - * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). - */ - AMOTION_EVENT_AXIS_WHEEL = 21, - /** - * Axis constant: Gas axis of a motion event. - * - * - For a joystick, reports the absolute position of the gas (accelerator) control. - * The value is normalized to a range from 0.0 (no acceleration) - * to 1.0 (maximum acceleration). - */ - AMOTION_EVENT_AXIS_GAS = 22, - /** - * Axis constant: Brake axis of a motion event. - * - * - For a joystick, reports the absolute position of the brake control. - * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking). - */ - AMOTION_EVENT_AXIS_BRAKE = 23, - /** - * Axis constant: Distance axis of a motion event. - * - * - For a stylus, reports the distance of the stylus from the screen. - * A value of 0.0 indicates direct contact and larger values indicate increasing - * distance from the surface. - */ - AMOTION_EVENT_AXIS_DISTANCE = 24, - /** - * Axis constant: Tilt axis of a motion event. - * - * - For a stylus, reports the tilt angle of the stylus in radians where - * 0 radians indicates that the stylus is being held perpendicular to the - * surface, and PI/2 radians indicates that the stylus is being held flat - * against the surface. - */ - AMOTION_EVENT_AXIS_TILT = 25, - /** - * Axis constant: Generic 1 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_1 = 32, - /** - * Axis constant: Generic 2 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_2 = 33, - /** - * Axis constant: Generic 3 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_3 = 34, - /** - * Axis constant: Generic 4 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_4 = 35, - /** - * Axis constant: Generic 5 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_5 = 36, - /** - * Axis constant: Generic 6 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_6 = 37, - /** - * Axis constant: Generic 7 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_7 = 38, - /** - * Axis constant: Generic 8 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_8 = 39, - /** - * Axis constant: Generic 9 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_9 = 40, - /** - * Axis constant: Generic 10 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_10 = 41, - /** - * Axis constant: Generic 11 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_11 = 42, - /** - * Axis constant: Generic 12 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_12 = 43, - /** - * Axis constant: Generic 13 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_13 = 44, - /** - * Axis constant: Generic 14 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_14 = 45, - /** - * Axis constant: Generic 15 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_15 = 46, - /** - * Axis constant: Generic 16 axis of a motion event. - * The interpretation of a generic axis is device-specific. - */ - AMOTION_EVENT_AXIS_GENERIC_16 = 47, - - // NOTE: If you add a new axis here you must also add it to several other files. - // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. -}; - -/** - * Constants that identify buttons that are associated with motion events. - * Refer to the documentation on the MotionEvent class for descriptions of each button. - */ -enum { - /** primary */ - AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0, - /** secondary */ - AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1, - /** tertiary */ - AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2, - /** back */ - AMOTION_EVENT_BUTTON_BACK = 1 << 3, - /** forward */ - AMOTION_EVENT_BUTTON_FORWARD = 1 << 4, - AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5, - AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6, -}; - -/** - * Constants that identify tool types. - * Refer to the documentation on the MotionEvent class for descriptions of each tool type. - */ -enum { - /** unknown */ - AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0, - /** finger */ - AMOTION_EVENT_TOOL_TYPE_FINGER = 1, - /** stylus */ - AMOTION_EVENT_TOOL_TYPE_STYLUS = 2, - /** mouse */ - AMOTION_EVENT_TOOL_TYPE_MOUSE = 3, - /** eraser */ - AMOTION_EVENT_TOOL_TYPE_ERASER = 4, -}; - -/** - * Input source masks. - * - * Refer to the documentation on android.view.InputDevice for more details about input sources - * and their correct interpretation. - */ -enum { - /** mask */ - AINPUT_SOURCE_CLASS_MASK = 0x000000ff, - - /** none */ - AINPUT_SOURCE_CLASS_NONE = 0x00000000, - /** button */ - AINPUT_SOURCE_CLASS_BUTTON = 0x00000001, - /** pointer */ - AINPUT_SOURCE_CLASS_POINTER = 0x00000002, - /** navigation */ - AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004, - /** position */ - AINPUT_SOURCE_CLASS_POSITION = 0x00000008, - /** joystick */ - AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010, -}; - -/** - * Input sources. - */ -enum { - /** unknown */ - AINPUT_SOURCE_UNKNOWN = 0x00000000, - - /** keyboard */ - AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON, - /** dpad */ - AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON, - /** gamepad */ - AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON, - /** touchscreen */ - AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, - /** mouse */ - AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, - /** stylus */ - AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER, - /** bluetooth stylus */ - AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS, - /** trackball */ - AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, - /** touchpad */ - AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, - /** navigation */ - AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, - /** gesture sensor (?) */ - AINPUT_SOURCE_GESTURE_SENSOR = 0x00400000 | AINPUT_SOURCE_CLASS_NONE, - /** joystick */ - AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, - - /** any */ - AINPUT_SOURCE_ANY = 0xffffff00, -}; - -/** - * Keyboard types. - * - * Refer to the documentation on android.view.InputDevice for more details. - */ -enum { - /** none */ - AINPUT_KEYBOARD_TYPE_NONE = 0, - /** non alphabetic */ - AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1, - /** alphabetic */ - AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2, -}; - -/** - * Constants used to retrieve information about the range of motion for a particular - * coordinate of a motion event. - * - * Refer to the documentation on android.view.InputDevice for more details about input sources - * and their correct interpretation. - * - * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead. - */ -enum { - /** x */ - AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X, - /** y */ - AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y, - /** pressure */ - AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE, - /** size */ - AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE, - /** touch major */ - AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR, - /** touch minor */ - AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR, - /** tool major */ - AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR, - /** tool minor */ - AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR, - /** orientation */ - AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION, -}; - - -/** - * Input event accessors. - * - * Note that most functions can only be used on input events that are of a given type. - * Calling these functions on input events of other types will yield undefined behavior. - */ - -/*** Accessors for all input events. ***/ - -/** Get the input event type. */ -int32_t AInputEvent_getType(const AInputEvent* event); - -/** Get the id for the device that an input event came from. - * - * Input events can be generated by multiple different input devices. - * Use the input device id to obtain information about the input - * device that was responsible for generating a particular event. - * - * An input device id of 0 indicates that the event didn't come from a physical device; - * other numbers are arbitrary and you shouldn't depend on the values. - * Use the provided input device query API to obtain information about input devices. - */ -int32_t AInputEvent_getDeviceId(const AInputEvent* event); - -/** Get the input event source. */ -int32_t AInputEvent_getSource(const AInputEvent* event); - -/*** Accessors for key events only. ***/ - -/** Get the key event action. */ -int32_t AKeyEvent_getAction(const AInputEvent* key_event); - -/** Get the key event flags. */ -int32_t AKeyEvent_getFlags(const AInputEvent* key_event); - -/** - * Get the key code of the key event. - * This is the physical key that was pressed, not the Unicode character. - */ -int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event); - -/** - * Get the hardware key id of this key event. - * These values are not reliable and vary from device to device. - */ -int32_t AKeyEvent_getScanCode(const AInputEvent* key_event); - -/** Get the meta key state. */ -int32_t AKeyEvent_getMetaState(const AInputEvent* key_event); - -/** - * Get the repeat count of the event. - * For both key up an key down events, this is the number of times the key has - * repeated with the first down starting at 0 and counting up from there. For - * multiple key events, this is the number of down/up pairs that have occurred. - */ -int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event); - -/** - * Get the time of the most recent key down event, in the - * java.lang.System.nanoTime() time base. If this is a down event, - * this will be the same as eventTime. - * Note that when chording keys, this value is the down time of the most recently - * pressed key, which may not be the same physical key of this event. - */ -int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); - -/** - * Get the time this event occurred, in the - * java.lang.System.nanoTime() time base. - */ -int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); - -/*** Accessors for motion events only. ***/ - -/** Get the combined motion event action code and pointer index. */ -int32_t AMotionEvent_getAction(const AInputEvent* motion_event); - -/** Get the motion event flags. */ -int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); - -/** - * Get the state of any meta / modifier keys that were in effect when the - * event was generated. - */ -int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); - -/** Get the button state of all buttons that are pressed. */ -int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event); - -/** - * Get a bitfield indicating which edges, if any, were touched by this motion event. - * For touch events, clients can use this to determine if the user's finger was - * touching the edge of the display. - */ -int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event); - -/** - * Get the time when the user originally pressed down to start a stream of - * position events, in the java.lang.System.nanoTime() time base. - */ -int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event); - -/** - * Get the time when this specific event was generated, - * in the java.lang.System.nanoTime() time base. - */ -int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event); - -/** - * Get the X coordinate offset. - * For touch events on the screen, this is the delta that was added to the raw - * screen coordinates to adjust for the absolute position of the containing windows - * and views. - */ -float AMotionEvent_getXOffset(const AInputEvent* motion_event); - -/** - * Get the Y coordinate offset. - * For touch events on the screen, this is the delta that was added to the raw - * screen coordinates to adjust for the absolute position of the containing windows - * and views. - */ -float AMotionEvent_getYOffset(const AInputEvent* motion_event); - -/** - * Get the precision of the X coordinates being reported. - * You can multiply this number with an X coordinate sample to find the - * actual hardware value of the X coordinate. - */ -float AMotionEvent_getXPrecision(const AInputEvent* motion_event); - -/** - * Get the precision of the Y coordinates being reported. - * You can multiply this number with a Y coordinate sample to find the - * actual hardware value of the Y coordinate. - */ -float AMotionEvent_getYPrecision(const AInputEvent* motion_event); - -/** - * Get the number of pointers of data contained in this event. - * Always >= 1. - */ -size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); - -/** - * Get the pointer identifier associated with a particular pointer - * data index in this event. The identifier tells you the actual pointer - * number associated with the data, accounting for individual pointers - * going up and down since the start of the current gesture. - */ -int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the tool type of a pointer for the given pointer index. - * The tool type indicates the type of tool used to make contact such as a - * finger or stylus, if known. - */ -int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the original raw X coordinate of this event. - * For touch events on the screen, this is the original location of the event - * on the screen, before it had been adjusted for the containing window - * and views. - */ -float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the original raw X coordinate of this event. - * For touch events on the screen, this is the original location of the event - * on the screen, before it had been adjusted for the containing window - * and views. - */ -float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current X coordinate of this event for the given pointer index. - * Whole numbers are pixels; the value may have a fraction for input devices - * that are sub-pixel precise. - */ -float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current Y coordinate of this event for the given pointer index. - * Whole numbers are pixels; the value may have a fraction for input devices - * that are sub-pixel precise. - */ -float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current pressure of this event for the given pointer index. - * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), - * although values higher than 1 may be generated depending on the calibration of - * the input device. - */ -float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current scaled value of the approximate size for the given pointer index. - * This represents some approximation of the area of the screen being - * pressed; the actual value in pixels corresponding to the - * touch is normalized with the device specific range of values - * and scaled to a value between 0 and 1. The value of size can be used to - * determine fat touch events. - */ -float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current length of the major axis of an ellipse that describes the touch area - * at the point of contact for the given pointer index. - */ -float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current length of the minor axis of an ellipse that describes the touch area - * at the point of contact for the given pointer index. - */ -float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current length of the major axis of an ellipse that describes the size - * of the approaching tool for the given pointer index. - * The tool area represents the estimated size of the finger or pen that is - * touching the device independent of its actual touch area at the point of contact. - */ -float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current length of the minor axis of an ellipse that describes the size - * of the approaching tool for the given pointer index. - * The tool area represents the estimated size of the finger or pen that is - * touching the device independent of its actual touch area at the point of contact. - */ -float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index); - -/** - * Get the current orientation of the touch area and tool area in radians clockwise from - * vertical for the given pointer index. - * An angle of 0 degrees indicates that the major axis of contact is oriented - * upwards, is perfectly circular or is of unknown orientation. A positive angle - * indicates that the major axis of contact is oriented to the right. A negative angle - * indicates that the major axis of contact is oriented to the left. - * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians - * (finger pointing fully right). - */ -float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); - -/** Get the value of the request axis for the given pointer index. */ -float AMotionEvent_getAxisValue(const AInputEvent* motion_event, - int32_t axis, size_t pointer_index); - -/** - * Get the number of historical points in this event. These are movements that - * have occurred between this event and the previous event. This only applies - * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0. - * Historical samples are indexed from oldest to newest. - */ -size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event); - -/** - * Get the time that a historical movement occurred between this event and - * the previous event, in the java.lang.System.nanoTime() time base. - */ -int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event, - size_t history_index); - -/** - * Get the historical raw X coordinate of this event for the given pointer index that - * occurred between this event and the previous motion event. - * For touch events on the screen, this is the original location of the event - * on the screen, before it had been adjusted for the containing window - * and views. - * Whole numbers are pixels; the value may have a fraction for input devices - * that are sub-pixel precise. - */ -float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical raw Y coordinate of this event for the given pointer index that - * occurred between this event and the previous motion event. - * For touch events on the screen, this is the original location of the event - * on the screen, before it had been adjusted for the containing window - * and views. - * Whole numbers are pixels; the value may have a fraction for input devices - * that are sub-pixel precise. - */ -float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical X coordinate of this event for the given pointer index that - * occurred between this event and the previous motion event. - * Whole numbers are pixels; the value may have a fraction for input devices - * that are sub-pixel precise. - */ -float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical Y coordinate of this event for the given pointer index that - * occurred between this event and the previous motion event. - * Whole numbers are pixels; the value may have a fraction for input devices - * that are sub-pixel precise. - */ -float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical pressure of this event for the given pointer index that - * occurred between this event and the previous motion event. - * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), - * although values higher than 1 may be generated depending on the calibration of - * the input device. - */ -float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the current scaled value of the approximate size for the given pointer index that - * occurred between this event and the previous motion event. - * This represents some approximation of the area of the screen being - * pressed; the actual value in pixels corresponding to the - * touch is normalized with the device specific range of values - * and scaled to a value between 0 and 1. The value of size can be used to - * determine fat touch events. - */ -float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical length of the major axis of an ellipse that describes the touch area - * at the point of contact for the given pointer index that - * occurred between this event and the previous motion event. - */ -float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical length of the minor axis of an ellipse that describes the touch area - * at the point of contact for the given pointer index that - * occurred between this event and the previous motion event. - */ -float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical length of the major axis of an ellipse that describes the size - * of the approaching tool for the given pointer index that - * occurred between this event and the previous motion event. - * The tool area represents the estimated size of the finger or pen that is - * touching the device independent of its actual touch area at the point of contact. - */ -float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical length of the minor axis of an ellipse that describes the size - * of the approaching tool for the given pointer index that - * occurred between this event and the previous motion event. - * The tool area represents the estimated size of the finger or pen that is - * touching the device independent of its actual touch area at the point of contact. - */ -float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical orientation of the touch area and tool area in radians clockwise from - * vertical for the given pointer index that - * occurred between this event and the previous motion event. - * An angle of 0 degrees indicates that the major axis of contact is oriented - * upwards, is perfectly circular or is of unknown orientation. A positive angle - * indicates that the major axis of contact is oriented to the right. A negative angle - * indicates that the major axis of contact is oriented to the left. - * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians - * (finger pointing fully right). - */ -float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, - size_t history_index); - -/** - * Get the historical value of the request axis for the given pointer index - * that occurred between this event and the previous motion event. - */ -float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, - int32_t axis, size_t pointer_index, size_t history_index); - - -struct AInputQueue; -/** - * Input queue - * - * An input queue is the facility through which you retrieve input - * events. - */ -typedef struct AInputQueue AInputQueue; - -/** - * Add this input queue to a looper for processing. See - * ALooper_addFd() for information on the ident, callback, and data params. - */ -void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, - int ident, ALooper_callbackFunc callback, void* data); - -/** - * Remove the input queue from the looper it is currently attached to. - */ -void AInputQueue_detachLooper(AInputQueue* queue); - -/** - * Returns true if there are one or more events available in the - * input queue. Returns 1 if the queue has events; 0 if - * it does not have events; and a negative value if there is an error. - */ -int32_t AInputQueue_hasEvents(AInputQueue* queue); - -/** - * Returns the next available event from the queue. Returns a negative - * value if no events are available or an error has occurred. - */ -int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent); - -/** - * Sends the key for standard pre-dispatching -- that is, possibly deliver - * it to the current IME to be consumed before the app. Returns 0 if it - * was not pre-dispatched, meaning you can process it right now. If non-zero - * is returned, you must abandon the current event processing and allow the - * event to appear again in the event queue (if it does not get consumed during - * pre-dispatching). - */ -int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event); - -/** - * Report that dispatching has finished with the given event. - * This must be called after receiving an event with AInputQueue_get_event(). - */ -void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled); - -#ifdef __cplusplus -} -#endif - -#endif // _ANDROID_INPUT_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/keycodes.h b/third_party/android_frameworks_native/include/android/keycodes.h deleted file mode 100644 index 421abe5477..0000000000 --- a/third_party/android_frameworks_native/include/android/keycodes.h +++ /dev/null @@ -1,752 +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. - */ - -/** - * @addtogroup Input - * @{ - */ - -/** - * @file keycodes.h - */ - -#ifndef _ANDROID_KEYCODES_H -#define _ANDROID_KEYCODES_H - -/****************************************************************** - * - * IMPORTANT NOTICE: - * - * This file is part of Android's set of stable system headers - * exposed by the Android NDK (Native Development Kit). - * - * Third-party source AND binary code relies on the definitions - * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. - * - * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) - * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS - * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY - * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Key codes. - */ -enum { - /** Unknown key code. */ - AKEYCODE_UNKNOWN = 0, - /** Soft Left key. - * Usually situated below the display on phones and used as a multi-function - * feature key for selecting a software defined function shown on the bottom left - * of the display. */ - AKEYCODE_SOFT_LEFT = 1, - /** Soft Right key. - * Usually situated below the display on phones and used as a multi-function - * feature key for selecting a software defined function shown on the bottom right - * of the display. */ - AKEYCODE_SOFT_RIGHT = 2, - /** Home key. - * This key is handled by the framework and is never delivered to applications. */ - AKEYCODE_HOME = 3, - /** Back key. */ - AKEYCODE_BACK = 4, - /** Call key. */ - AKEYCODE_CALL = 5, - /** End Call key. */ - AKEYCODE_ENDCALL = 6, - /** '0' key. */ - AKEYCODE_0 = 7, - /** '1' key. */ - AKEYCODE_1 = 8, - /** '2' key. */ - AKEYCODE_2 = 9, - /** '3' key. */ - AKEYCODE_3 = 10, - /** '4' key. */ - AKEYCODE_4 = 11, - /** '5' key. */ - AKEYCODE_5 = 12, - /** '6' key. */ - AKEYCODE_6 = 13, - /** '7' key. */ - AKEYCODE_7 = 14, - /** '8' key. */ - AKEYCODE_8 = 15, - /** '9' key. */ - AKEYCODE_9 = 16, - /** '*' key. */ - AKEYCODE_STAR = 17, - /** '#' key. */ - AKEYCODE_POUND = 18, - /** Directional Pad Up key. - * May also be synthesized from trackball motions. */ - AKEYCODE_DPAD_UP = 19, - /** Directional Pad Down key. - * May also be synthesized from trackball motions. */ - AKEYCODE_DPAD_DOWN = 20, - /** Directional Pad Left key. - * May also be synthesized from trackball motions. */ - AKEYCODE_DPAD_LEFT = 21, - /** Directional Pad Right key. - * May also be synthesized from trackball motions. */ - AKEYCODE_DPAD_RIGHT = 22, - /** Directional Pad Center key. - * May also be synthesized from trackball motions. */ - AKEYCODE_DPAD_CENTER = 23, - /** Volume Up key. - * Adjusts the speaker volume up. */ - AKEYCODE_VOLUME_UP = 24, - /** Volume Down key. - * Adjusts the speaker volume down. */ - AKEYCODE_VOLUME_DOWN = 25, - /** Power key. */ - AKEYCODE_POWER = 26, - /** Camera key. - * Used to launch a camera application or take pictures. */ - AKEYCODE_CAMERA = 27, - /** Clear key. */ - AKEYCODE_CLEAR = 28, - /** 'A' key. */ - AKEYCODE_A = 29, - /** 'B' key. */ - AKEYCODE_B = 30, - /** 'C' key. */ - AKEYCODE_C = 31, - /** 'D' key. */ - AKEYCODE_D = 32, - /** 'E' key. */ - AKEYCODE_E = 33, - /** 'F' key. */ - AKEYCODE_F = 34, - /** 'G' key. */ - AKEYCODE_G = 35, - /** 'H' key. */ - AKEYCODE_H = 36, - /** 'I' key. */ - AKEYCODE_I = 37, - /** 'J' key. */ - AKEYCODE_J = 38, - /** 'K' key. */ - AKEYCODE_K = 39, - /** 'L' key. */ - AKEYCODE_L = 40, - /** 'M' key. */ - AKEYCODE_M = 41, - /** 'N' key. */ - AKEYCODE_N = 42, - /** 'O' key. */ - AKEYCODE_O = 43, - /** 'P' key. */ - AKEYCODE_P = 44, - /** 'Q' key. */ - AKEYCODE_Q = 45, - /** 'R' key. */ - AKEYCODE_R = 46, - /** 'S' key. */ - AKEYCODE_S = 47, - /** 'T' key. */ - AKEYCODE_T = 48, - /** 'U' key. */ - AKEYCODE_U = 49, - /** 'V' key. */ - AKEYCODE_V = 50, - /** 'W' key. */ - AKEYCODE_W = 51, - /** 'X' key. */ - AKEYCODE_X = 52, - /** 'Y' key. */ - AKEYCODE_Y = 53, - /** 'Z' key. */ - AKEYCODE_Z = 54, - /** ',' key. */ - AKEYCODE_COMMA = 55, - /** '.' key. */ - AKEYCODE_PERIOD = 56, - /** Left Alt modifier key. */ - AKEYCODE_ALT_LEFT = 57, - /** Right Alt modifier key. */ - AKEYCODE_ALT_RIGHT = 58, - /** Left Shift modifier key. */ - AKEYCODE_SHIFT_LEFT = 59, - /** Right Shift modifier key. */ - AKEYCODE_SHIFT_RIGHT = 60, - /** Tab key. */ - AKEYCODE_TAB = 61, - /** Space key. */ - AKEYCODE_SPACE = 62, - /** Symbol modifier key. - * Used to enter alternate symbols. */ - AKEYCODE_SYM = 63, - /** Explorer special function key. - * Used to launch a browser application. */ - AKEYCODE_EXPLORER = 64, - /** Envelope special function key. - * Used to launch a mail application. */ - AKEYCODE_ENVELOPE = 65, - /** Enter key. */ - AKEYCODE_ENTER = 66, - /** Backspace key. - * Deletes characters before the insertion point, unlike {@link AKEYCODE_FORWARD_DEL}. */ - AKEYCODE_DEL = 67, - /** '`' (backtick) key. */ - AKEYCODE_GRAVE = 68, - /** '-'. */ - AKEYCODE_MINUS = 69, - /** '=' key. */ - AKEYCODE_EQUALS = 70, - /** '[' key. */ - AKEYCODE_LEFT_BRACKET = 71, - /** ']' key. */ - AKEYCODE_RIGHT_BRACKET = 72, - /** '\' key. */ - AKEYCODE_BACKSLASH = 73, - /** ';' key. */ - AKEYCODE_SEMICOLON = 74, - /** ''' (apostrophe) key. */ - AKEYCODE_APOSTROPHE = 75, - /** '/' key. */ - AKEYCODE_SLASH = 76, - /** '@' key. */ - AKEYCODE_AT = 77, - /** Number modifier key. - * Used to enter numeric symbols. - * This key is not {@link AKEYCODE_NUM_LOCK}; it is more like {@link AKEYCODE_ALT_LEFT}. */ - AKEYCODE_NUM = 78, - /** Headset Hook key. - * Used to hang up calls and stop media. */ - AKEYCODE_HEADSETHOOK = 79, - /** Camera Focus key. - * Used to focus the camera. */ - AKEYCODE_FOCUS = 80, - /** '+' key. */ - AKEYCODE_PLUS = 81, - /** Menu key. */ - AKEYCODE_MENU = 82, - /** Notification key. */ - AKEYCODE_NOTIFICATION = 83, - /** Search key. */ - AKEYCODE_SEARCH = 84, - /** Play/Pause media key. */ - AKEYCODE_MEDIA_PLAY_PAUSE= 85, - /** Stop media key. */ - AKEYCODE_MEDIA_STOP = 86, - /** Play Next media key. */ - AKEYCODE_MEDIA_NEXT = 87, - /** Play Previous media key. */ - AKEYCODE_MEDIA_PREVIOUS = 88, - /** Rewind media key. */ - AKEYCODE_MEDIA_REWIND = 89, - /** Fast Forward media key. */ - AKEYCODE_MEDIA_FAST_FORWARD = 90, - /** Mute key. - * Mutes the microphone, unlike {@link AKEYCODE_VOLUME_MUTE}. */ - AKEYCODE_MUTE = 91, - /** Page Up key. */ - AKEYCODE_PAGE_UP = 92, - /** Page Down key. */ - AKEYCODE_PAGE_DOWN = 93, - /** Picture Symbols modifier key. - * Used to switch symbol sets (Emoji, Kao-moji). */ - AKEYCODE_PICTSYMBOLS = 94, - /** Switch Charset modifier key. - * Used to switch character sets (Kanji, Katakana). */ - AKEYCODE_SWITCH_CHARSET = 95, - /** A Button key. - * On a game controller, the A button should be either the button labeled A - * or the first button on the bottom row of controller buttons. */ - AKEYCODE_BUTTON_A = 96, - /** B Button key. - * On a game controller, the B button should be either the button labeled B - * or the second button on the bottom row of controller buttons. */ - AKEYCODE_BUTTON_B = 97, - /** C Button key. - * On a game controller, the C button should be either the button labeled C - * or the third button on the bottom row of controller buttons. */ - AKEYCODE_BUTTON_C = 98, - /** X Button key. - * On a game controller, the X button should be either the button labeled X - * or the first button on the upper row of controller buttons. */ - AKEYCODE_BUTTON_X = 99, - /** Y Button key. - * On a game controller, the Y button should be either the button labeled Y - * or the second button on the upper row of controller buttons. */ - AKEYCODE_BUTTON_Y = 100, - /** Z Button key. - * On a game controller, the Z button should be either the button labeled Z - * or the third button on the upper row of controller buttons. */ - AKEYCODE_BUTTON_Z = 101, - /** L1 Button key. - * On a game controller, the L1 button should be either the button labeled L1 (or L) - * or the top left trigger button. */ - AKEYCODE_BUTTON_L1 = 102, - /** R1 Button key. - * On a game controller, the R1 button should be either the button labeled R1 (or R) - * or the top right trigger button. */ - AKEYCODE_BUTTON_R1 = 103, - /** L2 Button key. - * On a game controller, the L2 button should be either the button labeled L2 - * or the bottom left trigger button. */ - AKEYCODE_BUTTON_L2 = 104, - /** R2 Button key. - * On a game controller, the R2 button should be either the button labeled R2 - * or the bottom right trigger button. */ - AKEYCODE_BUTTON_R2 = 105, - /** Left Thumb Button key. - * On a game controller, the left thumb button indicates that the left (or only) - * joystick is pressed. */ - AKEYCODE_BUTTON_THUMBL = 106, - /** Right Thumb Button key. - * On a game controller, the right thumb button indicates that the right - * joystick is pressed. */ - AKEYCODE_BUTTON_THUMBR = 107, - /** Start Button key. - * On a game controller, the button labeled Start. */ - AKEYCODE_BUTTON_START = 108, - /** Select Button key. - * On a game controller, the button labeled Select. */ - AKEYCODE_BUTTON_SELECT = 109, - /** Mode Button key. - * On a game controller, the button labeled Mode. */ - AKEYCODE_BUTTON_MODE = 110, - /** Escape key. */ - AKEYCODE_ESCAPE = 111, - /** Forward Delete key. - * Deletes characters ahead of the insertion point, unlike {@link AKEYCODE_DEL}. */ - AKEYCODE_FORWARD_DEL = 112, - /** Left Control modifier key. */ - AKEYCODE_CTRL_LEFT = 113, - /** Right Control modifier key. */ - AKEYCODE_CTRL_RIGHT = 114, - /** Caps Lock key. */ - AKEYCODE_CAPS_LOCK = 115, - /** Scroll Lock key. */ - AKEYCODE_SCROLL_LOCK = 116, - /** Left Meta modifier key. */ - AKEYCODE_META_LEFT = 117, - /** Right Meta modifier key. */ - AKEYCODE_META_RIGHT = 118, - /** Function modifier key. */ - AKEYCODE_FUNCTION = 119, - /** System Request / Print Screen key. */ - AKEYCODE_SYSRQ = 120, - /** Break / Pause key. */ - AKEYCODE_BREAK = 121, - /** Home Movement key. - * Used for scrolling or moving the cursor around to the start of a line - * or to the top of a list. */ - AKEYCODE_MOVE_HOME = 122, - /** End Movement key. - * Used for scrolling or moving the cursor around to the end of a line - * or to the bottom of a list. */ - AKEYCODE_MOVE_END = 123, - /** Insert key. - * Toggles insert / overwrite edit mode. */ - AKEYCODE_INSERT = 124, - /** Forward key. - * Navigates forward in the history stack. Complement of {@link AKEYCODE_BACK}. */ - AKEYCODE_FORWARD = 125, - /** Play media key. */ - AKEYCODE_MEDIA_PLAY = 126, - /** Pause media key. */ - AKEYCODE_MEDIA_PAUSE = 127, - /** Close media key. - * May be used to close a CD tray, for example. */ - AKEYCODE_MEDIA_CLOSE = 128, - /** Eject media key. - * May be used to eject a CD tray, for example. */ - AKEYCODE_MEDIA_EJECT = 129, - /** Record media key. */ - AKEYCODE_MEDIA_RECORD = 130, - /** F1 key. */ - AKEYCODE_F1 = 131, - /** F2 key. */ - AKEYCODE_F2 = 132, - /** F3 key. */ - AKEYCODE_F3 = 133, - /** F4 key. */ - AKEYCODE_F4 = 134, - /** F5 key. */ - AKEYCODE_F5 = 135, - /** F6 key. */ - AKEYCODE_F6 = 136, - /** F7 key. */ - AKEYCODE_F7 = 137, - /** F8 key. */ - AKEYCODE_F8 = 138, - /** F9 key. */ - AKEYCODE_F9 = 139, - /** F10 key. */ - AKEYCODE_F10 = 140, - /** F11 key. */ - AKEYCODE_F11 = 141, - /** F12 key. */ - AKEYCODE_F12 = 142, - /** Num Lock key. - * This is the Num Lock key; it is different from {@link AKEYCODE_NUM}. - * This key alters the behavior of other keys on the numeric keypad. */ - AKEYCODE_NUM_LOCK = 143, - /** Numeric keypad '0' key. */ - AKEYCODE_NUMPAD_0 = 144, - /** Numeric keypad '1' key. */ - AKEYCODE_NUMPAD_1 = 145, - /** Numeric keypad '2' key. */ - AKEYCODE_NUMPAD_2 = 146, - /** Numeric keypad '3' key. */ - AKEYCODE_NUMPAD_3 = 147, - /** Numeric keypad '4' key. */ - AKEYCODE_NUMPAD_4 = 148, - /** Numeric keypad '5' key. */ - AKEYCODE_NUMPAD_5 = 149, - /** Numeric keypad '6' key. */ - AKEYCODE_NUMPAD_6 = 150, - /** Numeric keypad '7' key. */ - AKEYCODE_NUMPAD_7 = 151, - /** Numeric keypad '8' key. */ - AKEYCODE_NUMPAD_8 = 152, - /** Numeric keypad '9' key. */ - AKEYCODE_NUMPAD_9 = 153, - /** Numeric keypad '/' key (for division). */ - AKEYCODE_NUMPAD_DIVIDE = 154, - /** Numeric keypad '*' key (for multiplication). */ - AKEYCODE_NUMPAD_MULTIPLY = 155, - /** Numeric keypad '-' key (for subtraction). */ - AKEYCODE_NUMPAD_SUBTRACT = 156, - /** Numeric keypad '+' key (for addition). */ - AKEYCODE_NUMPAD_ADD = 157, - /** Numeric keypad '.' key (for decimals or digit grouping). */ - AKEYCODE_NUMPAD_DOT = 158, - /** Numeric keypad ',' key (for decimals or digit grouping). */ - AKEYCODE_NUMPAD_COMMA = 159, - /** Numeric keypad Enter key. */ - AKEYCODE_NUMPAD_ENTER = 160, - /** Numeric keypad '=' key. */ - AKEYCODE_NUMPAD_EQUALS = 161, - /** Numeric keypad '(' key. */ - AKEYCODE_NUMPAD_LEFT_PAREN = 162, - /** Numeric keypad ')' key. */ - AKEYCODE_NUMPAD_RIGHT_PAREN = 163, - /** Volume Mute key. - * Mutes the speaker, unlike {@link AKEYCODE_MUTE}. - * This key should normally be implemented as a toggle such that the first press - * mutes the speaker and the second press restores the original volume. */ - AKEYCODE_VOLUME_MUTE = 164, - /** Info key. - * Common on TV remotes to show additional information related to what is - * currently being viewed. */ - AKEYCODE_INFO = 165, - /** Channel up key. - * On TV remotes, increments the television channel. */ - AKEYCODE_CHANNEL_UP = 166, - /** Channel down key. - * On TV remotes, decrements the television channel. */ - AKEYCODE_CHANNEL_DOWN = 167, - /** Zoom in key. */ - AKEYCODE_ZOOM_IN = 168, - /** Zoom out key. */ - AKEYCODE_ZOOM_OUT = 169, - /** TV key. - * On TV remotes, switches to viewing live TV. */ - AKEYCODE_TV = 170, - /** Window key. - * On TV remotes, toggles picture-in-picture mode or other windowing functions. */ - AKEYCODE_WINDOW = 171, - /** Guide key. - * On TV remotes, shows a programming guide. */ - AKEYCODE_GUIDE = 172, - /** DVR key. - * On some TV remotes, switches to a DVR mode for recorded shows. */ - AKEYCODE_DVR = 173, - /** Bookmark key. - * On some TV remotes, bookmarks content or web pages. */ - AKEYCODE_BOOKMARK = 174, - /** Toggle captions key. - * Switches the mode for closed-captioning text, for example during television shows. */ - AKEYCODE_CAPTIONS = 175, - /** Settings key. - * Starts the system settings activity. */ - AKEYCODE_SETTINGS = 176, - /** TV power key. - * On TV remotes, toggles the power on a television screen. */ - AKEYCODE_TV_POWER = 177, - /** TV input key. - * On TV remotes, switches the input on a television screen. */ - AKEYCODE_TV_INPUT = 178, - /** Set-top-box power key. - * On TV remotes, toggles the power on an external Set-top-box. */ - AKEYCODE_STB_POWER = 179, - /** Set-top-box input key. - * On TV remotes, switches the input mode on an external Set-top-box. */ - AKEYCODE_STB_INPUT = 180, - /** A/V Receiver power key. - * On TV remotes, toggles the power on an external A/V Receiver. */ - AKEYCODE_AVR_POWER = 181, - /** A/V Receiver input key. - * On TV remotes, switches the input mode on an external A/V Receiver. */ - AKEYCODE_AVR_INPUT = 182, - /** Red "programmable" key. - * On TV remotes, acts as a contextual/programmable key. */ - AKEYCODE_PROG_RED = 183, - /** Green "programmable" key. - * On TV remotes, actsas a contextual/programmable key. */ - AKEYCODE_PROG_GREEN = 184, - /** Yellow "programmable" key. - * On TV remotes, acts as a contextual/programmable key. */ - AKEYCODE_PROG_YELLOW = 185, - /** Blue "programmable" key. - * On TV remotes, acts as a contextual/programmable key. */ - AKEYCODE_PROG_BLUE = 186, - /** App switch key. - * Should bring up the application switcher dialog. */ - AKEYCODE_APP_SWITCH = 187, - /** Generic Game Pad Button #1.*/ - AKEYCODE_BUTTON_1 = 188, - /** Generic Game Pad Button #2.*/ - AKEYCODE_BUTTON_2 = 189, - /** Generic Game Pad Button #3.*/ - AKEYCODE_BUTTON_3 = 190, - /** Generic Game Pad Button #4.*/ - AKEYCODE_BUTTON_4 = 191, - /** Generic Game Pad Button #5.*/ - AKEYCODE_BUTTON_5 = 192, - /** Generic Game Pad Button #6.*/ - AKEYCODE_BUTTON_6 = 193, - /** Generic Game Pad Button #7.*/ - AKEYCODE_BUTTON_7 = 194, - /** Generic Game Pad Button #8.*/ - AKEYCODE_BUTTON_8 = 195, - /** Generic Game Pad Button #9.*/ - AKEYCODE_BUTTON_9 = 196, - /** Generic Game Pad Button #10.*/ - AKEYCODE_BUTTON_10 = 197, - /** Generic Game Pad Button #11.*/ - AKEYCODE_BUTTON_11 = 198, - /** Generic Game Pad Button #12.*/ - AKEYCODE_BUTTON_12 = 199, - /** Generic Game Pad Button #13.*/ - AKEYCODE_BUTTON_13 = 200, - /** Generic Game Pad Button #14.*/ - AKEYCODE_BUTTON_14 = 201, - /** Generic Game Pad Button #15.*/ - AKEYCODE_BUTTON_15 = 202, - /** Generic Game Pad Button #16.*/ - AKEYCODE_BUTTON_16 = 203, - /** Language Switch key. - * Toggles the current input language such as switching between English and Japanese on - * a QWERTY keyboard. On some devices, the same function may be performed by - * pressing Shift+Spacebar. */ - AKEYCODE_LANGUAGE_SWITCH = 204, - /** Manner Mode key. - * Toggles silent or vibrate mode on and off to make the device behave more politely - * in certain settings such as on a crowded train. On some devices, the key may only - * operate when long-pressed. */ - AKEYCODE_MANNER_MODE = 205, - /** 3D Mode key. - * Toggles the display between 2D and 3D mode. */ - AKEYCODE_3D_MODE = 206, - /** Contacts special function key. - * Used to launch an address book application. */ - AKEYCODE_CONTACTS = 207, - /** Calendar special function key. - * Used to launch a calendar application. */ - AKEYCODE_CALENDAR = 208, - /** Music special function key. - * Used to launch a music player application. */ - AKEYCODE_MUSIC = 209, - /** Calculator special function key. - * Used to launch a calculator application. */ - AKEYCODE_CALCULATOR = 210, - /** Japanese full-width / half-width key. */ - AKEYCODE_ZENKAKU_HANKAKU = 211, - /** Japanese alphanumeric key. */ - AKEYCODE_EISU = 212, - /** Japanese non-conversion key. */ - AKEYCODE_MUHENKAN = 213, - /** Japanese conversion key. */ - AKEYCODE_HENKAN = 214, - /** Japanese katakana / hiragana key. */ - AKEYCODE_KATAKANA_HIRAGANA = 215, - /** Japanese Yen key. */ - AKEYCODE_YEN = 216, - /** Japanese Ro key. */ - AKEYCODE_RO = 217, - /** Japanese kana key. */ - AKEYCODE_KANA = 218, - /** Assist key. - * Launches the global assist activity. Not delivered to applications. */ - AKEYCODE_ASSIST = 219, - /** Brightness Down key. - * Adjusts the screen brightness down. */ - AKEYCODE_BRIGHTNESS_DOWN = 220, - /** Brightness Up key. - * Adjusts the screen brightness up. */ - AKEYCODE_BRIGHTNESS_UP = 221, - /** Audio Track key. - * Switches the audio tracks. */ - AKEYCODE_MEDIA_AUDIO_TRACK = 222, - /** Sleep key. - * Puts the device to sleep. Behaves somewhat like {@link AKEYCODE_POWER} but it - * has no effect if the device is already asleep. */ - AKEYCODE_SLEEP = 223, - /** Wakeup key. - * Wakes up the device. Behaves somewhat like {@link AKEYCODE_POWER} but it - * has no effect if the device is already awake. */ - AKEYCODE_WAKEUP = 224, - /** Pairing key. - * Initiates peripheral pairing mode. Useful for pairing remote control - * devices or game controllers, especially if no other input mode is - * available. */ - AKEYCODE_PAIRING = 225, - /** Media Top Menu key. - * Goes to the top of media menu. */ - AKEYCODE_MEDIA_TOP_MENU = 226, - /** '11' key. */ - AKEYCODE_11 = 227, - /** '12' key. */ - AKEYCODE_12 = 228, - /** Last Channel key. - * Goes to the last viewed channel. */ - AKEYCODE_LAST_CHANNEL = 229, - /** TV data service key. - * Displays data services like weather, sports. */ - AKEYCODE_TV_DATA_SERVICE = 230, - /** Voice Assist key. - * Launches the global voice assist activity. Not delivered to applications. */ - AKEYCODE_VOICE_ASSIST = 231, - /** Radio key. - * Toggles TV service / Radio service. */ - AKEYCODE_TV_RADIO_SERVICE = 232, - /** Teletext key. - * Displays Teletext service. */ - AKEYCODE_TV_TELETEXT = 233, - /** Number entry key. - * Initiates to enter multi-digit channel nubmber when each digit key is assigned - * for selecting separate channel. Corresponds to Number Entry Mode (0x1D) of CEC - * User Control Code. */ - AKEYCODE_TV_NUMBER_ENTRY = 234, - /** Analog Terrestrial key. - * Switches to analog terrestrial broadcast service. */ - AKEYCODE_TV_TERRESTRIAL_ANALOG = 235, - /** Digital Terrestrial key. - * Switches to digital terrestrial broadcast service. */ - AKEYCODE_TV_TERRESTRIAL_DIGITAL = 236, - /** Satellite key. - * Switches to digital satellite broadcast service. */ - AKEYCODE_TV_SATELLITE = 237, - /** BS key. - * Switches to BS digital satellite broadcasting service available in Japan. */ - AKEYCODE_TV_SATELLITE_BS = 238, - /** CS key. - * Switches to CS digital satellite broadcasting service available in Japan. */ - AKEYCODE_TV_SATELLITE_CS = 239, - /** BS/CS key. - * Toggles between BS and CS digital satellite services. */ - AKEYCODE_TV_SATELLITE_SERVICE = 240, - /** Toggle Network key. - * Toggles selecting broacast services. */ - AKEYCODE_TV_NETWORK = 241, - /** Antenna/Cable key. - * Toggles broadcast input source between antenna and cable. */ - AKEYCODE_TV_ANTENNA_CABLE = 242, - /** HDMI #1 key. - * Switches to HDMI input #1. */ - AKEYCODE_TV_INPUT_HDMI_1 = 243, - /** HDMI #2 key. - * Switches to HDMI input #2. */ - AKEYCODE_TV_INPUT_HDMI_2 = 244, - /** HDMI #3 key. - * Switches to HDMI input #3. */ - AKEYCODE_TV_INPUT_HDMI_3 = 245, - /** HDMI #4 key. - * Switches to HDMI input #4. */ - AKEYCODE_TV_INPUT_HDMI_4 = 246, - /** Composite #1 key. - * Switches to composite video input #1. */ - AKEYCODE_TV_INPUT_COMPOSITE_1 = 247, - /** Composite #2 key. - * Switches to composite video input #2. */ - AKEYCODE_TV_INPUT_COMPOSITE_2 = 248, - /** Component #1 key. - * Switches to component video input #1. */ - AKEYCODE_TV_INPUT_COMPONENT_1 = 249, - /** Component #2 key. - * Switches to component video input #2. */ - AKEYCODE_TV_INPUT_COMPONENT_2 = 250, - /** VGA #1 key. - * Switches to VGA (analog RGB) input #1. */ - AKEYCODE_TV_INPUT_VGA_1 = 251, - /** Audio description key. - * Toggles audio description off / on. */ - AKEYCODE_TV_AUDIO_DESCRIPTION = 252, - /** Audio description mixing volume up key. - * Louden audio description volume as compared with normal audio volume. */ - AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP = 253, - /** Audio description mixing volume down key. - * Lessen audio description volume as compared with normal audio volume. */ - AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN = 254, - /** Zoom mode key. - * Changes Zoom mode (Normal, Full, Zoom, Wide-zoom, etc.) */ - AKEYCODE_TV_ZOOM_MODE = 255, - /** Contents menu key. - * Goes to the title list. Corresponds to Contents Menu (0x0B) of CEC User Control - * Code */ - AKEYCODE_TV_CONTENTS_MENU = 256, - /** Media context menu key. - * Goes to the context menu of media contents. Corresponds to Media Context-sensitive - * Menu (0x11) of CEC User Control Code. */ - AKEYCODE_TV_MEDIA_CONTEXT_MENU = 257, - /** Timer programming key. - * Goes to the timer recording menu. Corresponds to Timer Programming (0x54) of - * CEC User Control Code. */ - AKEYCODE_TV_TIMER_PROGRAMMING = 258, - /** Help key. */ - AKEYCODE_HELP = 259, - AKEYCODE_NAVIGATE_PREVIOUS = 260, - AKEYCODE_NAVIGATE_NEXT = 261, - AKEYCODE_NAVIGATE_IN = 262, - AKEYCODE_NAVIGATE_OUT = 263, - /** Primary stem key for Wear - * Main power/reset button on watch. */ - AKEYCODE_STEM_PRIMARY = 264, - /** Generic stem key 1 for Wear */ - AKEYCODE_STEM_1 = 265, - /** Generic stem key 2 for Wear */ - AKEYCODE_STEM_2 = 266, - /** Generic stem key 3 for Wear */ - AKEYCODE_STEM_3 = 267, - AKEYCODE_MEDIA_SKIP_FORWARD = 272, - AKEYCODE_MEDIA_SKIP_BACKWARD = 273, - AKEYCODE_MEDIA_STEP_FORWARD = 274, - AKEYCODE_MEDIA_STEP_BACKWARD = 275, - /** Put device to sleep unless a wakelock is held. */ - AKEYCODE_SOFT_SLEEP = 276 - - // NOTE: If you add a new keycode here you must also add it to several other files. - // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. -}; - -#ifdef __cplusplus -} -#endif - -#endif // _ANDROID_KEYCODES_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/looper.h b/third_party/android_frameworks_native/include/android/looper.h deleted file mode 100644 index 718f703048..0000000000 --- a/third_party/android_frameworks_native/include/android/looper.h +++ /dev/null @@ -1,269 +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. - */ - -/** - * @addtogroup Looper - * @{ - */ - -/** - * @file looper.h - */ - -#ifndef ANDROID_LOOPER_H -#define ANDROID_LOOPER_H - -#ifdef __cplusplus -extern "C" { -#endif - -struct ALooper; -/** - * ALooper - * - * A looper is the state tracking an event loop for a thread. - * Loopers do not define event structures or other such things; rather - * they are a lower-level facility to attach one or more discrete objects - * listening for an event. An "event" here is simply data available on - * a file descriptor: each attached object has an associated file descriptor, - * and waiting for "events" means (internally) polling on all of these file - * descriptors until one or more of them have data available. - * - * A thread can have only one ALooper associated with it. - */ -typedef struct ALooper ALooper; - -/** - * Returns the looper associated with the calling thread, or NULL if - * there is not one. - */ -ALooper* ALooper_forThread(); - -/** Option for for ALooper_prepare(). */ -enum { - /** - * This looper will accept calls to ALooper_addFd() that do not - * have a callback (that is provide NULL for the callback). In - * this case the caller of ALooper_pollOnce() or ALooper_pollAll() - * MUST check the return from these functions to discover when - * data is available on such fds and process it. - */ - ALOOPER_PREPARE_ALLOW_NON_CALLBACKS = 1<<0 -}; - -/** - * Prepares a looper associated with the calling thread, and returns it. - * If the thread already has a looper, it is returned. Otherwise, a new - * one is created, associated with the thread, and returned. - * - * The opts may be ALOOPER_PREPARE_ALLOW_NON_CALLBACKS or 0. - */ -ALooper* ALooper_prepare(int opts); - -/** Result from ALooper_pollOnce() and ALooper_pollAll(). */ -enum { - /** - * The poll was awoken using wake() before the timeout expired - * and no callbacks were executed and no other file descriptors were ready. - */ - ALOOPER_POLL_WAKE = -1, - - /** - * Result from ALooper_pollOnce() and ALooper_pollAll(): - * One or more callbacks were executed. - */ - ALOOPER_POLL_CALLBACK = -2, - - /** - * Result from ALooper_pollOnce() and ALooper_pollAll(): - * The timeout expired. - */ - ALOOPER_POLL_TIMEOUT = -3, - - /** - * Result from ALooper_pollOnce() and ALooper_pollAll(): - * An error occurred. - */ - ALOOPER_POLL_ERROR = -4, -}; - -/** - * Acquire a reference on the given ALooper object. This prevents the object - * from being deleted until the reference is removed. This is only needed - * to safely hand an ALooper from one thread to another. - */ -void ALooper_acquire(ALooper* looper); - -/** - * Remove a reference that was previously acquired with ALooper_acquire(). - */ -void ALooper_release(ALooper* looper); - -/** - * Flags for file descriptor events that a looper can monitor. - * - * These flag bits can be combined to monitor multiple events at once. - */ -enum { - /** - * The file descriptor is available for read operations. - */ - ALOOPER_EVENT_INPUT = 1 << 0, - - /** - * The file descriptor is available for write operations. - */ - ALOOPER_EVENT_OUTPUT = 1 << 1, - - /** - * The file descriptor has encountered an error condition. - * - * The looper always sends notifications about errors; it is not necessary - * to specify this event flag in the requested event set. - */ - ALOOPER_EVENT_ERROR = 1 << 2, - - /** - * The file descriptor was hung up. - * For example, indicates that the remote end of a pipe or socket was closed. - * - * The looper always sends notifications about hangups; it is not necessary - * to specify this event flag in the requested event set. - */ - ALOOPER_EVENT_HANGUP = 1 << 3, - - /** - * The file descriptor is invalid. - * For example, the file descriptor was closed prematurely. - * - * The looper always sends notifications about invalid file descriptors; it is not necessary - * to specify this event flag in the requested event set. - */ - ALOOPER_EVENT_INVALID = 1 << 4, -}; - -/** - * For callback-based event loops, this is the prototype of the function - * that is called when a file descriptor event occurs. - * It is given the file descriptor it is associated with, - * a bitmask of the poll events that were triggered (typically ALOOPER_EVENT_INPUT), - * and the data pointer that was originally supplied. - * - * Implementations should return 1 to continue receiving callbacks, or 0 - * to have this file descriptor and callback unregistered from the looper. - */ -typedef int (*ALooper_callbackFunc)(int fd, int events, void* data); - -/** - * Waits for events to be available, with optional timeout in milliseconds. - * Invokes callbacks for all file descriptors on which an event occurred. - * - * If the timeout is zero, returns immediately without blocking. - * If the timeout is negative, waits indefinitely until an event appears. - * - * Returns ALOOPER_POLL_WAKE if the poll was awoken using wake() before - * the timeout expired and no callbacks were invoked and no other file - * descriptors were ready. - * - * Returns ALOOPER_POLL_CALLBACK if one or more callbacks were invoked. - * - * Returns ALOOPER_POLL_TIMEOUT if there was no data before the given - * timeout expired. - * - * Returns ALOOPER_POLL_ERROR if an error occurred. - * - * Returns a value >= 0 containing an identifier (the same identifier - * `ident` passed to ALooper_addFd()) if its file descriptor has data - * and it has no callback function (requiring the caller here to - * handle it). In this (and only this) case outFd, outEvents and - * outData will contain the poll events and data associated with the - * fd, otherwise they will be set to NULL. - * - * This method does not return until it has finished invoking the appropriate callbacks - * for all file descriptors that were signalled. - */ -int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData); - -/** - * Like ALooper_pollOnce(), but performs all pending callbacks until all - * data has been consumed or a file descriptor is available with no callback. - * This function will never return ALOOPER_POLL_CALLBACK. - */ -int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData); - -/** - * Wakes the poll asynchronously. - * - * This method can be called on any thread. - * This method returns immediately. - */ -void ALooper_wake(ALooper* looper); - -/** - * Adds a new file descriptor to be polled by the looper. - * If the same file descriptor was previously added, it is replaced. - * - * "fd" is the file descriptor to be added. - * "ident" is an identifier for this event, which is returned from ALooper_pollOnce(). - * The identifier must be >= 0, or ALOOPER_POLL_CALLBACK if providing a non-NULL callback. - * "events" are the poll events to wake up on. Typically this is ALOOPER_EVENT_INPUT. - * "callback" is the function to call when there is an event on the file descriptor. - * "data" is a private data pointer to supply to the callback. - * - * There are two main uses of this function: - * - * (1) If "callback" is non-NULL, then this function will be called when there is - * data on the file descriptor. It should execute any events it has pending, - * appropriately reading from the file descriptor. The 'ident' is ignored in this case. - * - * (2) If "callback" is NULL, the 'ident' will be returned by ALooper_pollOnce - * when its file descriptor has data available, requiring the caller to take - * care of processing it. - * - * Returns 1 if the file descriptor was added or -1 if an error occurred. - * - * This method can be called on any thread. - * This method may block briefly if it needs to wake the poll. - */ -int ALooper_addFd(ALooper* looper, int fd, int ident, int events, - ALooper_callbackFunc callback, void* data); - -/** - * Removes a previously added file descriptor from the looper. - * - * When this method returns, it is safe to close the file descriptor since the looper - * will no longer have a reference to it. However, it is possible for the callback to - * already be running or for it to run one last time if the file descriptor was already - * signalled. Calling code is responsible for ensuring that this case is safely handled. - * For example, if the callback takes care of removing itself during its own execution either - * by returning 0 or by calling this method, then it can be guaranteed to not be invoked - * again at any later time unless registered anew. - * - * Returns 1 if the file descriptor was removed, 0 if none was previously registered - * or -1 if an error occurred. - * - * This method can be called on any thread. - * This method may block briefly if it needs to wake the poll. - */ -int ALooper_removeFd(ALooper* looper, int fd); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_LOOPER_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/multinetwork.h b/third_party/android_frameworks_native/include/android/multinetwork.h deleted file mode 100644 index 6c718c9037..0000000000 --- a/third_party/android_frameworks_native/include/android/multinetwork.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2015 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_MULTINETWORK_H -#define ANDROID_MULTINETWORK_H - -#include -#include -#include - -__BEGIN_DECLS - -/** - * The corresponding C type for android.net.Network#getNetworkHandle() return - * values. The Java signed long value can be safely cast to a net_handle_t: - * - * [C] ((net_handle_t) java_long_network_handle) - * [C++] static_cast(java_long_network_handle) - * - * as appropriate. - */ -typedef uint64_t net_handle_t; - -/** - * The value NETWORK_UNSPECIFIED indicates no specific network. - * - * For some functions (documented below), a previous binding may be cleared - * by an invocation with NETWORK_UNSPECIFIED. - * - * Depending on the context it may indicate an error. It is expressly - * not used to indicate some notion of the "current default network". - */ -#define NETWORK_UNSPECIFIED ((net_handle_t)0) - - -/** - * All functions below that return an int return 0 on success or -1 - * on failure with an appropriate errno value set. - */ - - -/** - * Set the network to be used by the given socket file descriptor. - * - * To clear a previous socket binding invoke with NETWORK_UNSPECIFIED. - * - * This is the equivalent of: - * - * [ android.net.Network#bindSocket() ] - * https://developer.android.com/reference/android/net/Network.html#bindSocket(java.net.Socket) - */ -int android_setsocknetwork(net_handle_t network, int fd); - - -/** - * Binds the current process to |network|. All sockets created in the future - * (and not explicitly bound via android_setsocknetwork()) will be bound to - * |network|. All host name resolutions will be limited to |network| as well. - * Note that if the network identified by |network| ever disconnects, all - * sockets created in this way will cease to work and all host name - * resolutions will fail. This is by design so an application doesn't - * accidentally use sockets it thinks are still bound to a particular network. - * - * To clear a previous process binding invoke with NETWORK_UNSPECIFIED. - * - * This is the equivalent of: - * - * [ android.net.ConnectivityManager#setProcessDefaultNetwork() ] - * https://developer.android.com/reference/android/net/ConnectivityManager.html#setProcessDefaultNetwork(android.net.Network) - */ -int android_setprocnetwork(net_handle_t network); - - -/** - * Perform hostname resolution via the DNS servers associated with |network|. - * - * All arguments (apart from |network|) are used identically as those passed - * to getaddrinfo(3). Return and error values are identical to those of - * getaddrinfo(3), and in particular gai_strerror(3) can be used as expected. - * Similar to getaddrinfo(3): - * - |hints| may be NULL (in which case man page documented defaults apply) - * - either |node| or |service| may be NULL, but not both - * - |res| must not be NULL - * - * This is the equivalent of: - * - * [ android.net.Network#getAllByName() ] - * https://developer.android.com/reference/android/net/Network.html#getAllByName(java.lang.String) - */ -int android_getaddrinfofornetwork(net_handle_t network, - const char *node, const char *service, - const struct addrinfo *hints, struct addrinfo **res); - -__END_DECLS - -#endif // ANDROID_MULTINETWORK_H diff --git a/third_party/android_frameworks_native/include/android/native_activity.h b/third_party/android_frameworks_native/include/android/native_activity.h deleted file mode 100644 index d3d99cf7a9..0000000000 --- a/third_party/android_frameworks_native/include/android/native_activity.h +++ /dev/null @@ -1,340 +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. - */ - -/** - * @addtogroup NativeActivity Native Activity - * @{ - */ - -/** - * @file native_activity.h - */ - -#ifndef ANDROID_NATIVE_ACTIVITY_H -#define ANDROID_NATIVE_ACTIVITY_H - -#include -#include - -#include - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * {@link ANativeActivityCallbacks} - */ -struct ANativeActivityCallbacks; - -/** - * This structure defines the native side of an android.app.NativeActivity. - * It is created by the framework, and handed to the application's native - * code as it is being launched. - */ -typedef struct ANativeActivity { - /** - * Pointer to the callback function table of the native application. - * You can set the functions here to your own callbacks. The callbacks - * pointer itself here should not be changed; it is allocated and managed - * for you by the framework. - */ - struct ANativeActivityCallbacks* callbacks; - - /** - * The global handle on the process's Java VM. - */ - JavaVM* vm; - - /** - * JNI context for the main thread of the app. Note that this field - * can ONLY be used from the main thread of the process; that is, the - * thread that calls into the ANativeActivityCallbacks. - */ - JNIEnv* env; - - /** - * The NativeActivity object handle. - * - * IMPORTANT NOTE: This member is mis-named. It should really be named - * 'activity' instead of 'clazz', since it's a reference to the - * NativeActivity instance created by the system for you. - * - * We unfortunately cannot change this without breaking NDK - * source-compatibility. - */ - jobject clazz; - - /** - * Path to this application's internal data directory. - */ - const char* internalDataPath; - - /** - * Path to this application's external (removable/mountable) data directory. - */ - const char* externalDataPath; - - /** - * The platform's SDK version code. - */ - int32_t sdkVersion; - - /** - * This is the native instance of the application. It is not used by - * the framework, but can be set by the application to its own instance - * state. - */ - void* instance; - - /** - * Pointer to the Asset Manager instance for the application. The application - * uses this to access binary assets bundled inside its own .apk file. - */ - AAssetManager* assetManager; - - /** - * Available starting with Honeycomb: path to the directory containing - * the application's OBB files (if any). If the app doesn't have any - * OBB files, this directory may not exist. - */ - const char* obbPath; -} ANativeActivity; - -/** - * These are the callbacks the framework makes into a native application. - * All of these callbacks happen on the main thread of the application. - * By default, all callbacks are NULL; set to a pointer to your own function - * to have it called. - */ -typedef struct ANativeActivityCallbacks { - /** - * NativeActivity has started. See Java documentation for Activity.onStart() - * for more information. - */ - void (*onStart)(ANativeActivity* activity); - - /** - * NativeActivity has resumed. See Java documentation for Activity.onResume() - * for more information. - */ - void (*onResume)(ANativeActivity* activity); - - /** - * Framework is asking NativeActivity to save its current instance state. - * See Java documentation for Activity.onSaveInstanceState() for more - * information. The returned pointer needs to be created with malloc(); - * the framework will call free() on it for you. You also must fill in - * outSize with the number of bytes in the allocation. Note that the - * saved state will be persisted, so it can not contain any active - * entities (pointers to memory, file descriptors, etc). - */ - void* (*onSaveInstanceState)(ANativeActivity* activity, size_t* outSize); - - /** - * NativeActivity has paused. See Java documentation for Activity.onPause() - * for more information. - */ - void (*onPause)(ANativeActivity* activity); - - /** - * NativeActivity has stopped. See Java documentation for Activity.onStop() - * for more information. - */ - void (*onStop)(ANativeActivity* activity); - - /** - * NativeActivity is being destroyed. See Java documentation for Activity.onDestroy() - * for more information. - */ - void (*onDestroy)(ANativeActivity* activity); - - /** - * Focus has changed in this NativeActivity's window. This is often used, - * for example, to pause a game when it loses input focus. - */ - void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus); - - /** - * The drawing window for this native activity has been created. You - * can use the given native window object to start drawing. - */ - void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window); - - /** - * The drawing window for this native activity has been resized. You should - * retrieve the new size from the window and ensure that your rendering in - * it now matches. - */ - void (*onNativeWindowResized)(ANativeActivity* activity, ANativeWindow* window); - - /** - * The drawing window for this native activity needs to be redrawn. To avoid - * transient artifacts during screen changes (such resizing after rotation), - * applications should not return from this function until they have finished - * drawing their window in its current state. - */ - void (*onNativeWindowRedrawNeeded)(ANativeActivity* activity, ANativeWindow* window); - - /** - * The drawing window for this native activity is going to be destroyed. - * You MUST ensure that you do not touch the window object after returning - * from this function: in the common case of drawing to the window from - * another thread, that means the implementation of this callback must - * properly synchronize with the other thread to stop its drawing before - * returning from here. - */ - void (*onNativeWindowDestroyed)(ANativeActivity* activity, ANativeWindow* window); - - /** - * The input queue for this native activity's window has been created. - * You can use the given input queue to start retrieving input events. - */ - void (*onInputQueueCreated)(ANativeActivity* activity, AInputQueue* queue); - - /** - * The input queue for this native activity's window is being destroyed. - * You should no longer try to reference this object upon returning from this - * function. - */ - void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue); - - /** - * The rectangle in the window in which content should be placed has changed. - */ - void (*onContentRectChanged)(ANativeActivity* activity, const ARect* rect); - - /** - * The current device AConfiguration has changed. The new configuration can - * be retrieved from assetManager. - */ - void (*onConfigurationChanged)(ANativeActivity* activity); - - /** - * The system is running low on memory. Use this callback to release - * resources you do not need, to help the system avoid killing more - * important processes. - */ - void (*onLowMemory)(ANativeActivity* activity); -} ANativeActivityCallbacks; - -/** - * This is the function that must be in the native code to instantiate the - * application's native activity. It is called with the activity instance (see - * above); if the code is being instantiated from a previously saved instance, - * the savedState will be non-NULL and point to the saved data. You must make - * any copy of this data you need -- it will be released after you return from - * this function. - */ -typedef void ANativeActivity_createFunc(ANativeActivity* activity, - void* savedState, size_t savedStateSize); - -/** - * The name of the function that NativeInstance looks for when launching its - * native code. This is the default function that is used, you can specify - * "android.app.func_name" string meta-data in your manifest to use a different - * function. - */ -extern ANativeActivity_createFunc ANativeActivity_onCreate; - -/** - * Finish the given activity. Its finish() method will be called, causing it - * to be stopped and destroyed. Note that this method can be called from - * *any* thread; it will send a message to the main thread of the process - * where the Java finish call will take place. - */ -void ANativeActivity_finish(ANativeActivity* activity); - -/** - * Change the window format of the given activity. Calls getWindow().setFormat() - * of the given activity. Note that this method can be called from - * *any* thread; it will send a message to the main thread of the process - * where the Java finish call will take place. - */ -void ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format); - -/** - * Change the window flags of the given activity. Calls getWindow().setFlags() - * of the given activity. Note that this method can be called from - * *any* thread; it will send a message to the main thread of the process - * where the Java finish call will take place. See window.h for flag constants. - */ -void ANativeActivity_setWindowFlags(ANativeActivity* activity, - uint32_t addFlags, uint32_t removeFlags); - -/** - * Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager - * API for documentation. - */ -enum { - /** - * Implicit request to show the input window, not as the result - * of a direct request by the user. - */ - ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001, - - /** - * The user has forced the input method open (such as by - * long-pressing menu) so it should not be closed until they - * explicitly do so. - */ - ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002, -}; - -/** - * Show the IME while in the given activity. Calls InputMethodManager.showSoftInput() - * for the given activity. Note that this method can be called from - * *any* thread; it will send a message to the main thread of the process - * where the Java finish call will take place. - */ -void ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags); - -/** - * Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager - * API for documentation. - */ -enum { - /** - * The soft input window should only be hidden if it was not - * explicitly shown by the user. - */ - ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001, - /** - * The soft input window should normally be hidden, unless it was - * originally shown with {@link ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED}. - */ - ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002, -}; - -/** - * Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput() - * for the given activity. Note that this method can be called from - * *any* thread; it will send a message to the main thread of the process - * where the Java finish call will take place. - */ -void ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_NATIVE_ACTIVITY_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/native_window.h b/third_party/android_frameworks_native/include/android/native_window.h deleted file mode 100644 index cf07f1afad..0000000000 --- a/third_party/android_frameworks_native/include/android/native_window.h +++ /dev/null @@ -1,150 +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. - */ - -/** - * @addtogroup NativeActivity Native Activity - * @{ - */ - -/** - * @file native_window.h - */ - -#ifndef ANDROID_NATIVE_WINDOW_H -#define ANDROID_NATIVE_WINDOW_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Pixel formats that a window can use. - */ -enum { - /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/ - WINDOW_FORMAT_RGBA_8888 = 1, - /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits. **/ - WINDOW_FORMAT_RGBX_8888 = 2, - /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/ - WINDOW_FORMAT_RGB_565 = 4, -}; - -struct ANativeWindow; -/** - * {@link ANativeWindow} is opaque type that provides access to a native window. - * - * A pointer can be obtained using ANativeWindow_fromSurface(). - */ -typedef struct ANativeWindow ANativeWindow; - -/** - * {@link ANativeWindow} is a struct that represents a windows buffer. - * - * A pointer can be obtained using ANativeWindow_lock(). - */ -typedef struct ANativeWindow_Buffer { - // The number of pixels that are show horizontally. - int32_t width; - - // The number of pixels that are shown vertically. - int32_t height; - - // The number of *pixels* that a line in the buffer takes in - // memory. This may be >= width. - int32_t stride; - - // The format of the buffer. One of WINDOW_FORMAT_* - int32_t format; - - // The actual bits. - void* bits; - - // Do not touch. - uint32_t reserved[6]; -} ANativeWindow_Buffer; - -/** - * Acquire a reference on the given ANativeWindow object. This prevents the object - * from being deleted until the reference is removed. - */ -void ANativeWindow_acquire(ANativeWindow* window); - -/** - * Remove a reference that was previously acquired with ANativeWindow_acquire(). - */ -void ANativeWindow_release(ANativeWindow* window); - -/** - * Return the current width in pixels of the window surface. Returns a - * negative value on error. - */ -int32_t ANativeWindow_getWidth(ANativeWindow* window); - -/** - * Return the current height in pixels of the window surface. Returns a - * negative value on error. - */ -int32_t ANativeWindow_getHeight(ANativeWindow* window); - -/** - * Return the current pixel format of the window surface. Returns a - * negative value on error. - */ -int32_t ANativeWindow_getFormat(ANativeWindow* window); - -/** - * Change the format and size of the window buffers. - * - * The width and height control the number of pixels in the buffers, not the - * dimensions of the window on screen. If these are different than the - * window's physical size, then it buffer will be scaled to match that size - * when compositing it to the screen. - * - * For all of these parameters, if 0 is supplied then the window's base - * value will come back in force. - * - * width and height must be either both zero or both non-zero. - * - */ -int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, - int32_t width, int32_t height, int32_t format); - -/** - * Lock the window's next drawing surface for writing. - * inOutDirtyBounds is used as an in/out parameter, upon entering the - * function, it contains the dirty region, that is, the region the caller - * intends to redraw. When the function returns, inOutDirtyBounds is updated - * with the actual area the caller needs to redraw -- this region is often - * extended by ANativeWindow_lock. - */ -int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, - ARect* inOutDirtyBounds); - -/** - * Unlock the window's drawing surface after previously locking it, - * posting the new buffer to the display. - */ -int32_t ANativeWindow_unlockAndPost(ANativeWindow* window); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_NATIVE_WINDOW_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/native_window_jni.h b/third_party/android_frameworks_native/include/android/native_window_jni.h deleted file mode 100644 index 60a36c3f27..0000000000 --- a/third_party/android_frameworks_native/include/android/native_window_jni.h +++ /dev/null @@ -1,51 +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. - */ - -/** - * @addtogroup NativeActivity Native Activity - * @{ - */ - -/** - * @file native_window_jni.h - */ - -#ifndef ANDROID_NATIVE_WINDOW_JNI_H -#define ANDROID_NATIVE_WINDOW_JNI_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Return the ANativeWindow associated with a Java Surface object, - * for interacting with it through native code. This acquires a reference - * on the ANativeWindow that is returned; be sure to use ANativeWindow_release() - * when done with it so that it doesn't leak. - */ -ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_NATIVE_WINDOW_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/obb.h b/third_party/android_frameworks_native/include/android/obb.h deleted file mode 100644 index 4c6d9d7bad..0000000000 --- a/third_party/android_frameworks_native/include/android/obb.h +++ /dev/null @@ -1,76 +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. - */ - -/** - * @addtogroup Storage - * @{ - */ - -/** - * @file obb.h - */ - -#ifndef ANDROID_OBB_H -#define ANDROID_OBB_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct AObbInfo; -/** {@link AObbInfo} is an opaque type representing information for obb storage. */ -typedef struct AObbInfo AObbInfo; - -/** Flag for an obb file, returned by AObbInfo_getFlags(). */ -enum { - /** overlay */ - AOBBINFO_OVERLAY = 0x0001, -}; - -/** - * Scan an OBB and get information about it. - */ -AObbInfo* AObbScanner_getObbInfo(const char* filename); - -/** - * Destroy the AObbInfo object. You must call this when finished with the object. - */ -void AObbInfo_delete(AObbInfo* obbInfo); - -/** - * Get the package name for the OBB. - */ -const char* AObbInfo_getPackageName(AObbInfo* obbInfo); - -/** - * Get the version of an OBB file. - */ -int32_t AObbInfo_getVersion(AObbInfo* obbInfo); - -/** - * Get the flags of an OBB file. - */ -int32_t AObbInfo_getFlags(AObbInfo* obbInfo); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_OBB_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/rect.h b/third_party/android_frameworks_native/include/android/rect.h deleted file mode 100644 index 80741c0442..0000000000 --- a/third_party/android_frameworks_native/include/android/rect.h +++ /dev/null @@ -1,62 +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. - */ - -/** - * @addtogroup NativeActivity Native Activity - * @{ - */ - -/** - * @file rect.h - */ - -#ifndef ANDROID_RECT_H -#define ANDROID_RECT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * {@link ARect} is a struct that represents a rectangular window area. - * - * It is used with {@link - * ANativeActivityCallbacks::onContentRectChanged} event callback and - * ANativeWindow_lock() function. - */ -typedef struct ARect { -#ifdef __cplusplus - typedef int32_t value_type; -#endif - /** left position */ - int32_t left; - /** top position */ - int32_t top; - /** left position */ - int32_t right; - /** bottom position */ - int32_t bottom; -} ARect; - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_RECT_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/sensor.h b/third_party/android_frameworks_native/include/android/sensor.h deleted file mode 100644 index 73928ea76f..0000000000 --- a/third_party/android_frameworks_native/include/android/sensor.h +++ /dev/null @@ -1,475 +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. - */ - -/** - * @addtogroup Sensor - * @{ - */ - -/** - * @file sensor.h - */ - -#ifndef ANDROID_SENSOR_H -#define ANDROID_SENSOR_H - -/****************************************************************** - * - * IMPORTANT NOTICE: - * - * This file is part of Android's set of stable system headers - * exposed by the Android NDK (Native Development Kit). - * - * Third-party source AND binary code relies on the definitions - * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. - * - * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) - * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS - * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY - * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES - */ - -/** - * Structures and functions to receive and process sensor events in - * native code. - * - */ - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Sensor types. - * (keep in sync with hardware/sensor.h) - */ -enum { - /** - * {@link ASENSOR_TYPE_ACCELEROMETER} - * reporting-mode: continuous - * - * All values are in SI units (m/s^2) and measure the acceleration of the - * device minus the force of gravity. - */ - ASENSOR_TYPE_ACCELEROMETER = 1, - /** - * {@link ASENSOR_TYPE_MAGNETIC_FIELD} - * reporting-mode: continuous - * - * All values are in micro-Tesla (uT) and measure the geomagnetic - * field in the X, Y and Z axis. - */ - ASENSOR_TYPE_MAGNETIC_FIELD = 2, - /** - * {@link ASENSOR_TYPE_GYROSCOPE} - * reporting-mode: continuous - * - * All values are in radians/second and measure the rate of rotation - * around the X, Y and Z axis. - */ - ASENSOR_TYPE_GYROSCOPE = 4, - /** - * {@link ASENSOR_TYPE_LIGHT} - * reporting-mode: on-change - * - * The light sensor value is returned in SI lux units. - */ - ASENSOR_TYPE_LIGHT = 5, - /** - * {@link ASENSOR_TYPE_PROXIMITY} - * reporting-mode: on-change - * - * The proximity sensor which turns the screen off and back on during calls is the - * wake-up proximity sensor. Implement wake-up proximity sensor before implementing - * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag - * SENSOR_FLAG_WAKE_UP. - * The value corresponds to the distance to the nearest object in centimeters. - */ - ASENSOR_TYPE_PROXIMITY = 8 -}; - -/** - * Sensor accuracy measure. - */ -enum { - /** no contact */ - ASENSOR_STATUS_NO_CONTACT = -1, - /** unreliable */ - ASENSOR_STATUS_UNRELIABLE = 0, - /** low accuracy */ - ASENSOR_STATUS_ACCURACY_LOW = 1, - /** medium accuracy */ - ASENSOR_STATUS_ACCURACY_MEDIUM = 2, - /** high accuracy */ - ASENSOR_STATUS_ACCURACY_HIGH = 3 -}; - -/** - * Sensor Reporting Modes. - */ -enum { - /** continuous reporting */ - AREPORTING_MODE_CONTINUOUS = 0, - /** reporting on change */ - AREPORTING_MODE_ON_CHANGE = 1, - /** on shot reporting */ - AREPORTING_MODE_ONE_SHOT = 2, - /** special trigger reporting */ - AREPORTING_MODE_SPECIAL_TRIGGER = 3 -}; - -/* - * A few useful constants - */ - -/** Earth's gravity in m/s^2 */ -#define ASENSOR_STANDARD_GRAVITY (9.80665f) -/** Maximum magnetic field on Earth's surface in uT */ -#define ASENSOR_MAGNETIC_FIELD_EARTH_MAX (60.0f) -/** Minimum magnetic field on Earth's surface in uT*/ -#define ASENSOR_MAGNETIC_FIELD_EARTH_MIN (30.0f) - -/** - * A sensor event. - */ - -/* NOTE: Must match hardware/sensors.h */ -typedef struct ASensorVector { - union { - float v[3]; - struct { - float x; - float y; - float z; - }; - struct { - float azimuth; - float pitch; - float roll; - }; - }; - int8_t status; - uint8_t reserved[3]; -} ASensorVector; - -typedef struct AMetaDataEvent { - int32_t what; - int32_t sensor; -} AMetaDataEvent; - -typedef struct AUncalibratedEvent { - union { - float uncalib[3]; - struct { - float x_uncalib; - float y_uncalib; - float z_uncalib; - }; - }; - union { - float bias[3]; - struct { - float x_bias; - float y_bias; - float z_bias; - }; - }; -} AUncalibratedEvent; - -typedef struct AHeartRateEvent { - float bpm; - int8_t status; -} AHeartRateEvent; - -/* NOTE: Must match hardware/sensors.h */ -typedef struct ASensorEvent { - int32_t version; /* sizeof(struct ASensorEvent) */ - int32_t sensor; - int32_t type; - int32_t reserved0; - int64_t timestamp; - union { - union { - float data[16]; - ASensorVector vector; - ASensorVector acceleration; - ASensorVector magnetic; - float temperature; - float distance; - float light; - float pressure; - float relative_humidity; - AUncalibratedEvent uncalibrated_gyro; - AUncalibratedEvent uncalibrated_magnetic; - AMetaDataEvent meta_data; - AHeartRateEvent heart_rate; - }; - union { - uint64_t data[8]; - uint64_t step_counter; - } u64; - }; - - uint32_t flags; - int32_t reserved1[3]; -} ASensorEvent; - -struct ASensorManager; -/** - * {@link ASensorManager} is an opaque type to manage sensors and - * events queues. - * - * {@link ASensorManager} is a singleton that can be obtained using - * ASensorManager_getInstance(). - * - * This file provides a set of functions that uses {@link - * ASensorManager} to access and list hardware sensors, and - * create and destroy event queues: - * - ASensorManager_getSensorList() - * - ASensorManager_getDefaultSensor() - * - ASensorManager_getDefaultSensorEx() - * - ASensorManager_createEventQueue() - * - ASensorManager_destroyEventQueue() - */ -typedef struct ASensorManager ASensorManager; - - -struct ASensorEventQueue; -/** - * {@link ASensorEventQueue} is an opaque type that provides access to - * {@link ASensorEvent} from hardware sensors. - * - * A new {@link ASensorEventQueue} can be obtained using ASensorManager_createEventQueue(). - * - * This file provides a set of functions to enable and disable - * sensors, check and get events, and set event rates on a {@link - * ASensorEventQueue}. - * - ASensorEventQueue_enableSensor() - * - ASensorEventQueue_disableSensor() - * - ASensorEventQueue_hasEvents() - * - ASensorEventQueue_getEvents() - * - ASensorEventQueue_setEventRate() - */ -typedef struct ASensorEventQueue ASensorEventQueue; - -struct ASensor; -/** - * {@link ASensor} is an opaque type that provides information about - * an hardware sensors. - * - * A {@link ASensor} pointer can be obtained using - * ASensorManager_getDefaultSensor(), - * ASensorManager_getDefaultSensorEx() or from a {@link ASensorList}. - * - * This file provides a set of functions to access properties of a - * {@link ASensor}: - * - ASensor_getName() - * - ASensor_getVendor() - * - ASensor_getType() - * - ASensor_getResolution() - * - ASensor_getMinDelay() - * - ASensor_getFifoMaxEventCount() - * - ASensor_getFifoReservedEventCount() - * - ASensor_getStringType() - * - ASensor_getReportingMode() - * - ASensor_isWakeUpSensor() - */ -typedef struct ASensor ASensor; -/** - * {@link ASensorRef} is a type for constant pointers to {@link ASensor}. - * - * This is used to define entry in {@link ASensorList} arrays. - */ -typedef ASensor const* ASensorRef; -/** - * {@link ASensorList} is an array of reference to {@link ASensor}. - * - * A {@link ASensorList} can be initialized using ASensorManager_getSensorList(). - */ -typedef ASensorRef const* ASensorList; - -/*****************************************************************************/ - -/** - * Get a reference to the sensor manager. ASensorManager is a singleton - * per package as different packages may have access to different sensors. - * - * Deprecated: Use ASensorManager_getInstanceForPackage(const char*) instead. - * - * Example: - * - * ASensorManager* sensorManager = ASensorManager_getInstance(); - * - */ -__attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance(); - -/* - * Get a reference to the sensor manager. ASensorManager is a singleton - * per package as different packages may have access to different sensors. - * - * Example: - * - * ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz"); - * - */ -ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName); - -/** - * Returns the list of available sensors. - */ -int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list); - -/** - * Returns the default sensor for the given type, or NULL if no sensor - * of that type exists. - */ -ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type); - -/** - * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor - * of this type and wakeUp properties exists. - */ -ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, - bool wakeUp); - -/** - * Creates a new sensor event queue and associate it with a looper. - * - * "ident" is a identifier for the events that will be returned when - * calling ALooper_pollOnce(). The identifier must be >= 0, or - * ALOOPER_POLL_CALLBACK if providing a non-NULL callback. - */ -ASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager, - ALooper* looper, int ident, ALooper_callbackFunc callback, void* data); - -/** - * Destroys the event queue and free all resources associated to it. - */ -int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue); - - -/*****************************************************************************/ - -/** - * Enable the selected sensor. Returns a negative error code on failure. - */ -int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor const* sensor); - -/** - * Disable the selected sensor. Returns a negative error code on failure. - */ -int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor const* sensor); - -/** - * Sets the delivery rate of events in microseconds for the given sensor. - * Note that this is a hint only, generally event will arrive at a higher - * rate. It is an error to set a rate inferior to the value returned by - * ASensor_getMinDelay(). - * Returns a negative error code on failure. - */ -int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec); - -/** - * Returns true if there are one or more events available in the - * sensor queue. Returns 1 if the queue has events; 0 if - * it does not have events; and a negative value if there is an error. - */ -int ASensorEventQueue_hasEvents(ASensorEventQueue* queue); - -/** - * Returns the next available events from the queue. Returns a negative - * value if no events are available or an error has occurred, otherwise - * the number of events returned. - * - * Examples: - * ASensorEvent event; - * ssize_t numEvent = ASensorEventQueue_getEvents(queue, &event, 1); - * - * ASensorEvent eventBuffer[8]; - * ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8); - * - */ -ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, - ASensorEvent* events, size_t count); - - -/*****************************************************************************/ - -/** - * Returns this sensor's name (non localized) - */ -const char* ASensor_getName(ASensor const* sensor); - -/** - * Returns this sensor's vendor's name (non localized) - */ -const char* ASensor_getVendor(ASensor const* sensor); - -/** - * Return this sensor's type - */ -int ASensor_getType(ASensor const* sensor); - -/** - * Returns this sensors's resolution - */ -float ASensor_getResolution(ASensor const* sensor); - -/** - * Returns the minimum delay allowed between events in microseconds. - * A value of zero means that this sensor doesn't report events at a - * constant rate, but rather only when a new data is available. - */ -int ASensor_getMinDelay(ASensor const* sensor); - -/** - * Returns the maximum size of batches for this sensor. Batches will often be - * smaller, as the hardware fifo might be used for other sensors. - */ -int ASensor_getFifoMaxEventCount(ASensor const* sensor); - -/** - * Returns the hardware batch fifo size reserved to this sensor. - */ -int ASensor_getFifoReservedEventCount(ASensor const* sensor); - -/** - * Returns this sensor's string type. - */ -const char* ASensor_getStringType(ASensor const* sensor); - -/** - * Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants. - */ -int ASensor_getReportingMode(ASensor const* sensor); - -/** - * Returns true if this is a wake up sensor, false otherwise. - */ -bool ASensor_isWakeUpSensor(ASensor const* sensor); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_SENSOR_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/storage_manager.h b/third_party/android_frameworks_native/include/android/storage_manager.h deleted file mode 100644 index 7f2ee08d62..0000000000 --- a/third_party/android_frameworks_native/include/android/storage_manager.h +++ /dev/null @@ -1,154 +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. - */ - -/** - * @addtogroup Storage - * @{ - */ - -/** - * @file storage_manager.h - */ - -#ifndef ANDROID_STORAGE_MANAGER_H -#define ANDROID_STORAGE_MANAGER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct AStorageManager; -/** - * {@link AStorageManager} manages application OBB storage, a pointer - * can be obtained with AStorageManager_new(). - */ -typedef struct AStorageManager AStorageManager; - -/** - * The different states of a OBB storage passed to AStorageManager_obbCallbackFunc(). - */ -enum { - /** - * The OBB container is now mounted and ready for use. Can be returned - * as the status for callbacks made during asynchronous OBB actions. - */ - AOBB_STATE_MOUNTED = 1, - - /** - * The OBB container is now unmounted and not usable. Can be returned - * as the status for callbacks made during asynchronous OBB actions. - */ - AOBB_STATE_UNMOUNTED = 2, - - /** - * There was an internal system error encountered while trying to - * mount the OBB. Can be returned as the status for callbacks made - * during asynchronous OBB actions. - */ - AOBB_STATE_ERROR_INTERNAL = 20, - - /** - * The OBB could not be mounted by the system. Can be returned as the - * status for callbacks made during asynchronous OBB actions. - */ - AOBB_STATE_ERROR_COULD_NOT_MOUNT = 21, - - /** - * The OBB could not be unmounted. This most likely indicates that a - * file is in use on the OBB. Can be returned as the status for - * callbacks made during asynchronous OBB actions. - */ - AOBB_STATE_ERROR_COULD_NOT_UNMOUNT = 22, - - /** - * A call was made to unmount the OBB when it was not mounted. Can be - * returned as the status for callbacks made during asynchronous OBB - * actions. - */ - AOBB_STATE_ERROR_NOT_MOUNTED = 23, - - /** - * The OBB has already been mounted. Can be returned as the status for - * callbacks made during asynchronous OBB actions. - */ - AOBB_STATE_ERROR_ALREADY_MOUNTED = 24, - - /** - * The current application does not have permission to use this OBB. - * This could be because the OBB indicates it's owned by a different - * package. Can be returned as the status for callbacks made during - * asynchronous OBB actions. - */ - AOBB_STATE_ERROR_PERMISSION_DENIED = 25, -}; - -/** - * Obtains a new instance of AStorageManager. - */ -AStorageManager* AStorageManager_new(); - -/** - * Release AStorageManager instance. - */ -void AStorageManager_delete(AStorageManager* mgr); - -/** - * Callback function for asynchronous calls made on OBB files. - * - * "state" is one of the following constants: - * - {@link AOBB_STATE_MOUNTED} - * - {@link AOBB_STATE_UNMOUNTED} - * - {@link AOBB_STATE_ERROR_INTERNAL} - * - {@link AOBB_STATE_ERROR_COULD_NOT_MOUNT} - * - {@link AOBB_STATE_ERROR_COULD_NOT_UNMOUNT} - * - {@link AOBB_STATE_ERROR_NOT_MOUNTED} - * - {@link AOBB_STATE_ERROR_ALREADY_MOUNTED} - * - {@link AOBB_STATE_ERROR_PERMISSION_DENIED} - */ -typedef void (*AStorageManager_obbCallbackFunc)(const char* filename, const int32_t state, void* data); - -/** - * Attempts to mount an OBB file. This is an asynchronous operation. - */ -void AStorageManager_mountObb(AStorageManager* mgr, const char* filename, const char* key, - AStorageManager_obbCallbackFunc cb, void* data); - -/** - * Attempts to unmount an OBB file. This is an asynchronous operation. - */ -void AStorageManager_unmountObb(AStorageManager* mgr, const char* filename, const int force, - AStorageManager_obbCallbackFunc cb, void* data); - -/** - * Check whether an OBB is mounted. - */ -int AStorageManager_isObbMounted(AStorageManager* mgr, const char* filename); - -/** - * Get the mounted path for an OBB. - */ -const char* AStorageManager_getMountedObbPath(AStorageManager* mgr, const char* filename); - - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_STORAGE_MANAGER_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/android/trace.h b/third_party/android_frameworks_native/include/android/trace.h deleted file mode 100644 index e42e334102..0000000000 --- a/third_party/android_frameworks_native/include/android/trace.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2015 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_NATIVE_TRACE_H -#define ANDROID_NATIVE_TRACE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Returns true if tracing is enabled. Use this signal to avoid expensive computation only necessary - * when tracing is enabled. - */ -bool ATrace_isEnabled(); - -/** - * Writes a tracing message to indicate that the given section of code has begun. This call must be - * followed by a corresponding call to endSection() on the same thread. - * - * Note: At this time the vertical bar character '|' and newline character '\n' are used internally - * by the tracing mechanism. If sectionName contains these characters they will be replaced with a - * space character in the trace. - */ -void ATrace_beginSection(const char* sectionName); - -/** - * Writes a tracing message to indicate that a given section of code has ended. This call must be - * preceeded by a corresponding call to beginSection(char*) on the same thread. Calling this method - * will mark the end of the most recently begun section of code, so care must be taken to ensure - * that beginSection / endSection pairs are properly nested and called from the same thread. - */ -void ATrace_endSection(); - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_NATIVE_TRACE_H diff --git a/third_party/android_frameworks_native/include/android/window.h b/third_party/android_frameworks_native/include/android/window.h deleted file mode 100644 index 436bf3a830..0000000000 --- a/third_party/android_frameworks_native/include/android/window.h +++ /dev/null @@ -1,224 +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. - */ - -/** - * @addtogroup NativeActivity Native Activity - * @{ - */ - -/** - * @file window.h - */ - -#ifndef ANDROID_WINDOW_H -#define ANDROID_WINDOW_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Window flags, as per the Java API at android.view.WindowManager.LayoutParams. - */ -enum { - /** - * As long as this window is visible to the user, allow the lock - * screen to activate while the screen is on. This can be used - * independently, or in combination with {@link - * AWINDOW_FLAG_KEEP_SCREEN_ON} and/or {@link - * AWINDOW_FLAG_SHOW_WHEN_LOCKED} - */ - AWINDOW_FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001, - /** Everything behind this window will be dimmed. */ - AWINDOW_FLAG_DIM_BEHIND = 0x00000002, - /** - * Blur everything behind this window. - * @deprecated Blurring is no longer supported. - */ - AWINDOW_FLAG_BLUR_BEHIND = 0x00000004, - /** - * This window won't ever get key input focus, so the - * user can not send key or other button events to it. Those will - * instead go to whatever focusable window is behind it. This flag - * will also enable {@link AWINDOW_FLAG_NOT_TOUCH_MODAL} whether or not that - * is explicitly set. - * - * Setting this flag also implies that the window will not need to - * interact with - * a soft input method, so it will be Z-ordered and positioned - * independently of any active input method (typically this means it - * gets Z-ordered on top of the input method, so it can use the full - * screen for its content and cover the input method if needed. You - * can use {@link AWINDOW_FLAG_ALT_FOCUSABLE_IM} to modify this behavior. - */ - AWINDOW_FLAG_NOT_FOCUSABLE = 0x00000008, - /** this window can never receive touch events. */ - AWINDOW_FLAG_NOT_TOUCHABLE = 0x00000010, - /** - * Even when this window is focusable (its - * {@link AWINDOW_FLAG_NOT_FOCUSABLE} is not set), allow any pointer events - * outside of the window to be sent to the windows behind it. Otherwise - * it will consume all pointer events itself, regardless of whether they - * are inside of the window. - */ - AWINDOW_FLAG_NOT_TOUCH_MODAL = 0x00000020, - /** - * When set, if the device is asleep when the touch - * screen is pressed, you will receive this first touch event. Usually - * the first touch event is consumed by the system since the user can - * not see what they are pressing on. - * - * @deprecated This flag has no effect. - */ - AWINDOW_FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040, - /** - * As long as this window is visible to the user, keep - * the device's screen turned on and bright. - */ - AWINDOW_FLAG_KEEP_SCREEN_ON = 0x00000080, - /** - * Place the window within the entire screen, ignoring - * decorations around the border (such as the status bar). The - * window must correctly position its contents to take the screen - * decoration into account. - */ - AWINDOW_FLAG_LAYOUT_IN_SCREEN = 0x00000100, - /** allow window to extend outside of the screen. */ - AWINDOW_FLAG_LAYOUT_NO_LIMITS = 0x00000200, - /** - * Hide all screen decorations (such as the status - * bar) while this window is displayed. This allows the window to - * use the entire display space for itself -- the status bar will - * be hidden when an app window with this flag set is on the top - * layer. A fullscreen window will ignore a value of {@link - * AWINDOW_SOFT_INPUT_ADJUST_RESIZE}; the window will stay - * fullscreen and will not resize. - */ - AWINDOW_FLAG_FULLSCREEN = 0x00000400, - /** - * Override {@link AWINDOW_FLAG_FULLSCREEN} and force the - * screen decorations (such as the status bar) to be shown. - */ - AWINDOW_FLAG_FORCE_NOT_FULLSCREEN = 0x00000800, - /** - * Turn on dithering when compositing this window to - * the screen. - * @deprecated This flag is no longer used. - */ - AWINDOW_FLAG_DITHER = 0x00001000, - /** - * Treat the content of the window as secure, preventing - * it from appearing in screenshots or from being viewed on non-secure - * displays. - */ - AWINDOW_FLAG_SECURE = 0x00002000, - /** - * A special mode where the layout parameters are used - * to perform scaling of the surface when it is composited to the - * screen. - */ - AWINDOW_FLAG_SCALED = 0x00004000, - /** - * Intended for windows that will often be used when the user is - * holding the screen against their face, it will aggressively - * filter the event stream to prevent unintended presses in this - * situation that may not be desired for a particular window, when - * such an event stream is detected, the application will receive - * a {@link AMOTION_EVENT_ACTION_CANCEL} to indicate this so - * applications can handle this accordingly by taking no action on - * the event until the finger is released. - */ - AWINDOW_FLAG_IGNORE_CHEEK_PRESSES = 0x00008000, - /** - * A special option only for use in combination with - * {@link AWINDOW_FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the - * screen your window may appear on top of or behind screen decorations - * such as the status bar. By also including this flag, the window - * manager will report the inset rectangle needed to ensure your - * content is not covered by screen decorations. - */ - AWINDOW_FLAG_LAYOUT_INSET_DECOR = 0x00010000, - /** - * Invert the state of {@link AWINDOW_FLAG_NOT_FOCUSABLE} with - * respect to how this window interacts with the current method. - * That is, if FLAG_NOT_FOCUSABLE is set and this flag is set, - * then the window will behave as if it needs to interact with the - * input method and thus be placed behind/away from it; if {@link - * AWINDOW_FLAG_NOT_FOCUSABLE} is not set and this flag is set, - * then the window will behave as if it doesn't need to interact - * with the input method and can be placed to use more space and - * cover the input method. - */ - AWINDOW_FLAG_ALT_FOCUSABLE_IM = 0x00020000, - /** - * If you have set {@link AWINDOW_FLAG_NOT_TOUCH_MODAL}, you - * can set this flag to receive a single special MotionEvent with - * the action - * {@link AMOTION_EVENT_ACTION_OUTSIDE} for - * touches that occur outside of your window. Note that you will not - * receive the full down/move/up gesture, only the location of the - * first down as an {@link AMOTION_EVENT_ACTION_OUTSIDE}. - */ - AWINDOW_FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000, - /** - * Special flag to let windows be shown when the screen - * is locked. This will let application windows take precedence over - * key guard or any other lock screens. Can be used with - * {@link AWINDOW_FLAG_KEEP_SCREEN_ON} to turn screen on and display windows - * directly before showing the key guard window. Can be used with - * {@link AWINDOW_FLAG_DISMISS_KEYGUARD} to automatically fully dismisss - * non-secure keyguards. This flag only applies to the top-most - * full-screen window. - */ - AWINDOW_FLAG_SHOW_WHEN_LOCKED = 0x00080000, - /** - * Ask that the system wallpaper be shown behind - * your window. The window surface must be translucent to be able - * to actually see the wallpaper behind it; this flag just ensures - * that the wallpaper surface will be there if this window actually - * has translucent regions. - */ - AWINDOW_FLAG_SHOW_WALLPAPER = 0x00100000, - /** - * When set as a window is being added or made - * visible, once the window has been shown then the system will - * poke the power manager's user activity (as if the user had woken - * up the device) to turn the screen on. - */ - AWINDOW_FLAG_TURN_SCREEN_ON = 0x00200000, - /** - * When set the window will cause the keyguard to - * be dismissed, only if it is not a secure lock keyguard. Because such - * a keyguard is not needed for security, it will never re-appear if - * the user navigates to another window (in contrast to - * {@link AWINDOW_FLAG_SHOW_WHEN_LOCKED}, which will only temporarily - * hide both secure and non-secure keyguards but ensure they reappear - * when the user moves to another UI that doesn't hide them). - * If the keyguard is currently active and is secure (requires an - * unlock pattern) than the user will still need to confirm it before - * seeing this window, unless {@link AWINDOW_FLAG_SHOW_WHEN_LOCKED} has - * also been set. - */ - AWINDOW_FLAG_DISMISS_KEYGUARD = 0x00400000, -}; - -#ifdef __cplusplus -}; -#endif - -#endif // ANDROID_WINDOW_H - -/** @} */ diff --git a/third_party/android_frameworks_native/include/binder/AppOpsManager.h b/third_party/android_frameworks_native/include/binder/AppOpsManager.h deleted file mode 100644 index 1d0e968c4a..0000000000 --- a/third_party/android_frameworks_native/include/binder/AppOpsManager.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2013 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_APP_OPS_MANAGER_H -#define ANDROID_APP_OPS_MANAGER_H - -#include - -#include - -// --------------------------------------------------------------------------- -namespace android { - -class AppOpsManager -{ -public: - enum { - MODE_ALLOWED = IAppOpsService::MODE_ALLOWED, - MODE_IGNORED = IAppOpsService::MODE_IGNORED, - MODE_ERRORED = IAppOpsService::MODE_ERRORED - }; - - enum { - OP_NONE = -1, - OP_COARSE_LOCATION = 0, - OP_FINE_LOCATION = 1, - OP_GPS = 2, - OP_VIBRATE = 3, - OP_READ_CONTACTS = 4, - OP_WRITE_CONTACTS = 5, - OP_READ_CALL_LOG = 6, - OP_WRITE_CALL_LOG = 7, - OP_READ_CALENDAR = 8, - OP_WRITE_CALENDAR = 9, - OP_WIFI_SCAN = 10, - OP_POST_NOTIFICATION = 11, - OP_NEIGHBORING_CELLS = 12, - OP_CALL_PHONE = 13, - OP_READ_SMS = 14, - OP_WRITE_SMS = 15, - OP_RECEIVE_SMS = 16, - OP_RECEIVE_EMERGECY_SMS = 17, - OP_RECEIVE_MMS = 18, - OP_RECEIVE_WAP_PUSH = 19, - OP_SEND_SMS = 20, - OP_READ_ICC_SMS = 21, - OP_WRITE_ICC_SMS = 22, - OP_WRITE_SETTINGS = 23, - OP_SYSTEM_ALERT_WINDOW = 24, - OP_ACCESS_NOTIFICATIONS = 25, - OP_CAMERA = 26, - OP_RECORD_AUDIO = 27, - OP_PLAY_AUDIO = 28, - OP_READ_CLIPBOARD = 29, - OP_WRITE_CLIPBOARD = 30, - OP_TAKE_MEDIA_BUTTONS = 31, - OP_TAKE_AUDIO_FOCUS = 32, - OP_AUDIO_MASTER_VOLUME = 33, - OP_AUDIO_VOICE_VOLUME = 34, - OP_AUDIO_RING_VOLUME = 35, - OP_AUDIO_MEDIA_VOLUME = 36, - OP_AUDIO_ALARM_VOLUME = 37, - OP_AUDIO_NOTIFICATION_VOLUME = 38, - OP_AUDIO_BLUETOOTH_VOLUME = 39, - OP_WAKE_LOCK = 40, - OP_MONITOR_LOCATION = 41, - OP_MONITOR_HIGH_POWER_LOCATION = 42, - OP_GET_USAGE_STATS = 43, - OP_MUTE_MICROPHONE = 44, - OP_TOAST_WINDOW = 45, - OP_PROJECT_MEDIA = 46, - OP_ACTIVATE_VPN = 47, - OP_WRITE_WALLPAPER = 48, - OP_ASSIST_STRUCTURE = 49, - OP_ASSIST_SCREENSHOT = 50, - OP_READ_PHONE_STATE = 51, - OP_ADD_VOICEMAIL = 52, - OP_USE_SIP = 53, - OP_PROCESS_OUTGOING_CALLS = 54, - OP_USE_FINGERPRINT = 55, - OP_BODY_SENSORS = 56, - OP_READ_CELL_BROADCASTS = 57, - OP_MOCK_LOCATION = 58, - OP_READ_EXTERNAL_STORAGE = 59, - OP_WRITE_EXTERNAL_STORAGE = 60, - OP_TURN_SCREEN_ON = 61, - OP_GET_ACCOUNTS = 62, - OP_WIFI_CHANGE = 63, - OP_BLUETOOTH_CHANGE = 64, - OP_BOOT_COMPLETED = 65, - OP_NFC_CHANGE = 66, - OP_DATA_CONNECT_CHANGE = 67, - OP_SU = 68 - }; - - AppOpsManager(); - - int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage); - int32_t noteOp(int32_t op, int32_t uid, const String16& callingPackage); - int32_t startOp(int32_t op, int32_t uid, const String16& callingPackage); - void finishOp(int32_t op, int32_t uid, const String16& callingPackage); - void startWatchingMode(int32_t op, const String16& packageName, - const sp& callback); - void stopWatchingMode(const sp& callback); - int32_t permissionToOpCode(const String16& permission); - -private: - Mutex mLock; - sp mService; - - sp getService(); -}; - - -}; // namespace android -// --------------------------------------------------------------------------- -#endif // ANDROID_APP_OPS_MANAGER_H diff --git a/third_party/android_frameworks_native/include/binder/Binder.h b/third_party/android_frameworks_native/include/binder/Binder.h deleted file mode 100644 index 86628a03d3..0000000000 --- a/third_party/android_frameworks_native/include/binder/Binder.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2008 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_BINDER_H -#define ANDROID_BINDER_H - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -class BBinder : public IBinder -{ -public: - BBinder(); - - virtual const String16& getInterfaceDescriptor() const; - virtual bool isBinderAlive() const; - virtual status_t pingBinder(); - virtual status_t dump(int fd, const Vector& args); - - virtual status_t transact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - - virtual status_t linkToDeath(const sp& recipient, - void* cookie = NULL, - uint32_t flags = 0); - - virtual status_t unlinkToDeath( const wp& recipient, - void* cookie = NULL, - uint32_t flags = 0, - wp* outRecipient = NULL); - - virtual void attachObject( const void* objectID, - void* object, - void* cleanupCookie, - object_cleanup_func func); - virtual void* findObject(const void* objectID) const; - virtual void detachObject(const void* objectID); - - virtual BBinder* localBinder(); - -protected: - virtual ~BBinder(); - - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - -private: - BBinder(const BBinder& o); - BBinder& operator=(const BBinder& o); - - class Extras; - - atomic_uintptr_t mExtras; // should be atomic - void* mReserved0; -}; - -// --------------------------------------------------------------------------- - -class BpRefBase : public virtual RefBase -{ -protected: - BpRefBase(const sp& o); - virtual ~BpRefBase(); - virtual void onFirstRef(); - virtual void onLastStrongRef(const void* id); - virtual bool onIncStrongAttempted(uint32_t flags, const void* id); - - inline IBinder* remote() { return mRemote; } - inline IBinder* remote() const { return mRemote; } - -private: - BpRefBase(const BpRefBase& o); - BpRefBase& operator=(const BpRefBase& o); - - IBinder* const mRemote; - RefBase::weakref_type* mRefs; - volatile int32_t mState; -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_BINDER_H diff --git a/third_party/android_frameworks_native/include/binder/BinderService.h b/third_party/android_frameworks_native/include/binder/BinderService.h deleted file mode 100644 index ef703bda90..0000000000 --- a/third_party/android_frameworks_native/include/binder/BinderService.h +++ /dev/null @@ -1,65 +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_BINDER_SERVICE_H -#define ANDROID_BINDER_SERVICE_H - -#include - -#include -#include - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -template -class BinderService -{ -public: - static status_t publish(bool allowIsolated = false) { - sp sm(defaultServiceManager()); - return sm->addService( - String16(SERVICE::getServiceName()), - new SERVICE(), allowIsolated); - } - - static void publishAndJoinThreadPool(bool allowIsolated = false) { - publish(allowIsolated); - joinThreadPool(); - } - - static void instantiate() { publish(); } - - static status_t shutdown() { return NO_ERROR; } - -private: - static void joinThreadPool() { - sp ps(ProcessState::self()); - ps->startThreadPool(); - ps->giveThreadPoolName(); - IPCThreadState::self()->joinThreadPool(); - } -}; - - -}; // namespace android -// --------------------------------------------------------------------------- -#endif // ANDROID_BINDER_SERVICE_H diff --git a/third_party/android_frameworks_native/include/binder/BpBinder.h b/third_party/android_frameworks_native/include/binder/BpBinder.h deleted file mode 100644 index 7ef93aa390..0000000000 --- a/third_party/android_frameworks_native/include/binder/BpBinder.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2005 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_BPBINDER_H -#define ANDROID_BPBINDER_H - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -class BpBinder : public IBinder -{ -public: - BpBinder(int32_t handle); - - inline int32_t handle() const { return mHandle; } - - virtual const String16& getInterfaceDescriptor() const; - virtual bool isBinderAlive() const; - virtual status_t pingBinder(); - virtual status_t dump(int fd, const Vector& args); - - virtual status_t transact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - - virtual status_t linkToDeath(const sp& recipient, - void* cookie = NULL, - uint32_t flags = 0); - virtual status_t unlinkToDeath( const wp& recipient, - void* cookie = NULL, - uint32_t flags = 0, - wp* outRecipient = NULL); - - virtual void attachObject( const void* objectID, - void* object, - void* cleanupCookie, - object_cleanup_func func); - virtual void* findObject(const void* objectID) const; - virtual void detachObject(const void* objectID); - - virtual BpBinder* remoteBinder(); - - status_t setConstantData(const void* data, size_t size); - void sendObituary(); - - class ObjectManager - { - public: - ObjectManager(); - ~ObjectManager(); - - void attach( const void* objectID, - void* object, - void* cleanupCookie, - IBinder::object_cleanup_func func); - void* find(const void* objectID) const; - void detach(const void* objectID); - - void kill(); - - private: - ObjectManager(const ObjectManager&); - ObjectManager& operator=(const ObjectManager&); - - struct entry_t - { - void* object; - void* cleanupCookie; - IBinder::object_cleanup_func func; - }; - - KeyedVector mObjects; - }; - -protected: - virtual ~BpBinder(); - virtual void onFirstRef(); - virtual void onLastStrongRef(const void* id); - virtual bool onIncStrongAttempted(uint32_t flags, const void* id); - -private: - const int32_t mHandle; - - struct Obituary { - wp recipient; - void* cookie; - uint32_t flags; - }; - - void reportOneDeath(const Obituary& obit); - bool isDescriptorCached() const; - - mutable Mutex mLock; - volatile int32_t mAlive; - volatile int32_t mObitsSent; - Vector* mObituaries; - ObjectManager mObjects; - Parcel* mConstantData; - mutable String16 mDescriptorCache; -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_BPBINDER_H diff --git a/third_party/android_frameworks_native/include/binder/BufferedTextOutput.h b/third_party/android_frameworks_native/include/binder/BufferedTextOutput.h deleted file mode 100644 index 9a7c43bb13..0000000000 --- a/third_party/android_frameworks_native/include/binder/BufferedTextOutput.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2006 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_BUFFEREDTEXTOUTPUT_H -#define ANDROID_BUFFEREDTEXTOUTPUT_H - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -class BufferedTextOutput : public TextOutput -{ -public: - //** Flags for constructor */ - enum { - MULTITHREADED = 0x0001 - }; - - BufferedTextOutput(uint32_t flags = 0); - virtual ~BufferedTextOutput(); - - virtual status_t print(const char* txt, size_t len); - virtual void moveIndent(int delta); - - virtual void pushBundle(); - virtual void popBundle(); - -protected: - virtual status_t writeLines(const struct iovec& vec, size_t N) = 0; - -private: - struct BufferState; - struct ThreadState; - - static ThreadState*getThreadState(); - static void threadDestructor(void *st); - - BufferState*getBuffer() const; - - uint32_t mFlags; - const int32_t mSeq; - const int32_t mIndex; - - Mutex mLock; - BufferState* mGlobalState; -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_BUFFEREDTEXTOUTPUT_H diff --git a/third_party/android_frameworks_native/include/binder/Debug.h b/third_party/android_frameworks_native/include/binder/Debug.h deleted file mode 100644 index f6a335502f..0000000000 --- a/third_party/android_frameworks_native/include/binder/Debug.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005 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_BINDER_DEBUG_H -#define ANDROID_BINDER_DEBUG_H - -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -#ifdef __cplusplus -extern "C" { -#endif - -const char* stringForIndent(int32_t indentLevel); - -typedef void (*debugPrintFunc)(void* cookie, const char* txt); - -void printTypeCode(uint32_t typeCode, - debugPrintFunc func = 0, void* cookie = 0); - -void printHexData(int32_t indent, const void *buf, size_t length, - size_t bytesPerLine=16, int32_t singleLineBytesCutoff=16, - size_t alignment=0, bool cArrayStyle=false, - debugPrintFunc func = 0, void* cookie = 0); - -#ifdef __cplusplus -} -#endif - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_BINDER_DEBUG_H diff --git a/third_party/android_frameworks_native/include/binder/IAppOpsCallback.h b/third_party/android_frameworks_native/include/binder/IAppOpsCallback.h deleted file mode 100644 index 7f8eb0168b..0000000000 --- a/third_party/android_frameworks_native/include/binder/IAppOpsCallback.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2013 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_IAPP_OPS_CALLBACK_H -#define ANDROID_IAPP_OPS_CALLBACK_H - -#include - -namespace android { - -// ---------------------------------------------------------------------- - -class IAppOpsCallback : public IInterface -{ -public: - DECLARE_META_INTERFACE(AppOpsCallback); - - virtual void opChanged(int32_t op, const String16& packageName) = 0; - - enum { - OP_CHANGED_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION - }; -}; - -// ---------------------------------------------------------------------- - -class BnAppOpsCallback : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IAPP_OPS_CALLBACK_H - diff --git a/third_party/android_frameworks_native/include/binder/IAppOpsService.h b/third_party/android_frameworks_native/include/binder/IAppOpsService.h deleted file mode 100644 index cd81efa363..0000000000 --- a/third_party/android_frameworks_native/include/binder/IAppOpsService.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2013 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_IAPP_OPS_SERVICE_H -#define ANDROID_IAPP_OPS_SERVICE_H - -#include -#include - -namespace android { - -// ---------------------------------------------------------------------- - -class IAppOpsService : public IInterface -{ -public: - DECLARE_META_INTERFACE(AppOpsService); - - virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0; - virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName) = 0; - virtual int32_t startOperation(const sp& token, int32_t code, int32_t uid, - const String16& packageName) = 0; - virtual void finishOperation(const sp& token, int32_t code, int32_t uid, - const String16& packageName) = 0; - virtual void startWatchingMode(int32_t op, const String16& packageName, - const sp& callback) = 0; - virtual void stopWatchingMode(const sp& callback) = 0; - virtual sp getToken(const sp& clientToken) = 0; - virtual int32_t permissionToOpCode(const String16& permission) = 0; - - enum { - CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, - NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1, - START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2, - FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3, - START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4, - STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5, - GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6, - PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7, - }; - - enum { - MODE_ALLOWED = 0, - MODE_IGNORED = 1, - MODE_ERRORED = 2 - }; -}; - -// ---------------------------------------------------------------------- - -class BnAppOpsService : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IAPP_OPS_SERVICE_H diff --git a/third_party/android_frameworks_native/include/binder/IBatteryStats.h b/third_party/android_frameworks_native/include/binder/IBatteryStats.h deleted file mode 100644 index 5f3818652b..0000000000 --- a/third_party/android_frameworks_native/include/binder/IBatteryStats.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013 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_IBATTERYSTATS_H -#define ANDROID_IBATTERYSTATS_H - -#include - -namespace android { - -// ---------------------------------------------------------------------- - -class IBatteryStats : public IInterface -{ -public: - DECLARE_META_INTERFACE(BatteryStats); - - virtual void noteStartSensor(int uid, int sensor) = 0; - virtual void noteStopSensor(int uid, int sensor) = 0; - virtual void noteStartVideo(int uid) = 0; - virtual void noteStopVideo(int uid) = 0; - virtual void noteStartAudio(int uid) = 0; - virtual void noteStopAudio(int uid) = 0; - virtual void noteResetVideo() = 0; - virtual void noteResetAudio() = 0; - virtual void noteFlashlightOn(int uid) = 0; - virtual void noteFlashlightOff(int uid) = 0; - virtual void noteStartCamera(int uid) = 0; - virtual void noteStopCamera(int uid) = 0; - virtual void noteResetCamera() = 0; - virtual void noteResetFlashlight() = 0; - - enum { - NOTE_START_SENSOR_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, - NOTE_STOP_SENSOR_TRANSACTION, - NOTE_START_VIDEO_TRANSACTION, - NOTE_STOP_VIDEO_TRANSACTION, - NOTE_START_AUDIO_TRANSACTION, - NOTE_STOP_AUDIO_TRANSACTION, - NOTE_RESET_VIDEO_TRANSACTION, - NOTE_RESET_AUDIO_TRANSACTION, - NOTE_FLASHLIGHT_ON_TRANSACTION, - NOTE_FLASHLIGHT_OFF_TRANSACTION, - NOTE_START_CAMERA_TRANSACTION, - NOTE_STOP_CAMERA_TRANSACTION, - NOTE_RESET_CAMERA_TRANSACTION, - NOTE_RESET_FLASHLIGHT_TRANSACTION - }; -}; - -// ---------------------------------------------------------------------- - -class BnBatteryStats : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IBATTERYSTATS_H diff --git a/third_party/android_frameworks_native/include/binder/IBinder.h b/third_party/android_frameworks_native/include/binder/IBinder.h deleted file mode 100644 index 43b654334b..0000000000 --- a/third_party/android_frameworks_native/include/binder/IBinder.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2008 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_IBINDER_H -#define ANDROID_IBINDER_H - -#include -#include -#include -#include - - -#define B_PACK_CHARS(c1, c2, c3, c4) \ - ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) - -// --------------------------------------------------------------------------- -namespace android { - -class BBinder; -class BpBinder; -class IInterface; -class Parcel; - -/** - * Base class and low-level protocol for a remotable object. - * You can derive from this class to create an object for which other - * processes can hold references to it. Communication between processes - * (method calls, property get and set) is down through a low-level - * protocol implemented on top of the transact() API. - */ -class IBinder : public virtual RefBase -{ -public: - enum { - FIRST_CALL_TRANSACTION = 0x00000001, - LAST_CALL_TRANSACTION = 0x00ffffff, - - PING_TRANSACTION = B_PACK_CHARS('_','P','N','G'), - DUMP_TRANSACTION = B_PACK_CHARS('_','D','M','P'), - INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'), - SYSPROPS_TRANSACTION = B_PACK_CHARS('_', 'S', 'P', 'R'), - - // Corresponds to TF_ONE_WAY -- an asynchronous call. - FLAG_ONEWAY = 0x00000001 - }; - - IBinder(); - - /** - * Check if this IBinder implements the interface named by - * @a descriptor. If it does, the base pointer to it is returned, - * which you can safely static_cast<> to the concrete C++ interface. - */ - virtual sp queryLocalInterface(const String16& descriptor); - - /** - * Return the canonical name of the interface provided by this IBinder - * object. - */ - virtual const String16& getInterfaceDescriptor() const = 0; - - virtual bool isBinderAlive() const = 0; - virtual status_t pingBinder() = 0; - virtual status_t dump(int fd, const Vector& args) = 0; - - virtual status_t transact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0) = 0; - - class DeathRecipient : public virtual RefBase - { - public: - virtual void binderDied(const wp& who) = 0; - }; - - /** - * Register the @a recipient for a notification if this binder - * goes away. If this binder object unexpectedly goes away - * (typically because its hosting process has been killed), - * then DeathRecipient::binderDied() will be called with a reference - * to this. - * - * The @a cookie is optional -- if non-NULL, it should be a - * memory address that you own (that is, you know it is unique). - * - * @note You will only receive death notifications for remote binders, - * as local binders by definition can't die without you dying as well. - * Trying to use this function on a local binder will result in an - * INVALID_OPERATION code being returned and nothing happening. - * - * @note This link always holds a weak reference to its recipient. - * - * @note You will only receive a weak reference to the dead - * binder. You should not try to promote this to a strong reference. - * (Nor should you need to, as there is nothing useful you can - * directly do with it now that it has passed on.) - */ - virtual status_t linkToDeath(const sp& recipient, - void* cookie = NULL, - uint32_t flags = 0) = 0; - - /** - * Remove a previously registered death notification. - * The @a recipient will no longer be called if this object - * dies. The @a cookie is optional. If non-NULL, you can - * supply a NULL @a recipient, and the recipient previously - * added with that cookie will be unlinked. - */ - virtual status_t unlinkToDeath( const wp& recipient, - void* cookie = NULL, - uint32_t flags = 0, - wp* outRecipient = NULL) = 0; - - virtual bool checkSubclass(const void* subclassID) const; - - typedef void (*object_cleanup_func)(const void* id, void* obj, void* cleanupCookie); - - virtual void attachObject( const void* objectID, - void* object, - void* cleanupCookie, - object_cleanup_func func) = 0; - virtual void* findObject(const void* objectID) const = 0; - virtual void detachObject(const void* objectID) = 0; - - virtual BBinder* localBinder(); - virtual BpBinder* remoteBinder(); - -protected: - virtual ~IBinder(); - -private: -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_IBINDER_H diff --git a/third_party/android_frameworks_native/include/binder/IInterface.h b/third_party/android_frameworks_native/include/binder/IInterface.h deleted file mode 100644 index 4ce361380d..0000000000 --- a/third_party/android_frameworks_native/include/binder/IInterface.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2005 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_IINTERFACE_H -#define ANDROID_IINTERFACE_H - -#include - -namespace android { - -// ---------------------------------------------------------------------- - -class IInterface : public virtual RefBase -{ -public: - IInterface(); - static sp asBinder(const IInterface*); - static sp asBinder(const sp&); - -protected: - virtual ~IInterface(); - virtual IBinder* onAsBinder() = 0; -}; - -// ---------------------------------------------------------------------- - -template -inline sp interface_cast(const sp& obj) -{ - return INTERFACE::asInterface(obj); -} - -// ---------------------------------------------------------------------- - -template -class BnInterface : public INTERFACE, public BBinder -{ -public: - virtual sp queryLocalInterface(const String16& _descriptor); - virtual const String16& getInterfaceDescriptor() const; - -protected: - virtual IBinder* onAsBinder(); -}; - -// ---------------------------------------------------------------------- - -template -class BpInterface : public INTERFACE, public BpRefBase -{ -public: - BpInterface(const sp& remote); - -protected: - virtual IBinder* onAsBinder(); -}; - -// ---------------------------------------------------------------------- - -#define DECLARE_META_INTERFACE(INTERFACE) \ - static const android::String16 descriptor; \ - static android::sp asInterface( \ - const android::sp& obj); \ - virtual const android::String16& getInterfaceDescriptor() const; \ - I##INTERFACE(); \ - virtual ~I##INTERFACE(); \ - - -#define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ - const android::String16 I##INTERFACE::descriptor(NAME); \ - const android::String16& \ - I##INTERFACE::getInterfaceDescriptor() const { \ - return I##INTERFACE::descriptor; \ - } \ - android::sp I##INTERFACE::asInterface( \ - const android::sp& obj) \ - { \ - android::sp intr; \ - if (obj != NULL) { \ - intr = static_cast( \ - obj->queryLocalInterface( \ - I##INTERFACE::descriptor).get()); \ - if (intr == NULL) { \ - intr = new Bp##INTERFACE(obj); \ - } \ - } \ - return intr; \ - } \ - I##INTERFACE::I##INTERFACE() { } \ - I##INTERFACE::~I##INTERFACE() { } \ - - -#define CHECK_INTERFACE(interface, data, reply) \ - if (!data.checkInterface(this)) { return PERMISSION_DENIED; } \ - - -// ---------------------------------------------------------------------- -// No user-serviceable parts after this... - -template -inline sp BnInterface::queryLocalInterface( - const String16& _descriptor) -{ - if (_descriptor == INTERFACE::descriptor) return this; - return NULL; -} - -template -inline const String16& BnInterface::getInterfaceDescriptor() const -{ - return INTERFACE::getInterfaceDescriptor(); -} - -template -IBinder* BnInterface::onAsBinder() -{ - return this; -} - -template -inline BpInterface::BpInterface(const sp& remote) - : BpRefBase(remote) -{ -} - -template -inline IBinder* BpInterface::onAsBinder() -{ - return remote(); -} - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IINTERFACE_H diff --git a/third_party/android_frameworks_native/include/binder/IMemory.h b/third_party/android_frameworks_native/include/binder/IMemory.h deleted file mode 100644 index 178ef85937..0000000000 --- a/third_party/android_frameworks_native/include/binder/IMemory.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2007 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_IMEMORY_H -#define ANDROID_IMEMORY_H - -#include -#include -#include - -#include -#include -#include - -namespace android { - -// ---------------------------------------------------------------------------- - -class IMemoryHeap : public IInterface -{ -public: - DECLARE_META_INTERFACE(MemoryHeap); - - // flags returned by getFlags() - enum { - READ_ONLY = 0x00000001, -#ifdef USE_MEMORY_HEAP_ION - USE_ION_FD = 0x00008000 -#else - USE_ION_FD = 0x00000008 -#endif - }; - - virtual int getHeapID() const = 0; - virtual void* getBase() const = 0; - virtual size_t getSize() const = 0; - virtual uint32_t getFlags() const = 0; - virtual uint32_t getOffset() const = 0; - - // these are there just for backward source compatibility - int32_t heapID() const { return getHeapID(); } - void* base() const { return getBase(); } - size_t virtualSize() const { return getSize(); } -}; - -class BnMemoryHeap : public BnInterface -{ -public: - virtual status_t onTransact( - uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - - BnMemoryHeap(); -protected: - virtual ~BnMemoryHeap(); -}; - -// ---------------------------------------------------------------------------- - -class IMemory : public IInterface -{ -public: - DECLARE_META_INTERFACE(Memory); - - virtual sp getMemory(ssize_t* offset=0, size_t* size=0) const = 0; - - // helpers - void* fastPointer(const sp& heap, ssize_t offset) const; - void* pointer() const; - size_t size() const; - ssize_t offset() const; -}; - -class BnMemory : public BnInterface -{ -public: - virtual status_t onTransact( - uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); - - BnMemory(); -protected: - virtual ~BnMemory(); -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IMEMORY_H diff --git a/third_party/android_frameworks_native/include/binder/IPCThreadState.h b/third_party/android_frameworks_native/include/binder/IPCThreadState.h deleted file mode 100644 index 1853cff235..0000000000 --- a/third_party/android_frameworks_native/include/binder/IPCThreadState.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2005 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_IPC_THREAD_STATE_H -#define ANDROID_IPC_THREAD_STATE_H - -#include -#include -#include -#include - -#if defined(_WIN32) -typedef int uid_t; -#endif - -// --------------------------------------------------------------------------- -namespace android { - -class IPCThreadState -{ -public: - static IPCThreadState* self(); - static IPCThreadState* selfOrNull(); // self(), but won't instantiate - - sp process(); - - status_t clearLastError(); - - pid_t getCallingPid() const; - uid_t getCallingUid() const; - - void setStrictModePolicy(int32_t policy); - int32_t getStrictModePolicy() const; - - void setLastTransactionBinderFlags(int32_t flags); - int32_t getLastTransactionBinderFlags() const; - - int64_t clearCallingIdentity(); - void restoreCallingIdentity(int64_t token); - - int setupPolling(int* fd); - status_t handlePolledCommands(); - void flushCommands(); - - void joinThreadPool(bool isMain = true); - - // Stop the local process. - void stopProcess(bool immediate = true); - - status_t transact(int32_t handle, - uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags); - - void incStrongHandle(int32_t handle); - void decStrongHandle(int32_t handle); - void incWeakHandle(int32_t handle); - void decWeakHandle(int32_t handle); - status_t attemptIncStrongHandle(int32_t handle); - static void expungeHandle(int32_t handle, IBinder* binder); - status_t requestDeathNotification( int32_t handle, - BpBinder* proxy); - status_t clearDeathNotification( int32_t handle, - BpBinder* proxy); - - static void shutdown(); - - // Call this to disable switching threads to background scheduling when - // receiving incoming IPC calls. This is specifically here for the - // Android system process, since it expects to have background apps calling - // in to it but doesn't want to acquire locks in its services while in - // the background. - static void disableBackgroundScheduling(bool disable); - - // Call blocks until the number of executing binder threads is less than - // the maximum number of binder threads threads allowed for this process. - void blockUntilThreadAvailable(); - -private: - IPCThreadState(); - ~IPCThreadState(); - - status_t sendReply(const Parcel& reply, uint32_t flags); - status_t waitForResponse(Parcel *reply, - status_t *acquireResult=NULL); - status_t talkWithDriver(bool doReceive=true); - status_t writeTransactionData(int32_t cmd, - uint32_t binderFlags, - int32_t handle, - uint32_t code, - const Parcel& data, - status_t* statusBuffer); - status_t getAndExecuteCommand(); - status_t executeCommand(int32_t command); - void processPendingDerefs(); - - void clearCaller(); - - static void threadDestructor(void *st); - static void freeBuffer(Parcel* parcel, - const uint8_t* data, size_t dataSize, - const binder_size_t* objects, size_t objectsSize, - void* cookie); - - const sp mProcess; - const pid_t mMyThreadId; - Vector mPendingStrongDerefs; - Vector mPendingWeakDerefs; - - Parcel mIn; - Parcel mOut; - status_t mLastError; - pid_t mCallingPid; - uid_t mCallingUid; - int32_t mStrictModePolicy; - int32_t mLastTransactionBinderFlags; -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_IPC_THREAD_STATE_H diff --git a/third_party/android_frameworks_native/include/binder/IPermissionController.h b/third_party/android_frameworks_native/include/binder/IPermissionController.h deleted file mode 100644 index 4e5fb34838..0000000000 --- a/third_party/android_frameworks_native/include/binder/IPermissionController.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2005 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_IPERMISSION_CONTROLLER_H -#define ANDROID_IPERMISSION_CONTROLLER_H - -#include -#include - -namespace android { - -// ---------------------------------------------------------------------- - -class IPermissionController : public IInterface -{ -public: - DECLARE_META_INTERFACE(PermissionController); - - virtual bool checkPermission(const String16& permission, int32_t pid, int32_t uid) = 0; - - virtual void getPackagesForUid(const uid_t uid, Vector &packages) = 0; - - virtual bool isRuntimePermission(const String16& permission) = 0; - - enum { - CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, - GET_PACKAGES_FOR_UID_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + 1, - IS_RUNTIME_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + 2 - }; -}; - -// ---------------------------------------------------------------------- - -class BnPermissionController : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_IPERMISSION_CONTROLLER_H - diff --git a/third_party/android_frameworks_native/include/binder/IProcessInfoService.h b/third_party/android_frameworks_native/include/binder/IProcessInfoService.h deleted file mode 100644 index dc62f457c7..0000000000 --- a/third_party/android_frameworks_native/include/binder/IProcessInfoService.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2015 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_I_PROCESS_INFO_SERVICE_H -#define ANDROID_I_PROCESS_INFO_SERVICE_H - -#include - -namespace android { - -// ---------------------------------------------------------------------- - -class IProcessInfoService : public IInterface { -public: - DECLARE_META_INTERFACE(ProcessInfoService); - - virtual status_t getProcessStatesFromPids( size_t length, - /*in*/ int32_t* pids, - /*out*/ int32_t* states) = 0; - - enum { - GET_PROCESS_STATES_FROM_PIDS = IBinder::FIRST_CALL_TRANSACTION, - }; -}; - -// ---------------------------------------------------------------------- - -class BnProcessInfoService : public BnInterface { -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_I_PROCESS_INFO_SERVICE_H diff --git a/third_party/android_frameworks_native/include/binder/IServiceManager.h b/third_party/android_frameworks_native/include/binder/IServiceManager.h deleted file mode 100644 index 2c297d64fb..0000000000 --- a/third_party/android_frameworks_native/include/binder/IServiceManager.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2005 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_ISERVICE_MANAGER_H -#define ANDROID_ISERVICE_MANAGER_H - -#include -#include -#include -#include - -namespace android { - -// ---------------------------------------------------------------------- - -class IServiceManager : public IInterface -{ -public: - DECLARE_META_INTERFACE(ServiceManager); - - /** - * Retrieve an existing service, blocking for a few seconds - * if it doesn't yet exist. - */ - virtual sp getService( const String16& name) const = 0; - - /** - * Retrieve an existing service, non-blocking. - */ - virtual sp checkService( const String16& name) const = 0; - - /** - * Register a service. - */ - virtual status_t addService( const String16& name, - const sp& service, - bool allowIsolated = false) = 0; - - /** - * Return list of all existing services. - */ - virtual Vector listServices() = 0; - - enum { - GET_SERVICE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, - CHECK_SERVICE_TRANSACTION, - ADD_SERVICE_TRANSACTION, - LIST_SERVICES_TRANSACTION, - }; -}; - -sp defaultServiceManager(); - -template -status_t getService(const String16& name, sp* outService) -{ - const sp sm = defaultServiceManager(); - if (sm != NULL) { - *outService = interface_cast(sm->getService(name)); - if ((*outService) != NULL) return NO_ERROR; - } - return NAME_NOT_FOUND; -} - -bool checkCallingPermission(const String16& permission); -bool checkCallingPermission(const String16& permission, - int32_t* outPid, int32_t* outUid); -bool checkPermission(const String16& permission, pid_t pid, uid_t uid); - - -// ---------------------------------------------------------------------- - -class BnServiceManager : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_ISERVICE_MANAGER_H - diff --git a/third_party/android_frameworks_native/include/binder/MemoryBase.h b/third_party/android_frameworks_native/include/binder/MemoryBase.h deleted file mode 100644 index 463e26d977..0000000000 --- a/third_party/android_frameworks_native/include/binder/MemoryBase.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 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_MEMORY_BASE_H -#define ANDROID_MEMORY_BASE_H - -#include -#include - -#include - - -namespace android { - -// --------------------------------------------------------------------------- - -class MemoryBase : public BnMemory -{ -public: - MemoryBase(const sp& heap, ssize_t offset, size_t size); - virtual ~MemoryBase(); - virtual sp getMemory(ssize_t* offset, size_t* size) const; - -protected: - size_t getSize() const { return mSize; } - ssize_t getOffset() const { return mOffset; } - const sp& getHeap() const { return mHeap; } - -private: - size_t mSize; - ssize_t mOffset; - sp mHeap; -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_MEMORY_BASE_H diff --git a/third_party/android_frameworks_native/include/binder/MemoryDealer.h b/third_party/android_frameworks_native/include/binder/MemoryDealer.h deleted file mode 100644 index aa415d5ac8..0000000000 --- a/third_party/android_frameworks_native/include/binder/MemoryDealer.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2007 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_MEMORY_DEALER_H -#define ANDROID_MEMORY_DEALER_H - - -#include -#include - -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class SimpleBestFitAllocator; - -// ---------------------------------------------------------------------------- - -class MemoryDealer : public RefBase -{ -public: - MemoryDealer(size_t size, const char* name = 0, - uint32_t flags = 0 /* or bits such as MemoryHeapBase::READ_ONLY */ ); - - virtual sp allocate(size_t size); - virtual void deallocate(size_t offset); - virtual void dump(const char* what) const; - - sp getMemoryHeap() const { return heap(); } - -protected: - virtual ~MemoryDealer(); - -private: - const sp& heap() const; - SimpleBestFitAllocator* allocator() const; - - sp mHeap; - SimpleBestFitAllocator* mAllocator; -}; - - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_MEMORY_DEALER_H diff --git a/third_party/android_frameworks_native/include/binder/MemoryHeapBase.h b/third_party/android_frameworks_native/include/binder/MemoryHeapBase.h deleted file mode 100644 index ea9b66c497..0000000000 --- a/third_party/android_frameworks_native/include/binder/MemoryHeapBase.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2008 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_MEMORY_HEAP_BASE_H -#define ANDROID_MEMORY_HEAP_BASE_H - -#include -#include - -#include - - -namespace android { - -// --------------------------------------------------------------------------- - -class MemoryHeapBase : public virtual BnMemoryHeap -{ -public: - enum { - READ_ONLY = IMemoryHeap::READ_ONLY, - // memory won't be mapped locally, but will be mapped in the remote - // process. - DONT_MAP_LOCALLY = 0x00000100, - NO_CACHING = 0x00000200 - }; - - /* - * maps the memory referenced by fd. but DOESN'T take ownership - * of the filedescriptor (it makes a copy with dup() - */ - MemoryHeapBase(int fd, size_t size, uint32_t flags = 0, uint32_t offset = 0); - - /* - * maps memory from the given device - */ - MemoryHeapBase(const char* device, size_t size = 0, uint32_t flags = 0); - - /* - * maps memory from ashmem, with the given name for debugging - */ - MemoryHeapBase(size_t size, uint32_t flags = 0, char const* name = NULL); - - virtual ~MemoryHeapBase(); - - /* implement IMemoryHeap interface */ - virtual int getHeapID() const; - - /* virtual address of the heap. returns MAP_FAILED in case of error */ - virtual void* getBase() const; - - virtual size_t getSize() const; - virtual uint32_t getFlags() const; - virtual uint32_t getOffset() const; - - const char* getDevice() const; - - /* this closes this heap -- use carefully */ - void dispose(); - - /* this is only needed as a workaround, use only if you know - * what you are doing */ - status_t setDevice(const char* device) { - if (mDevice == 0) - mDevice = device; - return mDevice ? NO_ERROR : ALREADY_EXISTS; - } - -protected: - MemoryHeapBase(); - // init() takes ownership of fd - status_t init(int fd, void *base, int size, - int flags = 0, const char* device = NULL); - -private: - status_t mapfd(int fd, size_t size, uint32_t offset = 0); - - int mFD; - size_t mSize; - void* mBase; - uint32_t mFlags; - const char* mDevice; - bool mNeedUnmap; - uint32_t mOffset; -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_MEMORY_HEAP_BASE_H diff --git a/third_party/android_frameworks_native/include/binder/MemoryHeapIon.h b/third_party/android_frameworks_native/include/binder/MemoryHeapIon.h deleted file mode 100644 index 7e059f4eac..0000000000 --- a/third_party/android_frameworks_native/include/binder/MemoryHeapIon.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * Copyright 2011, Samsung Electronics Co. LTD - * - * 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. - */ -/*! - * \file MemoryHeapIon.h - * \brief header file for MemoryHeapIon - * \author MinGu, Jeon(mingu85.jeon) - * \date 2011/11/20 - * - * Revision History: - * - 2011/11/21 : MinGu, Jeon(mingu85.jeon)) \n - * Initial version - * - 2012/11/29 : MinGu, Jeon(mingu85.jeon)) \n - * Change name - */ - -#ifndef ANDROID_MEMORY_HEAP_ION_H -#define ANDROID_MEMORY_HEAP_ION_H - -#include -#include -#include - -#define MHB_ION_HEAP_SYSTEM_CONTIG_MASK (1 << 1) -#define MHB_ION_HEAP_EXYNOS_CONTIG_MASK (1 << 4) -#define MHB_ION_HEAP_EXYNOS_MASK (1 << 5) -#define MHB_ION_HEAP_SYSTEM_MASK (1 << 6) - -#define MHB_ION_FLAG_CACHED (1 << 16) -#define MHB_ION_FLAG_CACHED_NEEDS_SYNC (1 << 17) -#define MHB_ION_FLAG_PRESERVE_KMAP (1 << 18) - -#define MHB_ION_EXYNOS_VIDEO_MASK (1 << 21) -#define MHB_ION_EXYNOS_MFC_INPUT_MASK (1 << 25) -#define MHB_ION_EXYNOS_MFC_OUTPUT_MASK (1 << 26) -#define MHB_ION_EXYNOS_GSC_MASK (1 << 27) -#define MHB_ION_EXYNOS_FIMD_VIDEO_MASK (1 << 28) - -namespace android { - -class MemoryHeapIon : public MemoryHeapBase -{ -public: - enum { - USE_ION_FD = IMemoryHeap::USE_ION_FD - }; - MemoryHeapIon(size_t size, uint32_t flags = 0, char const* name = NULL); - MemoryHeapIon(int fd, size_t size, uint32_t flags = 0, uint32_t offset = 0); - ~MemoryHeapIon(); -private: - int mIonClient; -}; - -}; -#endif diff --git a/third_party/android_frameworks_native/include/binder/Parcel.h b/third_party/android_frameworks_native/include/binder/Parcel.h deleted file mode 100644 index 91ffae0ba3..0000000000 --- a/third_party/android_frameworks_native/include/binder/Parcel.h +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright (C) 2005 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_PARCEL_H -#define ANDROID_PARCEL_H - -#include -#include -#include -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -template class Flattenable; -template class LightFlattenable; -class IBinder; -class IPCThreadState; -class ProcessState; -class String8; -class TextOutput; - -class Parcel { - friend class IPCThreadState; -public: - class ReadableBlob; - class WritableBlob; - - Parcel(); - ~Parcel(); - - const uint8_t* data() const; - size_t dataSize() const; - size_t dataAvail() const; - size_t dataPosition() const; - size_t dataCapacity() const; - - status_t setDataSize(size_t size); - void setDataPosition(size_t pos) const; - status_t setDataCapacity(size_t size); - - status_t setData(const uint8_t* buffer, size_t len); - - status_t appendFrom(const Parcel *parcel, - size_t start, size_t len); - - bool allowFds() const; - bool pushAllowFds(bool allowFds); - void restoreAllowFds(bool lastValue); - - bool hasFileDescriptors() const; - - // Writes the RPC header. - status_t writeInterfaceToken(const String16& interface); - - // Parses the RPC header, returning true if the interface name - // in the header matches the expected interface from the caller. - // - // Additionally, enforceInterface does part of the work of - // propagating the StrictMode policy mask, populating the current - // IPCThreadState, which as an optimization may optionally be - // passed in. - bool enforceInterface(const String16& interface, - IPCThreadState* threadState = NULL) const; - bool checkInterface(IBinder*) const; - - void freeData(); - -private: - const binder_size_t* objects() const; - -public: - size_t objectsCount() const; - - status_t errorCheck() const; - void setError(status_t err); - - status_t write(const void* data, size_t len); - void* writeInplace(size_t len); - status_t writeUnpadded(const void* data, size_t len); - status_t writeInt32(int32_t val); - status_t writeUint32(uint32_t val); - status_t writeInt64(int64_t val); - status_t writeUint64(uint64_t val); - status_t writeFloat(float val); - status_t writeDouble(double val); - status_t writeCString(const char* str); - status_t writeString8(const String8& str); - status_t writeString16(const String16& str); - status_t writeString16(const char16_t* str, size_t len); - status_t writeStrongBinder(const sp& val); - status_t writeWeakBinder(const wp& val); - status_t writeInt32Array(size_t len, const int32_t *val); - status_t writeByteArray(size_t len, const uint8_t *val); - - template - status_t write(const Flattenable& val); - - template - status_t write(const LightFlattenable& val); - - - // Place a native_handle into the parcel (the native_handle's file- - // descriptors are dup'ed, so it is safe to delete the native_handle - // when this function returns). - // Doesn't take ownership of the native_handle. - status_t writeNativeHandle(const native_handle* handle); - - // Place a file descriptor into the parcel. The given fd must remain - // valid for the lifetime of the parcel. - // The Parcel does not take ownership of the given fd unless you ask it to. - status_t writeFileDescriptor(int fd, bool takeOwnership = false); - - // Place a file descriptor into the parcel. A dup of the fd is made, which - // will be closed once the parcel is destroyed. - status_t writeDupFileDescriptor(int fd); - - // Writes a blob to the parcel. - // If the blob is small, then it is stored in-place, otherwise it is - // transferred by way of an anonymous shared memory region. Prefer sending - // immutable blobs if possible since they may be subsequently transferred between - // processes without further copying whereas mutable blobs always need to be copied. - // The caller should call release() on the blob after writing its contents. - status_t writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob); - - // Write an existing immutable blob file descriptor to the parcel. - // This allows the client to send the same blob to multiple processes - // as long as it keeps a dup of the blob file descriptor handy for later. - status_t writeDupImmutableBlobFileDescriptor(int fd); - - status_t writeObject(const flat_binder_object& val, bool nullMetaData); - - // Like Parcel.java's writeNoException(). Just writes a zero int32. - // Currently the native implementation doesn't do any of the StrictMode - // stack gathering and serialization that the Java implementation does. - status_t writeNoException(); - - void remove(size_t start, size_t amt); - - status_t read(void* outData, size_t len) const; - const void* readInplace(size_t len) const; - int32_t readInt32() const; - status_t readInt32(int32_t *pArg) const; - uint32_t readUint32() const; - status_t readUint32(uint32_t *pArg) const; - int64_t readInt64() const; - status_t readInt64(int64_t *pArg) const; - uint64_t readUint64() const; - status_t readUint64(uint64_t *pArg) const; - float readFloat() const; - status_t readFloat(float *pArg) const; - double readDouble() const; - status_t readDouble(double *pArg) const; - intptr_t readIntPtr() const; - status_t readIntPtr(intptr_t *pArg) const; - - const char* readCString() const; - String8 readString8() const; - String16 readString16() const; - const char16_t* readString16Inplace(size_t* outLen) const; - sp readStrongBinder() const; - wp readWeakBinder() const; - - template - status_t read(Flattenable& val) const; - - template - status_t read(LightFlattenable& val) const; - - // Like Parcel.java's readExceptionCode(). Reads the first int32 - // off of a Parcel's header, returning 0 or the negative error - // code on exceptions, but also deals with skipping over rich - // response headers. Callers should use this to read & parse the - // response headers rather than doing it by hand. - int32_t readExceptionCode() const; - - // Retrieve native_handle from the parcel. This returns a copy of the - // parcel's native_handle (the caller takes ownership). The caller - // must free the native_handle with native_handle_close() and - // native_handle_delete(). - native_handle* readNativeHandle() const; - - - // Retrieve a file descriptor from the parcel. This returns the raw fd - // in the parcel, which you do not own -- use dup() to get your own copy. - int readFileDescriptor() const; - - // Reads a blob from the parcel. - // The caller should call release() on the blob after reading its contents. - status_t readBlob(size_t len, ReadableBlob* outBlob) const; - - const flat_binder_object* readObject(bool nullMetaData) const; - - // Explicitly close all file descriptors in the parcel. - void closeFileDescriptors(); - - // Debugging: get metrics on current allocations. - static size_t getGlobalAllocSize(); - static size_t getGlobalAllocCount(); - -private: - typedef void (*release_func)(Parcel* parcel, - const uint8_t* data, size_t dataSize, - const binder_size_t* objects, size_t objectsSize, - void* cookie); - - uintptr_t ipcData() const; - size_t ipcDataSize() const; - uintptr_t ipcObjects() const; - size_t ipcObjectsCount() const; - void ipcSetDataReference(const uint8_t* data, size_t dataSize, - const binder_size_t* objects, size_t objectsCount, - release_func relFunc, void* relCookie); - -public: - void print(TextOutput& to, uint32_t flags = 0) const; - -private: - Parcel(const Parcel& o); - Parcel& operator=(const Parcel& o); - - status_t finishWrite(size_t len); - void releaseObjects(); - void acquireObjects(); - status_t growData(size_t len); - status_t restartWrite(size_t desired); - status_t continueWrite(size_t desired); - status_t writePointer(uintptr_t val); - status_t readPointer(uintptr_t *pArg) const; - uintptr_t readPointer() const; - void freeDataNoInit(); - void initState(); - void scanForFds() const; - - template - status_t readAligned(T *pArg) const; - - template T readAligned() const; - - template - status_t writeAligned(T val); - - status_t mError; - uint8_t* mData; - size_t mDataSize; - size_t mDataCapacity; - mutable size_t mDataPos; - binder_size_t* mObjects; - size_t mObjectsSize; - size_t mObjectsCapacity; - mutable size_t mNextObjectHint; - - mutable bool mFdsKnown; - mutable bool mHasFds; - bool mAllowFds; - - release_func mOwner; - void* mOwnerCookie; - - class Blob { - public: - Blob(); - ~Blob(); - - void clear(); - void release(); - inline size_t size() const { return mSize; } - inline int fd() const { return mFd; }; - inline bool isMutable() const { return mMutable; } - - protected: - void init(int fd, void* data, size_t size, bool isMutable); - - int mFd; // owned by parcel so not closed when released - void* mData; - size_t mSize; - bool mMutable; - }; - - class FlattenableHelperInterface { - protected: - ~FlattenableHelperInterface() { } - public: - virtual size_t getFlattenedSize() const = 0; - virtual size_t getFdCount() const = 0; - virtual status_t flatten(void* buffer, size_t size, int* fds, size_t count) const = 0; - virtual status_t unflatten(void const* buffer, size_t size, int const* fds, size_t count) = 0; - }; - - template - class FlattenableHelper : public FlattenableHelperInterface { - friend class Parcel; - const Flattenable& val; - explicit FlattenableHelper(const Flattenable& val) : val(val) { } - - public: - virtual size_t getFlattenedSize() const { - return val.getFlattenedSize(); - } - virtual size_t getFdCount() const { - return val.getFdCount(); - } - virtual status_t flatten(void* buffer, size_t size, int* fds, size_t count) const { - return val.flatten(buffer, size, fds, count); - } - virtual status_t unflatten(void const* buffer, size_t size, int const* fds, size_t count) { - return const_cast&>(val).unflatten(buffer, size, fds, count); - } - }; - status_t write(const FlattenableHelperInterface& val); - status_t read(FlattenableHelperInterface& val) const; - -public: - class ReadableBlob : public Blob { - friend class Parcel; - public: - inline const void* data() const { return mData; } - inline void* mutableData() { return isMutable() ? mData : NULL; } - }; - - class WritableBlob : public Blob { - friend class Parcel; - public: - inline void* data() { return mData; } - }; - -#ifndef DISABLE_ASHMEM_TRACKING -private: - size_t mOpenAshmemSize; -#endif - -public: - // TODO: Remove once ABI can be changed. - size_t getBlobAshmemSize() const; - size_t getOpenAshmemSize() const; -}; - -// --------------------------------------------------------------------------- - -template -status_t Parcel::write(const Flattenable& val) { - const FlattenableHelper helper(val); - return write(helper); -} - -template -status_t Parcel::write(const LightFlattenable& val) { - size_t size(val.getFlattenedSize()); - if (!val.isFixedSize()) { - status_t err = writeInt32(size); - if (err != NO_ERROR) { - return err; - } - } - if (size) { - void* buffer = writeInplace(size); - if (buffer == NULL) - return NO_MEMORY; - return val.flatten(buffer, size); - } - return NO_ERROR; -} - -template -status_t Parcel::read(Flattenable& val) const { - FlattenableHelper helper(val); - return read(helper); -} - -template -status_t Parcel::read(LightFlattenable& val) const { - size_t size; - if (val.isFixedSize()) { - size = val.getFlattenedSize(); - } else { - int32_t s; - status_t err = readInt32(&s); - if (err != NO_ERROR) { - return err; - } - size = s; - } - if (size) { - void const* buffer = readInplace(size); - return buffer == NULL ? NO_MEMORY : - val.unflatten(buffer, size); - } - return NO_ERROR; -} - -// --------------------------------------------------------------------------- - -inline TextOutput& operator<<(TextOutput& to, const Parcel& parcel) -{ - parcel.print(to); - return to; -} - -// --------------------------------------------------------------------------- - -// Generic acquire and release of objects. -void acquire_object(const sp& proc, - const flat_binder_object& obj, const void* who); -void release_object(const sp& proc, - const flat_binder_object& obj, const void* who); - -void flatten_binder(const sp& proc, - const sp& binder, flat_binder_object* out); -void flatten_binder(const sp& proc, - const wp& binder, flat_binder_object* out); -status_t unflatten_binder(const sp& proc, - const flat_binder_object& flat, sp* out); -status_t unflatten_binder(const sp& proc, - const flat_binder_object& flat, wp* out); - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_PARCEL_H diff --git a/third_party/android_frameworks_native/include/binder/PermissionCache.h b/third_party/android_frameworks_native/include/binder/PermissionCache.h deleted file mode 100644 index bcdf0c2914..0000000000 --- a/third_party/android_frameworks_native/include/binder/PermissionCache.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2009 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 BINDER_PERMISSION_H -#define BINDER_PERMISSION_H - -#include -#include - -#include -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -/* - * PermissionCache caches permission checks for a given uid. - * - * Currently the cache is not updated when there is a permission change, - * for instance when an application is uninstalled. - * - * IMPORTANT: for the reason stated above, only system permissions are safe - * to cache. This restriction may be lifted at a later time. - * - */ - -class PermissionCache : Singleton { - struct Entry { - String16 name; - uid_t uid; - bool granted; - inline bool operator < (const Entry& e) const { - return (uid == e.uid) ? (name < e.name) : (uid < e.uid); - } - }; - mutable Mutex mLock; - // we pool all the permission names we see, as many permissions checks - // will have identical names - SortedVector< String16 > mPermissionNamesPool; - // this is our cache per say. it stores pooled names. - SortedVector< Entry > mCache; - - // free the whole cache, but keep the permission name pool - void purge(); - - status_t check(bool* granted, - const String16& permission, uid_t uid) const; - - void cache(const String16& permission, uid_t uid, bool granted); - -public: - PermissionCache(); - - static bool checkCallingPermission(const String16& permission); - - static bool checkCallingPermission(const String16& permission, - int32_t* outPid, int32_t* outUid); - - static bool checkPermission(const String16& permission, - pid_t pid, uid_t uid); -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif /* BINDER_PERMISSION_H */ diff --git a/third_party/android_frameworks_native/include/binder/ProcessInfoService.h b/third_party/android_frameworks_native/include/binder/ProcessInfoService.h deleted file mode 100644 index c5ead20676..0000000000 --- a/third_party/android_frameworks_native/include/binder/ProcessInfoService.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2015 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_PROCESS_INFO_SERVICE_H -#define ANDROID_PROCESS_INFO_SERVICE_H - -#include -#include -#include -#include - -namespace android { - -// ---------------------------------------------------------------------- - -class ProcessInfoService : public Singleton { - - friend class Singleton; - sp mProcessInfoService; - Mutex mProcessInfoLock; - - ProcessInfoService(); - - status_t getProcessStatesImpl(size_t length, /*in*/ int32_t* pids, /*out*/ int32_t* states); - void updateBinderLocked(); - - static const int BINDER_ATTEMPT_LIMIT = 5; - -public: - - /** - * For each PID in the given "pids" input array, write the current process state - * for that process into the "states" output array, or - * ActivityManager.PROCESS_STATE_NONEXISTENT * to indicate that no process with the given PID - * exists. - * - * Returns NO_ERROR if this operation was successful, or a negative error code otherwise. - */ - static status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids, - /*out*/ int32_t* states) { - return ProcessInfoService::getInstance().getProcessStatesImpl(length, /*in*/ pids, - /*out*/ states); - } - -}; - -// ---------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_PROCESS_INFO_SERVICE_H - diff --git a/third_party/android_frameworks_native/include/binder/ProcessState.h b/third_party/android_frameworks_native/include/binder/ProcessState.h deleted file mode 100644 index f9edc2a691..0000000000 --- a/third_party/android_frameworks_native/include/binder/ProcessState.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2005 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_PROCESS_STATE_H -#define ANDROID_PROCESS_STATE_H - -#include -#include -#include -#include - -#include - -#include - -// --------------------------------------------------------------------------- -namespace android { - -class IPCThreadState; - -class ProcessState : public virtual RefBase -{ -public: - static sp self(); - - void setContextObject(const sp& object); - sp getContextObject(const sp& caller); - - void setContextObject(const sp& object, - const String16& name); - sp getContextObject(const String16& name, - const sp& caller); - - void startThreadPool(); - - typedef bool (*context_check_func)(const String16& name, - const sp& caller, - void* userData); - - bool isContextManager(void) const; - bool becomeContextManager( - context_check_func checkFunc, - void* userData); - - sp getStrongProxyForHandle(int32_t handle); - wp getWeakProxyForHandle(int32_t handle); - void expungeHandle(int32_t handle, IBinder* binder); - - void spawnPooledThread(bool isMain); - - status_t setThreadPoolMaxThreadCount(size_t maxThreads); - void giveThreadPoolName(); - -private: - friend class IPCThreadState; - - ProcessState(); - ~ProcessState(); - - ProcessState(const ProcessState& o); - ProcessState& operator=(const ProcessState& o); - String8 makeBinderThreadName(); - - struct handle_entry { - IBinder* binder; - RefBase::weakref_type* refs; - }; - - handle_entry* lookupHandleLocked(int32_t handle); - - int mDriverFD; - void* mVMStart; - - // Protects thread count variable below. - pthread_mutex_t mThreadCountLock; - pthread_cond_t mThreadCountDecrement; - // Number of binder threads current executing a command. - size_t mExecutingThreadsCount; - // Maximum number for binder threads allowed for this process. - size_t mMaxThreads; - - mutable Mutex mLock; // protects everything below. - - VectormHandleToObject; - - bool mManagesContexts; - context_check_func mBinderContextCheckFunc; - void* mBinderContextUserData; - - KeyedVector > - mContexts; - - - String8 mRootDir; - bool mThreadPoolStarted; - volatile int32_t mThreadPoolSeq; -}; - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_PROCESS_STATE_H diff --git a/third_party/android_frameworks_native/include/binder/TextOutput.h b/third_party/android_frameworks_native/include/binder/TextOutput.h deleted file mode 100644 index 974a194d8c..0000000000 --- a/third_party/android_frameworks_native/include/binder/TextOutput.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2006 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_TEXTOUTPUT_H -#define ANDROID_TEXTOUTPUT_H - -#include - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -class String8; -class String16; - -class TextOutput -{ -public: - TextOutput(); - virtual ~TextOutput(); - - virtual status_t print(const char* txt, size_t len) = 0; - virtual void moveIndent(int delta) = 0; - - class Bundle { - public: - inline Bundle(TextOutput& to) : mTO(to) { to.pushBundle(); } - inline ~Bundle() { mTO.popBundle(); } - private: - TextOutput& mTO; - }; - - virtual void pushBundle() = 0; - virtual void popBundle() = 0; -}; - -// --------------------------------------------------------------------------- - -// Text output stream for printing to the log (via utils/Log.h). -extern TextOutput& alog; - -// Text output stream for printing to stdout. -extern TextOutput& aout; - -// Text output stream for printing to stderr. -extern TextOutput& aerr; - -typedef TextOutput& (*TextOutputManipFunc)(TextOutput&); - -TextOutput& endl(TextOutput& to); -TextOutput& indent(TextOutput& to); -TextOutput& dedent(TextOutput& to); - -TextOutput& operator<<(TextOutput& to, const char* str); -TextOutput& operator<<(TextOutput& to, char); // writes raw character -TextOutput& operator<<(TextOutput& to, bool); -TextOutput& operator<<(TextOutput& to, int); -TextOutput& operator<<(TextOutput& to, long); -TextOutput& operator<<(TextOutput& to, unsigned int); -TextOutput& operator<<(TextOutput& to, unsigned long); -TextOutput& operator<<(TextOutput& to, long long); -TextOutput& operator<<(TextOutput& to, unsigned long long); -TextOutput& operator<<(TextOutput& to, float); -TextOutput& operator<<(TextOutput& to, double); -TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func); -TextOutput& operator<<(TextOutput& to, const void*); -TextOutput& operator<<(TextOutput& to, const String8& val); -TextOutput& operator<<(TextOutput& to, const String16& val); - -class TypeCode -{ -public: - inline TypeCode(uint32_t code); - inline ~TypeCode(); - - inline uint32_t typeCode() const; - -private: - uint32_t mCode; -}; - -TextOutput& operator<<(TextOutput& to, const TypeCode& val); - -class HexDump -{ -public: - HexDump(const void *buf, size_t size, size_t bytesPerLine=16); - inline ~HexDump(); - - inline HexDump& setBytesPerLine(size_t bytesPerLine); - inline HexDump& setSingleLineCutoff(int32_t bytes); - inline HexDump& setAlignment(size_t alignment); - inline HexDump& setCArrayStyle(bool enabled); - - inline const void* buffer() const; - inline size_t size() const; - inline size_t bytesPerLine() const; - inline int32_t singleLineCutoff() const; - inline size_t alignment() const; - inline bool carrayStyle() const; - -private: - const void* mBuffer; - size_t mSize; - size_t mBytesPerLine; - int32_t mSingleLineCutoff; - size_t mAlignment; - bool mCArrayStyle; -}; - -TextOutput& operator<<(TextOutput& to, const HexDump& val); - -// --------------------------------------------------------------------------- -// No user servicable parts below. - -inline TextOutput& endl(TextOutput& to) -{ - to.print("\n", 1); - return to; -} - -inline TextOutput& indent(TextOutput& to) -{ - to.moveIndent(1); - return to; -} - -inline TextOutput& dedent(TextOutput& to) -{ - to.moveIndent(-1); - return to; -} - -inline TextOutput& operator<<(TextOutput& to, const char* str) -{ - to.print(str, strlen(str)); - return to; -} - -inline TextOutput& operator<<(TextOutput& to, char c) -{ - to.print(&c, 1); - return to; -} - -inline TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func) -{ - return (*func)(to); -} - -inline TypeCode::TypeCode(uint32_t code) : mCode(code) { } -inline TypeCode::~TypeCode() { } -inline uint32_t TypeCode::typeCode() const { return mCode; } - -inline HexDump::~HexDump() { } - -inline HexDump& HexDump::setBytesPerLine(size_t bytesPerLine) { - mBytesPerLine = bytesPerLine; return *this; -} -inline HexDump& HexDump::setSingleLineCutoff(int32_t bytes) { - mSingleLineCutoff = bytes; return *this; -} -inline HexDump& HexDump::setAlignment(size_t alignment) { - mAlignment = alignment; return *this; -} -inline HexDump& HexDump::setCArrayStyle(bool enabled) { - mCArrayStyle = enabled; return *this; -} - -inline const void* HexDump::buffer() const { return mBuffer; } -inline size_t HexDump::size() const { return mSize; } -inline size_t HexDump::bytesPerLine() const { return mBytesPerLine; } -inline int32_t HexDump::singleLineCutoff() const { return mSingleLineCutoff; } -inline size_t HexDump::alignment() const { return mAlignment; } -inline bool HexDump::carrayStyle() const { return mCArrayStyle; } - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_TEXTOUTPUT_H diff --git a/third_party/android_frameworks_native/include/gui/BitTube.h b/third_party/android_frameworks_native/include/gui/BitTube.h deleted file mode 100644 index 3ecac52ad7..0000000000 --- a/third_party/android_frameworks_native/include/gui/BitTube.h +++ /dev/null @@ -1,95 +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_SENSOR_CHANNEL_H -#define ANDROID_GUI_SENSOR_CHANNEL_H - -#include -#include - -#include -#include -#include - - -namespace android { -// ---------------------------------------------------------------------------- -class Parcel; - -class BitTube : public RefBase -{ -public: - - // creates a BitTube with a default (4KB) send buffer - BitTube(); - - // creates a BitTube with a a specified send and receive buffer size - explicit BitTube(size_t bufsize); - - explicit BitTube(const Parcel& data); - virtual ~BitTube(); - - // check state after construction - status_t initCheck() const; - - // get receive file-descriptor - int getFd() const; - - // get the send file-descriptor. - int getSendFd() const; - - // send objects (sized blobs). All objects are guaranteed to be written or the call fails. - template - static ssize_t sendObjects(const sp& tube, - T const* events, size_t count) { - return sendObjects(tube, events, count, sizeof(T)); - } - - // receive objects (sized blobs). If the receiving buffer isn't large enough, - // excess messages are silently discarded. - template - static ssize_t recvObjects(const sp& tube, - T* events, size_t count) { - return recvObjects(tube, events, count, sizeof(T)); - } - - // parcels this BitTube - status_t writeToParcel(Parcel* reply) const; - -private: - void init(size_t rcvbuf, size_t sndbuf); - - // send a message. The write is guaranteed to send the whole message or fail. - ssize_t write(void const* vaddr, size_t size); - - // receive a message. the passed buffer must be at least as large as the - // write call used to send the message, excess data is silently discarded. - ssize_t read(void* vaddr, size_t size); - - int mSendFd; - mutable int mReceiveFd; - - static ssize_t sendObjects(const sp& tube, - void const* events, size_t count, size_t objSize); - - static ssize_t recvObjects(const sp& tube, - void* events, size_t count, size_t objSize); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_SENSOR_CHANNEL_H diff --git a/third_party/android_frameworks_native/include/gui/BufferItem.h b/third_party/android_frameworks_native/include/gui/BufferItem.h deleted file mode 100644 index 145efe6f60..0000000000 --- a/third_party/android_frameworks_native/include/gui/BufferItem.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2014 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_BUFFERITEM_H -#define ANDROID_GUI_BUFFERITEM_H - -#include -#include - -#include -#include - -#include - -#include -#include - -namespace android { - -class Fence; -class GraphicBuffer; - -class BufferItem : public Flattenable { - friend class Flattenable; - size_t getPodSize() const; - size_t getFlattenedSize() const; - size_t getFdCount() const; - status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; - status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); - - public: - // The default value of mBuf, used to indicate this doesn't correspond to a slot. - enum { INVALID_BUFFER_SLOT = -1 }; - BufferItem(); - ~BufferItem(); - - static const char* scalingModeName(uint32_t scalingMode); - - // mGraphicBuffer points to the buffer allocated for this slot, or is NULL - // if the buffer in this slot has been acquired in the past (see - // BufferSlot.mAcquireCalled). - sp mGraphicBuffer; - - // mFence is a fence that will signal when the buffer is idle. - sp mFence; - - // mCrop is the current crop rectangle for this buffer slot. - Rect mCrop; - - // mTransform is the current transform flags for this buffer slot. - // refer to NATIVE_WINDOW_TRANSFORM_* in - uint32_t mTransform; - - // mScalingMode is the current scaling mode for this buffer slot. - // refer to NATIVE_WINDOW_SCALING_* in - uint32_t mScalingMode; - - // mTimestamp is the current timestamp for this buffer slot. This gets - // to set by queueBuffer each time this slot is queued. This value - // is guaranteed to be monotonically increasing for each newly - // acquired buffer. - union { - int64_t mTimestamp; - struct { - uint32_t mTimestampLo; - uint32_t mTimestampHi; - }; - }; - - // mIsAutoTimestamp indicates whether mTimestamp was generated - // automatically when the buffer was queued. - bool mIsAutoTimestamp; - - // mDataSpace is the current dataSpace value for this buffer slot. This gets - // set by queueBuffer each time this slot is queued. The meaning of the - // dataSpace is format-dependent. - android_dataspace mDataSpace; - - // mFrameNumber is the number of the queued frame for this slot. - union { - uint64_t mFrameNumber; - struct { - uint32_t mFrameNumberLo; - uint32_t mFrameNumberHi; - }; - }; - - union { - // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT). - int mSlot; - - // mBuf is the former name for mSlot - int mBuf; - }; - - // mIsDroppable whether this buffer was queued with the - // property that it can be replaced by a new buffer for the purpose of - // making sure dequeueBuffer() won't block. - // i.e.: was the BufferQueue in "mDequeueBufferCannotBlock" when this buffer - // was queued. - bool mIsDroppable; - - // Indicates whether this buffer has been seen by a consumer yet - bool mAcquireCalled; - - // Indicates this buffer must be transformed by the inverse transform of the screen - // it is displayed onto. This is applied after mTransform. - bool mTransformToDisplayInverse; - - // Describes the portion of the surface that has been modified since the - // previous frame - Region mSurfaceDamage; -}; - -} // namespace android - -#endif diff --git a/third_party/android_frameworks_native/include/gui/BufferItemConsumer.h b/third_party/android_frameworks_native/include/gui/BufferItemConsumer.h deleted file mode 100644 index 56c7a3f463..0000000000 --- a/third_party/android_frameworks_native/include/gui/BufferItemConsumer.h +++ /dev/null @@ -1,93 +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_BUFFERITEMCONSUMER_H -#define ANDROID_GUI_BUFFERITEMCONSUMER_H - -#include - -#include - -#include -#include -#include - -#define ANDROID_GRAPHICS_BUFFERITEMCONSUMER_JNI_ID "mBufferItemConsumer" - -namespace android { - -class BufferQueue; - -/** - * BufferItemConsumer is a BufferQueue consumer endpoint that allows clients - * access to the whole BufferItem entry from BufferQueue. Multiple buffers may - * be acquired at once, to be used concurrently by the client. This consumer can - * operate either in synchronous or asynchronous mode. - */ -class BufferItemConsumer: public ConsumerBase -{ - public: - typedef ConsumerBase::FrameAvailableListener FrameAvailableListener; - - enum { DEFAULT_MAX_BUFFERS = -1 }; - enum { INVALID_BUFFER_SLOT = BufferQueue::INVALID_BUFFER_SLOT }; - enum { NO_BUFFER_AVAILABLE = BufferQueue::NO_BUFFER_AVAILABLE }; - - // Create a new buffer item consumer. The consumerUsage parameter determines - // the consumer usage flags passed to the graphics allocator. The - // bufferCount parameter specifies how many buffers can be locked for user - // access at the same time. - // controlledByApp tells whether this consumer is controlled by the - // application. - BufferItemConsumer(const sp& consumer, - uint32_t consumerUsage, int bufferCount = DEFAULT_MAX_BUFFERS, - bool controlledByApp = false); - - virtual ~BufferItemConsumer(); - - // set the name of the BufferItemConsumer that will be used to identify it in - // log messages. - void setName(const String8& name); - - // Gets the next graphics buffer from the producer, filling out the - // passed-in BufferItem structure. Returns NO_BUFFER_AVAILABLE if the queue - // of buffers is empty, and INVALID_OPERATION if the maximum number of - // buffers is already acquired. - // - // Only a fixed number of buffers can be acquired at a time, determined by - // the construction-time bufferCount parameter. If INVALID_OPERATION is - // returned by acquireBuffer, then old buffers must be returned to the - // queue by calling releaseBuffer before more buffers can be acquired. - // - // If waitForFence is true, and the acquired BufferItem has a valid fence object, - // acquireBuffer will wait on the fence with no timeout before returning. - status_t acquireBuffer(BufferItem* item, nsecs_t presentWhen, - bool waitForFence = true); - - // Returns an acquired buffer to the queue, allowing it to be reused. Since - // only a fixed number of buffers may be acquired at a time, old buffers - // must be released by calling releaseBuffer to ensure new buffers can be - // acquired by acquireBuffer. Once a BufferItem is released, the caller must - // not access any members of the BufferItem, and should immediately remove - // all of its references to the BufferItem itself. - status_t releaseBuffer(const BufferItem &item, - const sp& releaseFence = Fence::NO_FENCE); - -}; - -} // namespace android - -#endif // ANDROID_GUI_CPUCONSUMER_H diff --git a/third_party/android_frameworks_native/include/gui/BufferQueue.h b/third_party/android_frameworks_native/include/gui/BufferQueue.h deleted file mode 100644 index 09300a20c9..0000000000 --- a/third_party/android_frameworks_native/include/gui/BufferQueue.h +++ /dev/null @@ -1,89 +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_BUFFERQUEUE_H -#define ANDROID_GUI_BUFFERQUEUE_H - -#include -#include -#include -#include -#include - -// These are only required to keep other parts of the framework with incomplete -// dependencies building successfully -#include - -namespace android { - -class BufferQueue { -public: - // BufferQueue will keep track of at most this value of buffers. - // Attempts at runtime to increase the number of buffers past this will fail. - enum { NUM_BUFFER_SLOTS = BufferQueueDefs::NUM_BUFFER_SLOTS }; - // Used as a placeholder slot# when the value isn't pointing to an existing buffer. - enum { INVALID_BUFFER_SLOT = BufferItem::INVALID_BUFFER_SLOT }; - // Alias to -- please scope from there in future code! - enum { - NO_BUFFER_AVAILABLE = IGraphicBufferConsumer::NO_BUFFER_AVAILABLE, - PRESENT_LATER = IGraphicBufferConsumer::PRESENT_LATER, - }; - - // When in async mode we reserve two slots in order to guarantee that the - // producer and consumer can run asynchronously. - enum { MAX_MAX_ACQUIRED_BUFFERS = NUM_BUFFER_SLOTS - 2 }; - - // for backward source compatibility - typedef ::android::ConsumerListener ConsumerListener; - - // ProxyConsumerListener is a ConsumerListener implementation that keeps a weak - // reference to the actual consumer object. It forwards all calls to that - // consumer object so long as it exists. - // - // This class exists to avoid having a circular reference between the - // BufferQueue object and the consumer object. The reason this can't be a weak - // reference in the BufferQueue class is because we're planning to expose the - // consumer side of a BufferQueue as a binder interface, which doesn't support - // weak references. - class ProxyConsumerListener : public BnConsumerListener { - public: - ProxyConsumerListener(const wp& consumerListener); - virtual ~ProxyConsumerListener(); - virtual void onFrameAvailable(const BufferItem& item) override; - virtual void onFrameReplaced(const BufferItem& item) override; - virtual void onBuffersReleased() override; - virtual void onSidebandStreamChanged() override; - private: - // mConsumerListener is a weak reference to the IConsumerListener. This is - // the raison d'etre of ProxyConsumerListener. - wp mConsumerListener; - }; - - // BufferQueue manages a pool of gralloc memory slots to be used by - // producers and consumers. allocator is used to allocate all the - // needed gralloc buffers. - static void createBufferQueue(sp* outProducer, - sp* outConsumer, - const sp& allocator = NULL); - -private: - BufferQueue(); // Create through createBufferQueue -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_BUFFERQUEUE_H diff --git a/third_party/android_frameworks_native/include/gui/BufferQueueConsumer.h b/third_party/android_frameworks_native/include/gui/BufferQueueConsumer.h deleted file mode 100644 index cde302f8a6..0000000000 --- a/third_party/android_frameworks_native/include/gui/BufferQueueConsumer.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2014 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_BUFFERQUEUECONSUMER_H -#define ANDROID_GUI_BUFFERQUEUECONSUMER_H - -#include -#include - -#include -#include - -namespace android { - -class BufferQueueCore; - -class BufferQueueConsumer : public BnGraphicBufferConsumer { - -public: - BufferQueueConsumer(const sp& core); - virtual ~BufferQueueConsumer(); - - // acquireBuffer attempts to acquire ownership of the next pending buffer in - // the BufferQueue. If no buffer is pending then it returns - // NO_BUFFER_AVAILABLE. If a buffer is successfully acquired, the - // information about the buffer is returned in BufferItem. If the buffer - // returned had previously been acquired then the BufferItem::mGraphicBuffer - // field of buffer is set to NULL and it is assumed that the consumer still - // holds a reference to the buffer. - // - // If expectedPresent is nonzero, it indicates the time when the buffer - // will be displayed on screen. If the buffer's timestamp is farther in the - // future, the buffer won't be acquired, and PRESENT_LATER will be - // returned. The presentation time is in nanoseconds, and the time base - // is CLOCK_MONOTONIC. - virtual status_t acquireBuffer(BufferItem* outBuffer, - nsecs_t expectedPresent, uint64_t maxFrameNumber = 0) override; - - // See IGraphicBufferConsumer::detachBuffer - virtual status_t detachBuffer(int slot); - - // See IGraphicBufferConsumer::attachBuffer - virtual status_t attachBuffer(int* slot, const sp& buffer); - - // releaseBuffer releases a buffer slot from the consumer back to the - // BufferQueue. This may be done while the buffer's contents are still - // being accessed. The fence will signal when the buffer is no longer - // in use. frameNumber is used to indentify the exact buffer returned. - // - // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free - // any references to the just-released buffer that it might have, as if it - // had received a onBuffersReleased() call with a mask set for the released - // buffer. - // - // Note that the dependencies on EGL will be removed once we switch to using - // the Android HW Sync HAL. - virtual status_t releaseBuffer(int slot, uint64_t frameNumber, - const sp& releaseFence, EGLDisplay display, - EGLSyncKHR fence); - - // connect connects a consumer to the BufferQueue. Only one - // consumer may be connected, and when that consumer disconnects the - // BufferQueue is placed into the "abandoned" state, causing most - // interactions with the BufferQueue by the producer to fail. - // controlledByApp indicates whether the consumer is controlled by - // the application. - // - // consumerListener may not be NULL. - virtual status_t connect(const sp& consumerListener, - bool controlledByApp); - - // disconnect disconnects a consumer from the BufferQueue. All - // buffers will be freed and the BufferQueue is placed in the "abandoned" - // state, causing most interactions with the BufferQueue by the producer to - // fail. - virtual status_t disconnect(); - - // getReleasedBuffers sets the value pointed to by outSlotMask to a bit mask - // indicating which buffer slots have been released by the BufferQueue - // but have not yet been released by the consumer. - // - // This should be called from the onBuffersReleased() callback. - virtual status_t getReleasedBuffers(uint64_t* outSlotMask); - - // setDefaultBufferSize is used to set the size of buffers returned by - // dequeueBuffer when a width and height of zero is requested. Default - // is 1x1. - virtual status_t setDefaultBufferSize(uint32_t width, uint32_t height); - - // setDefaultMaxBufferCount sets the default value for the maximum buffer - // count (the initial default is 2). If the producer has requested a - // buffer count using setBufferCount, the default buffer count will only - // take effect if the producer sets the count back to zero. - // - // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive. - virtual status_t setDefaultMaxBufferCount(int bufferCount); - - // disableAsyncBuffer disables the extra buffer used in async mode - // (when both producer and consumer have set their "isControlledByApp" - // flag) and has dequeueBuffer() return WOULD_BLOCK instead. - // - // This can only be called before connect(). - virtual status_t disableAsyncBuffer(); - - // setMaxAcquiredBufferCount sets the maximum number of buffers that can - // be acquired by the consumer at one time (default 1). This call will - // fail if a producer is connected to the BufferQueue. - virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers); - - // setConsumerName sets the name used in logging - virtual void setConsumerName(const String8& name); - - // setDefaultBufferFormat allows the BufferQueue to create - // GraphicBuffers of a defaultFormat if no format is specified - // in dequeueBuffer. The initial default is HAL_PIXEL_FORMAT_RGBA_8888. - virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat); - - // setDefaultBufferDataSpace allows the BufferQueue to create - // GraphicBuffers of a defaultDataSpace if no data space is specified - // in queueBuffer. - // The initial default is HAL_DATASPACE_UNKNOWN - virtual status_t setDefaultBufferDataSpace( - android_dataspace defaultDataSpace); - - // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer. - // These are merged with the bits passed to dequeueBuffer. The values are - // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0. - virtual status_t setConsumerUsageBits(uint32_t usage); - - // setTransformHint bakes in rotation to buffers so overlays can be used. - // The values are enumerated in window.h, e.g. - // NATIVE_WINDOW_TRANSFORM_ROT_90. The default is 0 (no transform). - virtual status_t setTransformHint(uint32_t hint); - - // Retrieve the sideband buffer stream, if any. - virtual sp getSidebandStream() const; - - // dump our state in a String - virtual void dump(String8& result, const char* prefix) const; - - // Functions required for backwards compatibility. - // These will be modified/renamed in IGraphicBufferConsumer and will be - // removed from this class at that time. See b/13306289. - - virtual status_t releaseBuffer(int buf, uint64_t frameNumber, - EGLDisplay display, EGLSyncKHR fence, - const sp& releaseFence) { - return releaseBuffer(buf, frameNumber, releaseFence, display, fence); - } - - virtual status_t consumerConnect(const sp& consumer, - bool controlledByApp) { - return connect(consumer, controlledByApp); - } - - virtual status_t consumerDisconnect() { return disconnect(); } - - // End functions required for backwards compatibility - -private: - sp mCore; - - // This references mCore->mSlots. Lock mCore->mMutex while accessing. - BufferQueueDefs::SlotsType& mSlots; - - // This is a cached copy of the name stored in the BufferQueueCore. - // It's updated during setConsumerName. - String8 mConsumerName; - -}; // class BufferQueueConsumer - -} // namespace android - -#endif diff --git a/third_party/android_frameworks_native/include/gui/BufferQueueCore.h b/third_party/android_frameworks_native/include/gui/BufferQueueCore.h deleted file mode 100644 index 99134ea501..0000000000 --- a/third_party/android_frameworks_native/include/gui/BufferQueueCore.h +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright 2014 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_BUFFERQUEUECORE_H -#define ANDROID_GUI_BUFFERQUEUECORE_H - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define BQ_LOGV(x, ...) ALOGV("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) -#define BQ_LOGD(x, ...) ALOGD("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) -#define BQ_LOGI(x, ...) ALOGI("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) -#define BQ_LOGW(x, ...) ALOGW("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) -#define BQ_LOGE(x, ...) ALOGE("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) - -#define ATRACE_BUFFER_INDEX(index) \ - if (ATRACE_ENABLED()) { \ - char ___traceBuf[1024]; \ - snprintf(___traceBuf, 1024, "%s: %d", \ - mCore->mConsumerName.string(), (index)); \ - android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf); \ - } - -namespace android { - -class IConsumerListener; -class IGraphicBufferAlloc; -class IProducerListener; - -class BufferQueueCore : public virtual RefBase { - - friend class BufferQueueProducer; - friend class BufferQueueConsumer; - -public: - // Used as a placeholder slot number when the value isn't pointing to an - // existing buffer. - enum { INVALID_BUFFER_SLOT = BufferItem::INVALID_BUFFER_SLOT }; - - // We reserve two slots in order to guarantee that the producer and - // consumer can run asynchronously. - enum { MAX_MAX_ACQUIRED_BUFFERS = BufferQueueDefs::NUM_BUFFER_SLOTS - 2 }; - - // The default API number used to indicate that no producer is connected - enum { NO_CONNECTED_API = 0 }; - - typedef Vector Fifo; - - // BufferQueueCore manages a pool of gralloc memory slots to be used by - // producers and consumers. allocator is used to allocate all the needed - // gralloc buffers. - BufferQueueCore(const sp& allocator = NULL); - virtual ~BufferQueueCore(); - -private: - // Dump our state in a string - void dump(String8& result, const char* prefix) const; - - // getMinUndequeuedBufferCountLocked returns the minimum number of buffers - // that must remain in a state other than DEQUEUED. The async parameter - // tells whether we're in asynchronous mode. - int getMinUndequeuedBufferCountLocked(bool async) const; - - // getMinMaxBufferCountLocked returns the minimum number of buffers allowed - // given the current BufferQueue state. The async parameter tells whether - // we're in asynchonous mode. - int getMinMaxBufferCountLocked(bool async) const; - - // getMaxBufferCountLocked returns the maximum number of buffers that can be - // allocated at once. This value depends on the following member variables: - // - // mDequeueBufferCannotBlock - // mMaxAcquiredBufferCount - // mDefaultMaxBufferCount - // mOverrideMaxBufferCount - // async parameter - // - // Any time one of these member variables is changed while a producer is - // connected, mDequeueCondition must be broadcast. - int getMaxBufferCountLocked(bool async) const; - - // setDefaultMaxBufferCountLocked sets the maximum number of buffer slots - // that will be used if the producer does not override the buffer slot - // count. The count must be between 2 and NUM_BUFFER_SLOTS, inclusive. The - // initial default is 2. - status_t setDefaultMaxBufferCountLocked(int count); - - // freeBufferLocked frees the GraphicBuffer and sync resources for the - // given slot. - void freeBufferLocked(int slot); - - // freeAllBuffersLocked frees the GraphicBuffer and sync resources for - // all slots. - void freeAllBuffersLocked(); - - // stillTracking returns true iff the buffer item is still being tracked - // in one of the slots. - bool stillTracking(const BufferItem* item) const; - - // waitWhileAllocatingLocked blocks until mIsAllocating is false. - void waitWhileAllocatingLocked() const; - - // validateConsistencyLocked ensures that the free lists are in sync with - // the information stored in mSlots - void validateConsistencyLocked() const; - - // mAllocator is the connection to SurfaceFlinger that is used to allocate - // new GraphicBuffer objects. - sp mAllocator; - - // mMutex is the mutex used to prevent concurrent access to the member - // variables of BufferQueueCore objects. It must be locked whenever any - // member variable is accessed. - mutable Mutex mMutex; - - // mIsAbandoned indicates that the BufferQueue will no longer be used to - // consume image buffers pushed to it using the IGraphicBufferProducer - // interface. It is initialized to false, and set to true in the - // consumerDisconnect method. A BufferQueue that is abandoned will return - // the NO_INIT error from all IGraphicBufferProducer methods capable of - // returning an error. - bool mIsAbandoned; - - // mConsumerControlledByApp indicates whether the connected consumer is - // controlled by the application. - bool mConsumerControlledByApp; - - // mConsumerName is a string used to identify the BufferQueue in log - // messages. It is set by the IGraphicBufferConsumer::setConsumerName - // method. - String8 mConsumerName; - - // mConsumerListener is used to notify the connected consumer of - // asynchronous events that it may wish to react to. It is initially - // set to NULL and is written by consumerConnect and consumerDisconnect. - sp mConsumerListener; - - // mConsumerUsageBits contains flags that the consumer wants for - // GraphicBuffers. - uint32_t mConsumerUsageBits; - - // mConnectedApi indicates the producer API that is currently connected - // to this BufferQueue. It defaults to NO_CONNECTED_API, and gets updated - // by the connect and disconnect methods. - int mConnectedApi; - - // mConnectedProducerToken is used to set a binder death notification on - // the producer. - sp mConnectedProducerListener; - - // mSlots is an array of buffer slots that must be mirrored on the producer - // side. This allows buffer ownership to be transferred between the producer - // and consumer without sending a GraphicBuffer over Binder. The entire - // array is initialized to NULL at construction time, and buffers are - // allocated for a slot when requestBuffer is called with that slot's index. - BufferQueueDefs::SlotsType mSlots; - - // mQueue is a FIFO of queued buffers used in synchronous mode. - Fifo mQueue; - - // mFreeSlots contains all of the slots which are FREE and do not currently - // have a buffer attached - std::set mFreeSlots; - - // mFreeBuffers contains all of the slots which are FREE and currently have - // a buffer attached - std::list mFreeBuffers; - - // mOverrideMaxBufferCount is the limit on the number of buffers that will - // be allocated at one time. This value is set by the producer by calling - // setBufferCount. The default is 0, which means that the producer doesn't - // care about the number of buffers in the pool. In that case, - // mDefaultMaxBufferCount is used as the limit. - int mOverrideMaxBufferCount; - - // mDequeueCondition is a condition variable used for dequeueBuffer in - // synchronous mode. - mutable Condition mDequeueCondition; - - // mUseAsyncBuffer indicates whether an extra buffer is used in async mode - // to prevent dequeueBuffer from blocking. - bool mUseAsyncBuffer; - - // mDequeueBufferCannotBlock indicates whether dequeueBuffer is allowed to - // block. This flag is set during connect when both the producer and - // consumer are controlled by the application. - bool mDequeueBufferCannotBlock; - - // mDefaultBufferFormat can be set so it will override the buffer format - // when it isn't specified in dequeueBuffer. - PixelFormat mDefaultBufferFormat; - - // mDefaultWidth holds the default width of allocated buffers. It is used - // in dequeueBuffer if a width and height of 0 are specified. - uint32_t mDefaultWidth; - - // mDefaultHeight holds the default height of allocated buffers. It is used - // in dequeueBuffer if a width and height of 0 are specified. - uint32_t mDefaultHeight; - - // mDefaultBufferDataSpace holds the default dataSpace of queued buffers. - // It is used in queueBuffer if a dataspace of 0 (HAL_DATASPACE_UNKNOWN) - // is specified. - android_dataspace mDefaultBufferDataSpace; - - // mDefaultMaxBufferCount is the default limit on the number of buffers that - // will be allocated at one time. This default limit is set by the consumer. - // The limit (as opposed to the default limit) may be overriden by the - // producer. - int mDefaultMaxBufferCount; - - // mMaxAcquiredBufferCount is the number of buffers that the consumer may - // acquire at one time. It defaults to 1, and can be changed by the consumer - // via setMaxAcquiredBufferCount, but this may only be done while no - // producer is connected to the BufferQueue. This value is used to derive - // the value returned for the MIN_UNDEQUEUED_BUFFERS query to the producer. - int mMaxAcquiredBufferCount; - - // mBufferHasBeenQueued is true once a buffer has been queued. It is reset - // when something causes all buffers to be freed (e.g., changing the buffer - // count). - bool mBufferHasBeenQueued; - - // mFrameCounter is the free running counter, incremented on every - // successful queueBuffer call and buffer allocation. - uint64_t mFrameCounter; - - // mTransformHint is used to optimize for screen rotations. - uint32_t mTransformHint; - - // mSidebandStream is a handle to the sideband buffer stream, if any - sp mSidebandStream; - - // mIsAllocating indicates whether a producer is currently trying to allocate buffers (which - // releases mMutex while doing the allocation proper). Producers should not modify any of the - // FREE slots while this is true. mIsAllocatingCondition is signaled when this value changes to - // false. - bool mIsAllocating; - - // mIsAllocatingCondition is a condition variable used by producers to wait until mIsAllocating - // becomes false. - mutable Condition mIsAllocatingCondition; - - // mAllowAllocation determines whether dequeueBuffer is allowed to allocate - // new buffers - bool mAllowAllocation; - - // mBufferAge tracks the age of the contents of the most recently dequeued - // buffer as the number of frames that have elapsed since it was last queued - uint64_t mBufferAge; - - // mGenerationNumber stores the current generation number of the attached - // producer. Any attempt to attach a buffer with a different generation - // number will fail. - uint32_t mGenerationNumber; - -}; // class BufferQueueCore - -} // namespace android - -#endif diff --git a/third_party/android_frameworks_native/include/gui/BufferQueueDefs.h b/third_party/android_frameworks_native/include/gui/BufferQueueDefs.h deleted file mode 100644 index 83e9580037..0000000000 --- a/third_party/android_frameworks_native/include/gui/BufferQueueDefs.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2014 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_BUFFERQUEUECOREDEFS_H -#define ANDROID_GUI_BUFFERQUEUECOREDEFS_H - -#include - -namespace android { - class BufferQueueCore; - - namespace BufferQueueDefs { - // BufferQueue will keep track of at most this value of buffers. - // Attempts at runtime to increase the number of buffers past this - // will fail. - enum { NUM_BUFFER_SLOTS = 64 }; - - typedef BufferSlot SlotsType[NUM_BUFFER_SLOTS]; - } // namespace BufferQueueDefs -} // namespace android - -#endif diff --git a/third_party/android_frameworks_native/include/gui/BufferQueueProducer.h b/third_party/android_frameworks_native/include/gui/BufferQueueProducer.h deleted file mode 100644 index 9754a89eac..0000000000 --- a/third_party/android_frameworks_native/include/gui/BufferQueueProducer.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright 2014 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_BUFFERQUEUEPRODUCER_H -#define ANDROID_GUI_BUFFERQUEUEPRODUCER_H - -#include -#include - -namespace android { - -class BufferSlot; - -class BufferQueueProducer : public BnGraphicBufferProducer, - private IBinder::DeathRecipient { -public: - friend class BufferQueue; // Needed to access binderDied - - BufferQueueProducer(const sp& core); - virtual ~BufferQueueProducer(); - - // requestBuffer returns the GraphicBuffer for slot N. - // - // In normal operation, this is called the first time slot N is returned - // by dequeueBuffer. It must be called again if dequeueBuffer returns - // flags indicating that previously-returned buffers are no longer valid. - virtual status_t requestBuffer(int slot, sp* buf); - - // setBufferCount updates the number of available buffer slots. If this - // method succeeds, buffer slots will be both unallocated and owned by - // the BufferQueue object (i.e. they are not owned by the producer or - // consumer). - // - // This will fail if the producer has dequeued any buffers, or if - // bufferCount is invalid. bufferCount must generally be a value - // between the minimum undequeued buffer count (exclusive) and NUM_BUFFER_SLOTS - // (inclusive). It may also be set to zero (the default) to indicate - // that the producer does not wish to set a value. The minimum value - // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, - // ...). - // - // This may only be called by the producer. The consumer will be told - // to discard buffers through the onBuffersReleased callback. - virtual status_t setBufferCount(int bufferCount); - - // dequeueBuffer gets the next buffer slot index for the producer to use. - // If a buffer slot is available then that slot index is written to the - // location pointed to by the buf argument and a status of OK is returned. - // If no slot is available then a status of -EBUSY is returned and buf is - // unmodified. - // - // The outFence parameter will be updated to hold the fence associated with - // the buffer. The contents of the buffer must not be overwritten until the - // fence signals. If the fence is Fence::NO_FENCE, the buffer may be - // written immediately. - // - // The width and height parameters must be no greater than the minimum of - // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). - // An error due to invalid dimensions might not be reported until - // updateTexImage() is called. If width and height are both zero, the - // default values specified by setDefaultBufferSize() are used instead. - // - // If the format is 0, the default format will be used. - // - // The usage argument specifies gralloc buffer usage flags. The values - // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER. These - // will be merged with the usage flags specified by setConsumerUsageBits. - // - // The return value may be a negative error value or a non-negative - // collection of flags. If the flags are set, the return values are - // valid, but additional actions must be performed. - // - // If IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION is set, the - // producer must discard cached GraphicBuffer references for the slot - // returned in buf. - // If IGraphicBufferProducer::RELEASE_ALL_BUFFERS is set, the producer - // must discard cached GraphicBuffer references for all slots. - // - // In both cases, the producer will need to call requestBuffer to get a - // GraphicBuffer handle for the returned slot. - virtual status_t dequeueBuffer(int *outSlot, sp* outFence, - bool async, uint32_t width, uint32_t height, PixelFormat format, - uint32_t usage); - - // See IGraphicBufferProducer::detachBuffer - virtual status_t detachBuffer(int slot); - - // See IGraphicBufferProducer::detachNextBuffer - virtual status_t detachNextBuffer(sp* outBuffer, - sp* outFence); - - // See IGraphicBufferProducer::attachBuffer - virtual status_t attachBuffer(int* outSlot, const sp& buffer); - - // queueBuffer returns a filled buffer to the BufferQueue. - // - // Additional data is provided in the QueueBufferInput struct. Notably, - // a timestamp must be provided for the buffer. The timestamp is in - // nanoseconds, and must be monotonically increasing. Its other semantics - // (zero point, etc) are producer-specific and should be documented by the - // producer. - // - // The caller may provide a fence that signals when all rendering - // operations have completed. Alternatively, NO_FENCE may be used, - // indicating that the buffer is ready immediately. - // - // Some values are returned in the output struct: the current settings - // for default width and height, the current transform hint, and the - // number of queued buffers. - virtual status_t queueBuffer(int slot, - const QueueBufferInput& input, QueueBufferOutput* output); - - // cancelBuffer returns a dequeued buffer to the BufferQueue, but doesn't - // queue it for use by the consumer. - // - // The buffer will not be overwritten until the fence signals. The fence - // will usually be the one obtained from dequeueBuffer. - virtual void cancelBuffer(int slot, const sp& fence); - - // Query native window attributes. The "what" values are enumerated in - // window.h (e.g. NATIVE_WINDOW_FORMAT). - virtual int query(int what, int* outValue); - - // connect attempts to connect a producer API to the BufferQueue. This - // must be called before any other IGraphicBufferProducer methods are - // called except for getAllocator. A consumer must already be connected. - // - // This method will fail if connect was previously called on the - // BufferQueue and no corresponding disconnect call was made (i.e. if - // it's still connected to a producer). - // - // APIs are enumerated in window.h (e.g. NATIVE_WINDOW_API_CPU). - virtual status_t connect(const sp& listener, - int api, bool producerControlledByApp, QueueBufferOutput* output); - - // disconnect attempts to disconnect a producer API from the BufferQueue. - // Calling this method will cause any subsequent calls to other - // IGraphicBufferProducer methods to fail except for getAllocator and connect. - // Successfully calling connect after this will allow the other methods to - // succeed again. - // - // This method will fail if the the BufferQueue is not currently - // connected to the specified producer API. - virtual status_t disconnect(int api); - - // Attaches a sideband buffer stream to the IGraphicBufferProducer. - // - // A sideband stream is a device-specific mechanism for passing buffers - // from the producer to the consumer without using dequeueBuffer/ - // queueBuffer. If a sideband stream is present, the consumer can choose - // whether to acquire buffers from the sideband stream or from the queued - // buffers. - // - // Passing NULL or a different stream handle will detach the previous - // handle if any. - virtual status_t setSidebandStream(const sp& stream); - - // See IGraphicBufferProducer::allocateBuffers - virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, - PixelFormat format, uint32_t usage); - - // See IGraphicBufferProducer::allowAllocation - virtual status_t allowAllocation(bool allow); - - // See IGraphicBufferProducer::setGenerationNumber - virtual status_t setGenerationNumber(uint32_t generationNumber); - - // See IGraphicBufferProducer::getConsumerName - virtual String8 getConsumerName() const override; - -private: - // This is required by the IBinder::DeathRecipient interface - virtual void binderDied(const wp& who); - - // waitForFreeSlotThenRelock finds the oldest slot in the FREE state. It may - // block if there are no available slots and we are not in non-blocking - // mode (producer and consumer controlled by the application). If it blocks, - // it will release mCore->mMutex while blocked so that other operations on - // the BufferQueue may succeed. - status_t waitForFreeSlotThenRelock(const char* caller, bool async, - int* found, status_t* returnFlags) const; - - sp mCore; - - // This references mCore->mSlots. Lock mCore->mMutex while accessing. - BufferQueueDefs::SlotsType& mSlots; - - // This is a cached copy of the name stored in the BufferQueueCore. - // It's updated during connect and dequeueBuffer (which should catch - // most updates). - String8 mConsumerName; - - uint32_t mStickyTransform; - - // This saves the fence from the last queueBuffer, such that the - // next queueBuffer call can throttle buffer production. The prior - // queueBuffer's fence is not nessessarily available elsewhere, - // since the previous buffer might have already been acquired. - sp mLastQueueBufferFence; - - // Take-a-ticket system for ensuring that onFrame* callbacks are called in - // the order that frames are queued. While the BufferQueue lock - // (mCore->mMutex) is held, a ticket is retained by the producer. After - // dropping the BufferQueue lock, the producer must wait on the condition - // variable until the current callback ticket matches its retained ticket. - Mutex mCallbackMutex; - int mNextCallbackTicket; // Protected by mCore->mMutex - int mCurrentCallbackTicket; // Protected by mCallbackMutex - Condition mCallbackCondition; - -}; // class BufferQueueProducer - -} // namespace android - -#endif diff --git a/third_party/android_frameworks_native/include/gui/BufferSlot.h b/third_party/android_frameworks_native/include/gui/BufferSlot.h deleted file mode 100644 index 6085e116a3..0000000000 --- a/third_party/android_frameworks_native/include/gui/BufferSlot.h +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2014 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_BUFFERSLOT_H -#define ANDROID_GUI_BUFFERSLOT_H - -#include -#include - -#include -#include - -#include - -namespace android { - -class Fence; - -struct BufferSlot { - - BufferSlot() - : mEglDisplay(EGL_NO_DISPLAY), - mBufferState(BufferSlot::FREE), - mRequestBufferCalled(false), - mFrameNumber(0), - mEglFence(EGL_NO_SYNC_KHR), - mAcquireCalled(false), - mNeedsCleanupOnRelease(false), - mAttachedByConsumer(false) { - } - - // mGraphicBuffer points to the buffer allocated for this slot or is NULL - // if no buffer has been allocated. - sp mGraphicBuffer; - - // mEglDisplay is the EGLDisplay used to create EGLSyncKHR objects. - EGLDisplay mEglDisplay; - - // BufferState represents the different states in which a buffer slot - // can be. All slots are initially FREE. - enum BufferState { - // FREE indicates that the buffer is available to be dequeued - // by the producer. The buffer may be in use by the consumer for - // a finite time, so the buffer must not be modified until the - // associated fence is signaled. - // - // The slot is "owned" by BufferQueue. It transitions to DEQUEUED - // when dequeueBuffer is called. - FREE = 0, - - // DEQUEUED indicates that the buffer has been dequeued by the - // producer, but has not yet been queued or canceled. The - // producer may modify the buffer's contents as soon as the - // associated ready fence is signaled. - // - // The slot is "owned" by the producer. It can transition to - // QUEUED (via queueBuffer) or back to FREE (via cancelBuffer). - DEQUEUED = 1, - - // QUEUED indicates that the buffer has been filled by the - // producer and queued for use by the consumer. The buffer - // contents may continue to be modified for a finite time, so - // the contents must not be accessed until the associated fence - // is signaled. - // - // The slot is "owned" by BufferQueue. It can transition to - // ACQUIRED (via acquireBuffer) or to FREE (if another buffer is - // queued in asynchronous mode). - QUEUED = 2, - - // ACQUIRED indicates that the buffer has been acquired by the - // consumer. As with QUEUED, the contents must not be accessed - // by the consumer until the fence is signaled. - // - // The slot is "owned" by the consumer. It transitions to FREE - // when releaseBuffer is called. - ACQUIRED = 3 - }; - - static const char* bufferStateName(BufferState state); - - // mBufferState is the current state of this buffer slot. - BufferState mBufferState; - - // mRequestBufferCalled is used for validating that the producer did - // call requestBuffer() when told to do so. Technically this is not - // needed but useful for debugging and catching producer bugs. - bool mRequestBufferCalled; - - // mFrameNumber is the number of the queued frame for this slot. This - // is used to dequeue buffers in LRU order (useful because buffers - // may be released before their release fence is signaled). - uint64_t mFrameNumber; - - // mEglFence is the EGL sync object that must signal before the buffer - // associated with this buffer slot may be dequeued. It is initialized - // to EGL_NO_SYNC_KHR when the buffer is created and may be set to a - // new sync object in releaseBuffer. (This is deprecated in favor of - // mFence, below.) - EGLSyncKHR mEglFence; - - // mFence is a fence which will signal when work initiated by the - // previous owner of the buffer is finished. When the buffer is FREE, - // the fence indicates when the consumer has finished reading - // from the buffer, or when the producer has finished writing if it - // called cancelBuffer after queueing some writes. When the buffer is - // QUEUED, it indicates when the producer has finished filling the - // buffer. When the buffer is DEQUEUED or ACQUIRED, the fence has been - // passed to the consumer or producer along with ownership of the - // buffer, and mFence is set to NO_FENCE. - sp mFence; - - // Indicates whether this buffer has been seen by a consumer yet - bool mAcquireCalled; - - // Indicates whether this buffer needs to be cleaned up by the - // consumer. This is set when a buffer in ACQUIRED state is freed. - // It causes releaseBuffer to return STALE_BUFFER_SLOT. - bool mNeedsCleanupOnRelease; - - // Indicates whether the buffer was attached on the consumer side. - // If so, it needs to set the BUFFER_NEEDS_REALLOCATION flag when dequeued - // to prevent the producer from using a stale cached buffer. - bool mAttachedByConsumer; -}; - -} // namespace android - -#endif diff --git a/third_party/android_frameworks_native/include/gui/ConsumerBase.h b/third_party/android_frameworks_native/include/gui/ConsumerBase.h deleted file mode 100644 index 9307a26fb3..0000000000 --- a/third_party/android_frameworks_native/include/gui/ConsumerBase.h +++ /dev/null @@ -1,252 +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 { - // See IConsumerListener::onFrame{Available,Replaced} - virtual void onFrameAvailable(const BufferItem& item) = 0; - virtual void onFrameReplaced(const BufferItem& /* item */) {} - }; - - 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(); - - // Returns true if the ConsumerBase is in the 'abandoned' state - bool isAbandoned(); - - // 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); - - // See IGraphicBufferConsumer::detachBuffer - status_t detachBuffer(int slot); - - // See IGraphicBufferConsumer::setDefaultBufferSize - status_t setDefaultBufferSize(uint32_t width, uint32_t height); - - // See IGraphicBufferConsumer::setDefaultBufferFormat - status_t setDefaultBufferFormat(PixelFormat defaultFormat); - - // See IGraphicBufferConsumer::setDefaultBufferDataSpace - status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace); - -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. The onFrameAvailable, onFrameReplaced, and - // onBuffersReleased 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. The ConsumerBase version of - // onSidebandStreamChanged does nothing and can be overriden by derived - // classes if they want the notification. - virtual void onFrameAvailable(const BufferItem& item) override; - virtual void onFrameReplaced(const BufferItem& item) override; - virtual void onBuffersReleased() override; - virtual void onSidebandStreamChanged() override; - - // 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(BufferItem *item, nsecs_t presentWhen, - uint64_t maxFrameNumber = 0); - - // 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/third_party/android_frameworks_native/include/gui/CpuConsumer.h b/third_party/android_frameworks_native/include/gui/CpuConsumer.h deleted file mode 100644 index 3b07a31750..0000000000 --- a/third_party/android_frameworks_native/include/gui/CpuConsumer.h +++ /dev/null @@ -1,131 +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 - -#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; - android_dataspace dataSpace; - uint64_t frameNumber; - // this is the same as format, except for formats that are compatible with - // a flexible format (e.g. HAL_PIXEL_FORMAT_YCbCr_420_888). In the latter - // case this contains that flexible format - PixelFormat flexFormat; - // Values below are only valid when using HAL_PIXEL_FORMAT_YCbCr_420_888 - // or compatible format, 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, - size_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); - - // 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 - size_t mMaxLockedBuffers; - - status_t releaseAcquiredBufferLocked(size_t 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 - size_t mCurrentLockedBuffers; - -}; - -} // namespace android - -#endif // ANDROID_GUI_CPUCONSUMER_H diff --git a/third_party/android_frameworks_native/include/gui/DisplayEventReceiver.h b/third_party/android_frameworks_native/include/gui/DisplayEventReceiver.h deleted file mode 100644 index a4718b91c6..0000000000 --- a/third_party/android_frameworks_native/include/gui/DisplayEventReceiver.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2011 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_DISPLAY_EVENT_H -#define ANDROID_GUI_DISPLAY_EVENT_H - -#include -#include - -#include -#include -#include - -#include - -// ---------------------------------------------------------------------------- - -namespace android { - -// ---------------------------------------------------------------------------- - -class BitTube; -class IDisplayEventConnection; - -// ---------------------------------------------------------------------------- - -class DisplayEventReceiver { -public: - enum { - DISPLAY_EVENT_VSYNC = 'vsyn', - DISPLAY_EVENT_HOTPLUG = 'plug' - }; - - struct Event { - - struct Header { - uint32_t type; - uint32_t id; - nsecs_t timestamp __attribute__((aligned(8))); - }; - - struct VSync { - uint32_t count; - }; - - struct Hotplug { - bool connected; - }; - - Header header; - union { - VSync vsync; - Hotplug hotplug; - }; - }; - -public: - /* - * DisplayEventReceiver creates and registers an event connection with - * SurfaceFlinger. VSync events are disabled by default. Call setVSyncRate - * or requestNextVsync to receive them. - * Other events start being delivered immediately. - */ - DisplayEventReceiver(); - - /* - * ~DisplayEventReceiver severs the connection with SurfaceFlinger, new events - * stop being delivered immediately. Note that the queue could have - * some events pending. These will be delivered. - */ - ~DisplayEventReceiver(); - - /* - * initCheck returns the state of DisplayEventReceiver after construction. - */ - status_t initCheck() const; - - /* - * getFd returns the file descriptor to use to receive events. - * OWNERSHIP IS RETAINED by DisplayEventReceiver. DO NOT CLOSE this - * file-descriptor. - */ - int getFd() const; - - /* - * getEvents reads events from the queue and returns how many events were - * read. Returns 0 if there are no more events or a negative error code. - * If NOT_ENOUGH_DATA is returned, the object has become invalid forever, it - * should be destroyed and getEvents() shouldn't be called again. - */ - ssize_t getEvents(Event* events, size_t count); - static ssize_t getEvents(const sp& dataChannel, - Event* events, size_t count); - - /* - * sendEvents write events to the queue and returns how many events were - * written. - */ - static ssize_t sendEvents(const sp& dataChannel, - Event const* events, size_t count); - - /* - * setVsyncRate() sets the Event::VSync delivery rate. A value of - * 1 returns every Event::VSync. A value of 2 returns every other event, - * etc... a value of 0 returns no event unless requestNextVsync() has - * been called. - */ - status_t setVsyncRate(uint32_t count); - - /* - * requestNextVsync() schedules the next Event::VSync. It has no effect - * if the vsync rate is > 0. - */ - status_t requestNextVsync(); - -private: - sp mEventConnection; - sp mDataChannel; -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_DISPLAY_EVENT_H diff --git a/third_party/android_frameworks_native/include/gui/GLConsumer.h b/third_party/android_frameworks_native/include/gui/GLConsumer.h deleted file mode 100644 index c35c7be064..0000000000 --- a/third_party/android_frameworks_native/include/gui/GLConsumer.h +++ /dev/null @@ -1,488 +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_CONSUMER_H -#define ANDROID_GUI_CONSUMER_H - -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - - -class String8; - -/* - * GLConsumer consumes buffers of graphics data from a BufferQueue, - * and makes them available to OpenGL as a texture. - * - * A typical usage pattern is to set up the GLConsumer with the - * desired options, and call updateTexImage() when a new frame is desired. - * If a new frame is available, the texture will be updated. If not, - * the previous contents are retained. - * - * By default, the texture is attached to the GL_TEXTURE_EXTERNAL_OES - * texture target, in the EGL context of the first thread that calls - * updateTexImage(). - * - * This class was previously called SurfaceTexture. - */ -class GLConsumer : public ConsumerBase { -public: - enum { TEXTURE_EXTERNAL = 0x8D65 }; // GL_TEXTURE_EXTERNAL_OES - typedef ConsumerBase::FrameAvailableListener FrameAvailableListener; - - // GLConsumer constructs a new GLConsumer object. If the constructor with - // the tex parameter is used, tex indicates the name of the OpenGL ES - // texture to which images are to be streamed. texTarget specifies the - // OpenGL ES texture target to which the texture will be bound in - // updateTexImage. useFenceSync specifies whether fences should be used to - // synchronize access to buffers if that behavior is enabled at - // compile-time. - // - // A GLConsumer may be detached from one OpenGL ES context and then - // attached to a different context using the detachFromContext and - // attachToContext methods, respectively. The intention of these methods is - // purely to allow a GLConsumer to be transferred from one consumer - // context to another. If such a transfer is not needed there is no - // requirement that either of these methods be called. - // - // If the constructor with the tex parameter is used, the GLConsumer is - // created in a state where it is considered attached to an OpenGL ES - // context for the purposes of the attachToContext and detachFromContext - // methods. However, despite being considered "attached" to a context, the - // specific OpenGL ES context doesn't get latched until the first call to - // updateTexImage. After that point, all calls to updateTexImage must be - // made with the same OpenGL ES context current. - // - // If the constructor without the tex parameter is used, the GLConsumer is - // created in a detached state, and attachToContext must be called before - // calls to updateTexImage. - GLConsumer(const sp& bq, - uint32_t tex, uint32_t texureTarget, bool useFenceSync, - bool isControlledByApp); - - GLConsumer(const sp& bq, uint32_t texureTarget, - bool useFenceSync, bool isControlledByApp); - - // updateTexImage acquires the most recently queued buffer, and sets the - // image contents of the target texture to it. - // - // This call may only be made while the OpenGL ES context to which the - // target texture belongs is bound to the calling thread. - // - // This calls doGLFenceWait to ensure proper synchronization. - status_t updateTexImage(); - - // releaseTexImage releases the texture acquired in updateTexImage(). - // This is intended to be used in single buffer mode. - // - // This call may only be made while the OpenGL ES context to which the - // target texture belongs is bound to the calling thread. - status_t releaseTexImage(); - - // setReleaseFence stores a fence that will signal when the current buffer - // is no longer being read. This fence will be returned to the producer - // when the current buffer is released by updateTexImage(). Multiple - // fences can be set for a given buffer; they will be merged into a single - // union fence. - void setReleaseFence(const sp& fence); - - // setDefaultMaxBufferCount sets the default limit on the maximum number - // of buffers that will be allocated at one time. The image producer may - // override the limit. - status_t setDefaultMaxBufferCount(int bufferCount); - - // getTransformMatrix retrieves the 4x4 texture coordinate transform matrix - // associated with the texture image set by the most recent call to - // updateTexImage. - // - // This transform matrix maps 2D homogeneous texture coordinates of the form - // (s, t, 0, 1) with s and t in the inclusive range [0, 1] to the texture - // coordinate that should be used to sample that location from the texture. - // Sampling the texture outside of the range of this transform is undefined. - // - // This transform is necessary to compensate for transforms that the stream - // content producer may implicitly apply to the content. By forcing users of - // a GLConsumer to apply this transform we avoid performing an extra - // copy of the data that would be needed to hide the transform from the - // user. - // - // The matrix is stored in column-major order so that it may be passed - // directly to OpenGL ES via the glLoadMatrixf or glUniformMatrix4fv - // functions. - void getTransformMatrix(float mtx[16]); - - // getTimestamp retrieves the timestamp associated with the texture image - // set by the most recent call to updateTexImage. - // - // The timestamp is in nanoseconds, and is monotonically increasing. Its - // other semantics (zero point, etc) are source-dependent and should be - // documented by the source. - int64_t getTimestamp(); - - // getFrameNumber retrieves the frame number associated with the texture - // image set by the most recent call to updateTexImage. - // - // The frame number is an incrementing counter set to 0 at the creation of - // the BufferQueue associated with this consumer. - uint64_t getFrameNumber(); - - // setDefaultBufferSize is used to set the size of buffers returned by - // requestBuffers when a with and height of zero is requested. - // A call to setDefaultBufferSize() may trigger requestBuffers() to - // be called from the client. - // The width and height parameters must be no greater than the minimum of - // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). - // An error due to invalid dimensions might not be reported until - // updateTexImage() is called. - status_t setDefaultBufferSize(uint32_t width, uint32_t height); - - // setFilteringEnabled sets whether the transform matrix should be computed - // for use with bilinear filtering. - void setFilteringEnabled(bool enabled); - - // getCurrentBuffer returns the buffer associated with the current image. - sp getCurrentBuffer() const; - - // getCurrentTextureTarget returns the texture target of the current - // texture as returned by updateTexImage(). - uint32_t getCurrentTextureTarget() const; - - // getCurrentCrop returns the cropping rectangle of the current buffer. - Rect getCurrentCrop() const; - - // getCurrentTransform returns the transform of the current buffer. - uint32_t getCurrentTransform() const; - - // getCurrentScalingMode returns the scaling mode of the current buffer. - uint32_t getCurrentScalingMode() const; - - // getCurrentFence returns the fence indicating when the current buffer is - // ready to be read from. - sp getCurrentFence() const; - - // doGLFenceWait inserts a wait command into the OpenGL ES command stream - // to ensure that it is safe for future OpenGL ES commands to access the - // current texture buffer. - status_t doGLFenceWait() const; - - // set the name of the GLConsumer that will be used to identify it in - // log messages. - void setName(const String8& name); - - // These functions call the corresponding BufferQueue implementation - // so the refactoring can proceed smoothly - status_t setDefaultBufferFormat(PixelFormat defaultFormat); - status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace); - status_t setConsumerUsageBits(uint32_t usage); - status_t setTransformHint(uint32_t hint); - - // detachFromContext detaches the GLConsumer from the calling thread's - // current OpenGL ES context. This context must be the same as the context - // that was current for previous calls to updateTexImage. - // - // Detaching a GLConsumer from an OpenGL ES context will result in the - // deletion of the OpenGL ES texture object into which the images were being - // streamed. After a GLConsumer has been detached from the OpenGL ES - // context calls to updateTexImage will fail returning INVALID_OPERATION - // until the GLConsumer is attached to a new OpenGL ES context using the - // attachToContext method. - status_t detachFromContext(); - - // attachToContext attaches a GLConsumer that is currently in the - // 'detached' state to the current OpenGL ES context. A GLConsumer is - // in the 'detached' state iff detachFromContext has successfully been - // called and no calls to attachToContext have succeeded since the last - // detachFromContext call. Calls to attachToContext made on a - // GLConsumer that is not in the 'detached' state will result in an - // INVALID_OPERATION error. - // - // The tex argument specifies the OpenGL ES texture object name in the - // new context into which the image contents will be streamed. A successful - // call to attachToContext will result in this texture object being bound to - // the texture target and populated with the image contents that were - // current at the time of the last call to detachFromContext. - status_t attachToContext(uint32_t tex); - -protected: - - // abandonLocked overrides the ConsumerBase method to clear - // mCurrentTextureImage in addition to the ConsumerBase behavior. - virtual void abandonLocked(); - - // dumpLocked overrides the ConsumerBase method to dump GLConsumer- - // specific info in addition to the ConsumerBase behavior. - virtual void dumpLocked(String8& result, const char* prefix) const; - - // acquireBufferLocked overrides the ConsumerBase method to update the - // mEglSlots array in addition to the ConsumerBase behavior. - virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen, - uint64_t maxFrameNumber = 0) override; - - // releaseBufferLocked overrides the ConsumerBase method to update the - // mEglSlots array in addition to the ConsumerBase. - virtual status_t releaseBufferLocked(int slot, - const sp graphicBuffer, - EGLDisplay display, EGLSyncKHR eglFence); - - status_t releaseBufferLocked(int slot, - const sp graphicBuffer, EGLSyncKHR eglFence) { - return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence); - } - - static bool isExternalFormat(PixelFormat format); - - // This releases the buffer in the slot referenced by mCurrentTexture, - // then updates state to refer to the BufferItem, which must be a - // newly-acquired buffer. - status_t updateAndReleaseLocked(const BufferItem& item); - - // Binds mTexName and the current buffer to mTexTarget. Uses - // mCurrentTexture if it's set, mCurrentTextureImage if not. If the - // bind succeeds, this calls doGLFenceWait. - status_t bindTextureImageLocked(); - - // Gets the current EGLDisplay and EGLContext values, and compares them - // to mEglDisplay and mEglContext. If the fields have been previously - // set, the values must match; if not, the fields are set to the current - // values. - // The contextCheck argument is used to ensure that a GL context is - // properly set; when set to false, the check is not performed. - status_t checkAndUpdateEglStateLocked(bool contextCheck = false); - -private: - // EglImage is a utility class for tracking and creating EGLImageKHRs. There - // is primarily just one image per slot, but there is also special cases: - // - For releaseTexImage, we use a debug image (mReleasedTexImage) - // - After freeBuffer, we must still keep the current image/buffer - // Reference counting EGLImages lets us handle all these cases easily while - // also only creating new EGLImages from buffers when required. - class EglImage : public LightRefBase { - public: - EglImage(sp graphicBuffer); - - // createIfNeeded creates an EGLImage if required (we haven't created - // one yet, or the EGLDisplay or crop-rect has changed). - status_t createIfNeeded(EGLDisplay display, - const Rect& cropRect, - bool forceCreate = false); - - // This calls glEGLImageTargetTexture2DOES to bind the image to the - // texture in the specified texture target. - void bindToTextureTarget(uint32_t texTarget); - - const sp& graphicBuffer() { return mGraphicBuffer; } - const native_handle* graphicBufferHandle() { - return mGraphicBuffer == NULL ? NULL : mGraphicBuffer->handle; - } - - private: - // Only allow instantiation using ref counting. - friend class LightRefBase; - virtual ~EglImage(); - - // createImage creates a new EGLImage from a GraphicBuffer. - EGLImageKHR createImage(EGLDisplay dpy, - const sp& graphicBuffer, const Rect& crop); - - // Disallow copying - EglImage(const EglImage& rhs); - void operator = (const EglImage& rhs); - - // mGraphicBuffer is the buffer that was used to create this image. - sp mGraphicBuffer; - - // mEglImage is the EGLImage created from mGraphicBuffer. - EGLImageKHR mEglImage; - - // mEGLDisplay is the EGLDisplay that was used to create mEglImage. - EGLDisplay mEglDisplay; - - // mCropRect is the crop rectangle passed to EGL when mEglImage - // was created. - Rect mCropRect; - }; - - // freeBufferLocked frees up the given buffer slot. If the slot has been - // initialized this will release the reference to the GraphicBuffer in that - // slot and destroy the EGLImage in that slot. Otherwise it has no effect. - // - // This method must be called with mMutex locked. - virtual void freeBufferLocked(int slotIndex); - - // computeCurrentTransformMatrixLocked computes the transform matrix for the - // current texture. It uses mCurrentTransform and the current GraphicBuffer - // to compute this matrix and stores it in mCurrentTransformMatrix. - // mCurrentTextureImage must not be NULL. - void computeCurrentTransformMatrixLocked(); - - // doGLFenceWaitLocked inserts a wait command into the OpenGL ES command - // stream to ensure that it is safe for future OpenGL ES commands to - // access the current texture buffer. - status_t doGLFenceWaitLocked() const; - - // syncForReleaseLocked performs the synchronization needed to release the - // current slot from an OpenGL ES context. If needed it will set the - // current slot's fence to guard against a producer accessing the buffer - // before the outstanding accesses have completed. - status_t syncForReleaseLocked(EGLDisplay dpy); - - // returns a graphic buffer used when the texture image has been released - static sp getDebugTexImageBuffer(); - - // The default consumer usage flags that GLConsumer always sets on its - // BufferQueue instance; these will be OR:d with any additional flags passed - // from the GLConsumer user. In particular, GLConsumer will always - // consume buffers as hardware textures. - static const uint32_t DEFAULT_USAGE_FLAGS = GraphicBuffer::USAGE_HW_TEXTURE; - - // mCurrentTextureImage is the EglImage/buffer of the current texture. It's - // possible that this buffer is not associated with any buffer slot, so we - // must track it separately in order to support the getCurrentBuffer method. - sp mCurrentTextureImage; - - // mCurrentCrop is the crop rectangle that applies to the current texture. - // It gets set each time updateTexImage is called. - Rect mCurrentCrop; - - // mCurrentTransform is the transform identifier for the current texture. It - // gets set each time updateTexImage is called. - uint32_t mCurrentTransform; - - // mCurrentScalingMode is the scaling mode for the current texture. It gets - // set each time updateTexImage is called. - uint32_t mCurrentScalingMode; - - // mCurrentFence is the fence received from BufferQueue in updateTexImage. - sp mCurrentFence; - - // mCurrentTransformMatrix is the transform matrix for the current texture. - // It gets computed by computeTransformMatrix each time updateTexImage is - // called. - float mCurrentTransformMatrix[16]; - - // mCurrentTimestamp is the timestamp for the current texture. It - // gets set each time updateTexImage is called. - int64_t mCurrentTimestamp; - - // mCurrentFrameNumber is the frame counter for the current texture. - // It gets set each time updateTexImage is called. - uint64_t mCurrentFrameNumber; - - uint32_t mDefaultWidth, mDefaultHeight; - - // mFilteringEnabled indicates whether the transform matrix is computed for - // use with bilinear filtering. It defaults to true and is changed by - // setFilteringEnabled(). - bool mFilteringEnabled; - - // mTexName is the name of the OpenGL texture to which streamed images will - // be bound when updateTexImage is called. It is set at construction time - // and can be changed with a call to attachToContext. - uint32_t mTexName; - - // mUseFenceSync indicates whether creation of the EGL_KHR_fence_sync - // extension should be used to prevent buffers from being dequeued before - // it's safe for them to be written. It gets set at construction time and - // never changes. - const bool mUseFenceSync; - - // mTexTarget is the GL texture target with which the GL texture object is - // associated. It is set in the constructor and never changed. It is - // almost always GL_TEXTURE_EXTERNAL_OES except for one use case in Android - // Browser. In that case it is set to GL_TEXTURE_2D to allow - // glCopyTexSubImage to read from the texture. This is a hack to work - // around a GL driver limitation on the number of FBO attachments, which the - // browser's tile cache exceeds. - const uint32_t mTexTarget; - - // EGLSlot contains the information and object references that - // GLConsumer maintains about a BufferQueue buffer slot. - struct EglSlot { - EglSlot() : mEglFence(EGL_NO_SYNC_KHR) {} - - // mEglImage is the EGLImage created from mGraphicBuffer. - sp mEglImage; - - // mFence is the EGL sync object that must signal before the buffer - // associated with this buffer slot may be dequeued. It is initialized - // to EGL_NO_SYNC_KHR when the buffer is created and (optionally, based - // on a compile-time option) set to a new sync object in updateTexImage. - EGLSyncKHR mEglFence; - }; - - // mEglDisplay is the EGLDisplay with which this GLConsumer is currently - // associated. It is intialized to EGL_NO_DISPLAY and gets set to the - // current display when updateTexImage is called for the first time and when - // attachToContext is called. - EGLDisplay mEglDisplay; - - // mEglContext is the OpenGL ES context with which this GLConsumer is - // currently associated. It is initialized to EGL_NO_CONTEXT and gets set - // to the current GL context when updateTexImage is called for the first - // time and when attachToContext is called. - EGLContext mEglContext; - - // mEGLSlots 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. - EglSlot mEglSlots[BufferQueue::NUM_BUFFER_SLOTS]; - - // mCurrentTexture is the buffer slot index of the buffer that is currently - // bound to the OpenGL texture. It is initialized to INVALID_BUFFER_SLOT, - // indicating that no buffer slot is currently bound to the texture. Note, - // however, that a value of INVALID_BUFFER_SLOT does not necessarily mean - // that no buffer is bound to the texture. A call to setBufferCount will - // reset mCurrentTexture to INVALID_BUFFER_SLOT. - int mCurrentTexture; - - // mAttached indicates whether the ConsumerBase is currently attached to - // an OpenGL ES context. For legacy reasons, this is initialized to true, - // indicating that the ConsumerBase is considered to be attached to - // whatever context is current at the time of the first updateTexImage call. - // It is set to false by detachFromContext, and then set to true again by - // attachToContext. - bool mAttached; - - // protects static initialization - static Mutex sStaticInitLock; - - // mReleasedTexImageBuffer is a dummy buffer used when in single buffer - // mode and releaseTexImage() has been called - static sp sReleasedTexImageBuffer; - sp mReleasedTexImage; -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_CONSUMER_H diff --git a/third_party/android_frameworks_native/include/gui/GraphicBufferAlloc.h b/third_party/android_frameworks_native/include/gui/GraphicBufferAlloc.h deleted file mode 100644 index 69fe51ef93..0000000000 --- a/third_party/android_frameworks_native/include/gui/GraphicBufferAlloc.h +++ /dev/null @@ -1,45 +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_SF_GRAPHIC_BUFFER_ALLOC_H -#define ANDROID_SF_GRAPHIC_BUFFER_ALLOC_H - -#include -#include - -#include -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -class GraphicBuffer; - -class GraphicBufferAlloc : public BnGraphicBufferAlloc { -public: - GraphicBufferAlloc(); - virtual ~GraphicBufferAlloc(); - virtual sp createGraphicBuffer(uint32_t width, - uint32_t height, PixelFormat format, uint32_t usage, - status_t* error); -}; - - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_SF_GRAPHIC_BUFFER_ALLOC_H diff --git a/third_party/android_frameworks_native/include/gui/GuiConfig.h b/third_party/android_frameworks_native/include/gui/GuiConfig.h deleted file mode 100644 index b020ed9b6a..0000000000 --- a/third_party/android_frameworks_native/include/gui/GuiConfig.h +++ /dev/null @@ -1,29 +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_CONFIG_H -#define ANDROID_GUI_CONFIG_H - -#include - -namespace android { - -// Append the libgui configuration details to configStr. -void appendGuiConfigString(String8& configStr); - -}; // namespace android - -#endif /*ANDROID_GUI_CONFIG_H*/ diff --git a/third_party/android_frameworks_native/include/gui/IConsumerListener.h b/third_party/android_frameworks_native/include/gui/IConsumerListener.h deleted file mode 100644 index 3f39799564..0000000000 --- a/third_party/android_frameworks_native/include/gui/IConsumerListener.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2013 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_ICONSUMERLISTENER_H -#define ANDROID_GUI_ICONSUMERLISTENER_H - -#include -#include - -#include -#include - -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class BufferItem; - -// ConsumerListener is the interface through which the BufferQueue notifies -// the consumer of events that the consumer may wish to react to. Because -// the consumer will generally have a mutex that is locked during calls from -// the consumer to the BufferQueue, these calls from the BufferQueue to the -// consumer *MUST* be called only when the BufferQueue mutex is NOT locked. - -class ConsumerListener : public virtual RefBase { -public: - ConsumerListener() { } - virtual ~ConsumerListener() { } - - // onFrameAvailable is called from queueBuffer 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. The item passed to the callback will contain - // all of the information about the queued frame except for its - // GraphicBuffer pointer, which will always be null. - // - // This is called without any lock held and can be called concurrently - // by multiple threads. - virtual void onFrameAvailable(const BufferItem& item) = 0; /* Asynchronous */ - - // onFrameReplaced is called from queueBuffer if the frame being queued is - // replacing an existing slot in the queue. Any call to queueBuffer that - // doesn't call onFrameAvailable will call this callback instead. The item - // passed to the callback will contain all of the information about the - // queued frame except for its GraphicBuffer pointer, which will always be - // null. - // - // This is called without any lock held and can be called concurrently - // by multiple threads. - virtual void onFrameReplaced(const BufferItem& /* item */) {} /* Asynchronous */ - - // onBuffersReleased is called to notify the buffer consumer that the - // BufferQueue has released its references to one or more GraphicBuffers - // contained in its slots. The buffer consumer should then call - // BufferQueue::getReleasedBuffers to retrieve the list of buffers - // - // This is called without any lock held and can be called concurrently - // by multiple threads. - virtual void onBuffersReleased() = 0; /* Asynchronous */ - - // onSidebandStreamChanged is called to notify the buffer consumer that the - // BufferQueue's sideband buffer stream has changed. This is called when a - // stream is first attached and when it is either detached or replaced by a - // different stream. - virtual void onSidebandStreamChanged() = 0; /* Asynchronous */ -}; - - -class IConsumerListener : public ConsumerListener, public IInterface -{ -public: - DECLARE_META_INTERFACE(ConsumerListener); -}; - -// ---------------------------------------------------------------------------- - -class BnConsumerListener : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_ICONSUMERLISTENER_H diff --git a/third_party/android_frameworks_native/include/gui/IDisplayEventConnection.h b/third_party/android_frameworks_native/include/gui/IDisplayEventConnection.h deleted file mode 100644 index 86247de62b..0000000000 --- a/third_party/android_frameworks_native/include/gui/IDisplayEventConnection.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2011 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_IDISPLAY_EVENT_CONNECTION_H -#define ANDROID_GUI_IDISPLAY_EVENT_CONNECTION_H - -#include -#include - -#include -#include - -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class BitTube; - -class IDisplayEventConnection : public IInterface -{ -public: - - DECLARE_META_INTERFACE(DisplayEventConnection); - - /* - * getDataChannel() returns a BitTube where to receive the events from - */ - virtual sp getDataChannel() const = 0; - - /* - * setVsyncRate() sets the vsync event delivery rate. A value of - * 1 returns every vsync events. A value of 2 returns every other events, - * etc... a value of 0 returns no event unless requestNextVsync() has - * been called. - */ - virtual void setVsyncRate(uint32_t count) = 0; - - /* - * requestNextVsync() schedules the next vsync event. It has no effect - * if the vsync rate is > 0. - */ - virtual void requestNextVsync() = 0; // asynchronous -}; - -// ---------------------------------------------------------------------------- - -class BnDisplayEventConnection : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_IDISPLAY_EVENT_CONNECTION_H diff --git a/third_party/android_frameworks_native/include/gui/IGraphicBufferAlloc.h b/third_party/android_frameworks_native/include/gui/IGraphicBufferAlloc.h deleted file mode 100644 index f3c46ec2ed..0000000000 --- a/third_party/android_frameworks_native/include/gui/IGraphicBufferAlloc.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2011 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_IGRAPHIC_BUFFER_ALLOC_H -#define ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H - -#include -#include - -#include -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class GraphicBuffer; - -class IGraphicBufferAlloc : public IInterface -{ -public: - DECLARE_META_INTERFACE(GraphicBufferAlloc); - - /* Create a new GraphicBuffer for the client to use. - */ - virtual sp createGraphicBuffer(uint32_t w, uint32_t h, - PixelFormat format, uint32_t usage, status_t* error) = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnGraphicBufferAlloc : public BnInterface -{ -public: - virtual status_t onTransact(uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H diff --git a/third_party/android_frameworks_native/include/gui/IGraphicBufferConsumer.h b/third_party/android_frameworks_native/include/gui/IGraphicBufferConsumer.h deleted file mode 100644 index 60ec9cc0e9..0000000000 --- a/third_party/android_frameworks_native/include/gui/IGraphicBufferConsumer.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (C) 2013 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_IGRAPHICBUFFERCONSUMER_H -#define ANDROID_GUI_IGRAPHICBUFFERCONSUMER_H - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class BufferItem; -class Fence; -class GraphicBuffer; -class IConsumerListener; -class NativeHandle; - -class IGraphicBufferConsumer : public IInterface { - -public: - enum { - // Returned by releaseBuffer, after which the consumer must - // free any references to the just-released buffer that it might have. - STALE_BUFFER_SLOT = 1, - // Returned by dequeueBuffer if there are no pending buffers available. - NO_BUFFER_AVAILABLE, - // Returned by dequeueBuffer if it's too early for the buffer to be acquired. - PRESENT_LATER, - }; - - // acquireBuffer attempts to acquire ownership of the next pending buffer in - // the BufferQueue. If no buffer is pending then it returns - // NO_BUFFER_AVAILABLE. If a buffer is successfully acquired, the - // information about the buffer is returned in BufferItem. - // - // If the buffer returned had previously been - // acquired then the BufferItem::mGraphicBuffer field of buffer is set to - // NULL and it is assumed that the consumer still holds a reference to the - // buffer. - // - // If presentWhen is non-zero, it indicates the time when the buffer will - // be displayed on screen. If the buffer's timestamp is farther in the - // future, the buffer won't be acquired, and PRESENT_LATER will be - // returned. The presentation time is in nanoseconds, and the time base - // is CLOCK_MONOTONIC. - // - // If maxFrameNumber is non-zero, it indicates that acquireBuffer should - // only return a buffer with a frame number less than or equal to - // maxFrameNumber. If no such frame is available (such as when a buffer has - // been replaced but the consumer has not received the onFrameReplaced - // callback), then PRESENT_LATER will be returned. - // - // Return of NO_ERROR means the operation completed as normal. - // - // Return of a positive value means the operation could not be completed - // at this time, but the user should try again later: - // * NO_BUFFER_AVAILABLE - no buffer is pending (nothing queued by producer) - // * PRESENT_LATER - the buffer's timestamp is farther in the future - // - // Return of a negative value means an error has occurred: - // * INVALID_OPERATION - too many buffers have been acquired - virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen, - uint64_t maxFrameNumber = 0) = 0; - - // detachBuffer attempts to remove all ownership of the buffer in the given - // slot from the buffer queue. If this call succeeds, the slot will be - // freed, and there will be no way to obtain the buffer from this interface. - // The freed slot will remain unallocated until either it is selected to - // hold a freshly allocated buffer in dequeueBuffer or a buffer is attached - // to the slot. The buffer must have already been acquired. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * BAD_VALUE - the given slot number is invalid, either because it is - // out of the range [0, NUM_BUFFER_SLOTS) or because the slot - // it refers to is not currently acquired. - virtual status_t detachBuffer(int slot) = 0; - - // attachBuffer attempts to transfer ownership of a buffer to the buffer - // queue. If this call succeeds, it will be as if this buffer was acquired - // from the returned slot number. As such, this call will fail if attaching - // this buffer would cause too many buffers to be simultaneously acquired. - // - // If the buffer is successfully attached, its frameNumber is initialized - // to 0. This must be passed into the releaseBuffer call or else the buffer - // will be deallocated as stale. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * BAD_VALUE - outSlot or buffer were NULL, or the generation number of - // the buffer did not match the buffer queue. - // * INVALID_OPERATION - cannot attach the buffer because it would cause too - // many buffers to be acquired. - // * NO_MEMORY - no free slots available - virtual status_t attachBuffer(int *outSlot, - const sp& buffer) = 0; - - // releaseBuffer releases a buffer slot from the consumer back to the - // BufferQueue. This may be done while the buffer's contents are still - // being accessed. The fence will signal when the buffer is no longer - // in use. frameNumber is used to indentify the exact buffer returned. - // - // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free - // any references to the just-released buffer that it might have, as if it - // had received a onBuffersReleased() call with a mask set for the released - // buffer. - // - // Note that the dependencies on EGL will be removed once we switch to using - // the Android HW Sync HAL. - // - // Return of NO_ERROR means the operation completed as normal. - // - // Return of a positive value means the operation could not be completed - // at this time, but the user should try again later: - // * STALE_BUFFER_SLOT - see above (second paragraph) - // - // Return of a negative value means an error has occurred: - // * BAD_VALUE - one of the following could've happened: - // * the buffer slot was invalid - // * the fence was NULL - // * the buffer slot specified is not in the acquired state - virtual status_t releaseBuffer(int buf, uint64_t frameNumber, - EGLDisplay display, EGLSyncKHR fence, - const sp& releaseFence) = 0; - - // consumerConnect connects a consumer to the BufferQueue. Only one - // consumer may be connected, and when that consumer disconnects the - // BufferQueue is placed into the "abandoned" state, causing most - // interactions with the BufferQueue by the producer to fail. - // controlledByApp indicates whether the consumer is controlled by - // the application. - // - // consumer may not be NULL. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned - // * BAD_VALUE - a NULL consumer was provided - virtual status_t consumerConnect(const sp& consumer, bool controlledByApp) = 0; - - // consumerDisconnect disconnects a consumer from the BufferQueue. All - // buffers will be freed and the BufferQueue is placed in the "abandoned" - // state, causing most interactions with the BufferQueue by the producer to - // fail. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * BAD_VALUE - no consumer is currently connected - virtual status_t consumerDisconnect() = 0; - - // getReleasedBuffers sets the value pointed to by slotMask to a bit set. - // Each bit index with a 1 corresponds to a released buffer slot with that - // index value. In particular, a released buffer is one that has - // been released by the BufferQueue but have not yet been released by the consumer. - // - // This should be called from the onBuffersReleased() callback. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - virtual status_t getReleasedBuffers(uint64_t* slotMask) = 0; - - // setDefaultBufferSize is used to set the size of buffers returned by - // dequeueBuffer when a width and height of zero is requested. Default - // is 1x1. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * BAD_VALUE - either w or h was zero - virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h) = 0; - - // setDefaultMaxBufferCount sets the default value for the maximum buffer - // count (the initial default is 2). If the producer has requested a - // buffer count using setBufferCount, the default buffer count will only - // take effect if the producer sets the count back to zero. - // - // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * BAD_VALUE - bufferCount was out of range (see above). - virtual status_t setDefaultMaxBufferCount(int bufferCount) = 0; - - // disableAsyncBuffer disables the extra buffer used in async mode - // (when both producer and consumer have set their "isControlledByApp" - // flag) and has dequeueBuffer() return WOULD_BLOCK instead. - // - // This can only be called before consumerConnect(). - // - // Return of a value other than NO_ERROR means an error has occurred: - // * INVALID_OPERATION - attempting to call this after consumerConnect. - virtual status_t disableAsyncBuffer() = 0; - - // setMaxAcquiredBufferCount sets the maximum number of buffers that can - // be acquired by the consumer at one time (default 1). This call will - // fail if a producer is connected to the BufferQueue. - // - // maxAcquiredBuffers must be (inclusive) between 1 and MAX_MAX_ACQUIRED_BUFFERS. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * BAD_VALUE - maxAcquiredBuffers was out of range (see above). - // * INVALID_OPERATION - attempting to call this after a producer connected. - virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) = 0; - - // setConsumerName sets the name used in logging - virtual void setConsumerName(const String8& name) = 0; - - // setDefaultBufferFormat allows the BufferQueue to create - // GraphicBuffers of a defaultFormat if no format is specified - // in dequeueBuffer. - // The initial default is PIXEL_FORMAT_RGBA_8888. - // - // Return of a value other than NO_ERROR means an unknown error has occurred. - virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) = 0; - - // setDefaultBufferDataSpace is a request to the producer to provide buffers - // of the indicated dataSpace. The producer may ignore this request. - // The initial default is HAL_DATASPACE_UNKNOWN. - // - // Return of a value other than NO_ERROR means an unknown error has occurred. - virtual status_t setDefaultBufferDataSpace( - android_dataspace defaultDataSpace) = 0; - - // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer. - // These are merged with the bits passed to dequeueBuffer. The values are - // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0. - // - // Return of a value other than NO_ERROR means an unknown error has occurred. - virtual status_t setConsumerUsageBits(uint32_t usage) = 0; - - // setTransformHint bakes in rotation to buffers so overlays can be used. - // The values are enumerated in window.h, e.g. - // NATIVE_WINDOW_TRANSFORM_ROT_90. The default is 0 (no transform). - // - // Return of a value other than NO_ERROR means an unknown error has occurred. - virtual status_t setTransformHint(uint32_t hint) = 0; - - // Retrieve the sideband buffer stream, if any. - virtual sp getSidebandStream() const = 0; - - // dump state into a string - virtual void dump(String8& result, const char* prefix) const = 0; - -public: - DECLARE_META_INTERFACE(GraphicBufferConsumer); -}; - -// ---------------------------------------------------------------------------- - -class BnGraphicBufferConsumer : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_IGRAPHICBUFFERCONSUMER_H diff --git a/third_party/android_frameworks_native/include/gui/IGraphicBufferProducer.h b/third_party/android_frameworks_native/include/gui/IGraphicBufferProducer.h deleted file mode 100644 index 9530de1aa8..0000000000 --- a/third_party/android_frameworks_native/include/gui/IGraphicBufferProducer.h +++ /dev/null @@ -1,502 +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_IGRAPHICBUFFERPRODUCER_H -#define ANDROID_GUI_IGRAPHICBUFFERPRODUCER_H - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class IProducerListener; -class NativeHandle; -class Surface; - -/* - * This class defines the Binder IPC interface for the producer side of - * a queue of graphics buffers. It's used to send graphics data from one - * component to another. For example, a class that decodes video for - * playback might use this to provide frames. This is typically done - * indirectly, through Surface. - * - * The underlying mechanism is a BufferQueue, which implements - * BnGraphicBufferProducer. In normal operation, the producer calls - * dequeueBuffer() to get an empty buffer, fills it with data, then - * calls queueBuffer() to make it available to the consumer. - * - * This class was previously called ISurfaceTexture. - */ -class IGraphicBufferProducer : public IInterface -{ -public: - DECLARE_META_INTERFACE(GraphicBufferProducer); - - enum { - // A flag returned by dequeueBuffer when the client needs to call - // requestBuffer immediately thereafter. - BUFFER_NEEDS_REALLOCATION = 0x1, - // A flag returned by dequeueBuffer when all mirrored slots should be - // released by the client. This flag should always be processed first. - RELEASE_ALL_BUFFERS = 0x2, - }; - - // requestBuffer requests a new buffer for the given index. The server (i.e. - // the IGraphicBufferProducer implementation) assigns the newly created - // buffer to the given slot index, and the client is expected to mirror the - // slot->buffer mapping so that it's not necessary to transfer a - // GraphicBuffer for every dequeue operation. - // - // The slot must be in the range of [0, NUM_BUFFER_SLOTS). - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - one of the two conditions occurred: - // * slot was out of range (see above) - // * buffer specified by the slot is not dequeued - virtual status_t requestBuffer(int slot, sp* buf) = 0; - - // setBufferCount sets the number of buffer slots available. Calling this - // will also cause all buffer slots to be emptied. The caller should empty - // its mirrored copy of the buffer slots when calling this method. - // - // This function should not be called when there are any dequeued buffer - // slots, doing so will result in a BAD_VALUE error returned. - // - // The buffer count should be at most NUM_BUFFER_SLOTS (inclusive), but at least - // the minimum undequeued buffer count (exclusive). The minimum value - // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS). - // In particular the range is (minUndequeudBuffers, NUM_BUFFER_SLOTS]. - // - // The buffer count may also be set to 0 (the default), to indicate that - // the producer does not wish to set a value. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - one of the below conditions occurred: - // * bufferCount was out of range (see above) - // * client has one or more buffers dequeued - virtual status_t setBufferCount(int bufferCount) = 0; - - // dequeueBuffer requests a new buffer slot for the client to use. Ownership - // of the slot is transfered to the client, meaning that the server will not - // use the contents of the buffer associated with that slot. - // - // The slot index returned may or may not contain a buffer (client-side). - // If the slot is empty the client should call requestBuffer to assign a new - // buffer to that slot. - // - // Once the client is done filling this buffer, it is expected to transfer - // buffer ownership back to the server with either cancelBuffer on - // the dequeued slot or to fill in the contents of its associated buffer - // contents and call queueBuffer. - // - // If dequeueBuffer returns the BUFFER_NEEDS_REALLOCATION flag, the client is - // expected to call requestBuffer immediately. - // - // If dequeueBuffer returns the RELEASE_ALL_BUFFERS flag, the client is - // expected to release all of the mirrored slot->buffer mappings. - // - // The fence parameter will be updated to hold the fence associated with - // the buffer. The contents of the buffer must not be overwritten until the - // fence signals. If the fence is Fence::NO_FENCE, the buffer may be written - // immediately. - // - // The async parameter sets whether we're in asynchronous mode for this - // dequeueBuffer() call. - // - // The width and height parameters must be no greater than the minimum of - // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). - // An error due to invalid dimensions might not be reported until - // updateTexImage() is called. If width and height are both zero, the - // default values specified by setDefaultBufferSize() are used instead. - // - // If the format is 0, the default format will be used. - // - // The usage argument specifies gralloc buffer usage flags. The values - // are enumerated in , e.g. GRALLOC_USAGE_HW_RENDER. These - // will be merged with the usage flags specified by - // IGraphicBufferConsumer::setConsumerUsageBits. - // - // This call will block until a buffer is available to be dequeued. If - // both the producer and consumer are controlled by the app, then this call - // can never block and will return WOULD_BLOCK if no buffer is available. - // - // A non-negative value with flags set (see above) will be returned upon - // success. - // - // Return of a negative means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - both in async mode and buffer count was less than the - // max numbers of buffers that can be allocated at once. - // * INVALID_OPERATION - cannot attach the buffer because it would cause - // too many buffers to be dequeued, either because - // the producer already has a single buffer dequeued - // and did not set a buffer count, or because a - // buffer count was set and this call would cause - // it to be exceeded. - // * WOULD_BLOCK - no buffer is currently available, and blocking is disabled - // since both the producer/consumer are controlled by app - // * NO_MEMORY - out of memory, cannot allocate the graphics buffer. - // - // All other negative values are an unknown error returned downstream - // from the graphics allocator (typically errno). - virtual status_t dequeueBuffer(int* slot, sp* fence, bool async, - uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) = 0; - - // detachBuffer attempts to remove all ownership of the buffer in the given - // slot from the buffer queue. If this call succeeds, the slot will be - // freed, and there will be no way to obtain the buffer from this interface. - // The freed slot will remain unallocated until either it is selected to - // hold a freshly allocated buffer in dequeueBuffer or a buffer is attached - // to the slot. The buffer must have already been dequeued, and the caller - // must already possesses the sp (i.e., must have called - // requestBuffer). - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - the given slot number is invalid, either because it is - // out of the range [0, NUM_BUFFER_SLOTS), or because the slot - // it refers to is not currently dequeued and requested. - virtual status_t detachBuffer(int slot) = 0; - - // detachNextBuffer is equivalent to calling dequeueBuffer, requestBuffer, - // and detachBuffer in sequence, except for two things: - // - // 1) It is unnecessary to know the dimensions, format, or usage of the - // next buffer. - // 2) It will not block, since if it cannot find an appropriate buffer to - // return, it will return an error instead. - // - // Only slots that are free but still contain a GraphicBuffer will be - // considered, and the oldest of those will be returned. outBuffer is - // equivalent to outBuffer from the requestBuffer call, and outFence is - // equivalent to fence from the dequeueBuffer call. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - either outBuffer or outFence were NULL. - // * NO_MEMORY - no slots were found that were both free and contained a - // GraphicBuffer. - virtual status_t detachNextBuffer(sp* outBuffer, - sp* outFence) = 0; - - // attachBuffer attempts to transfer ownership of a buffer to the buffer - // queue. If this call succeeds, it will be as if this buffer was dequeued - // from the returned slot number. As such, this call will fail if attaching - // this buffer would cause too many buffers to be simultaneously dequeued. - // - // If attachBuffer returns the RELEASE_ALL_BUFFERS flag, the caller is - // expected to release all of the mirrored slot->buffer mappings. - // - // A non-negative value with flags set (see above) will be returned upon - // success. - // - // Return of a negative value means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - outSlot or buffer were NULL, invalid combination of - // async mode and buffer count override, or the generation - // number of the buffer did not match the buffer queue. - // * INVALID_OPERATION - cannot attach the buffer because it would cause - // too many buffers to be dequeued, either because - // the producer already has a single buffer dequeued - // and did not set a buffer count, or because a - // buffer count was set and this call would cause - // it to be exceeded. - // * WOULD_BLOCK - no buffer slot is currently available, and blocking is - // disabled since both the producer/consumer are - // controlled by the app. - virtual status_t attachBuffer(int* outSlot, - const sp& buffer) = 0; - - // queueBuffer indicates that the client has finished filling in the - // contents of the buffer associated with slot and transfers ownership of - // that slot back to the server. - // - // It is not valid to call queueBuffer on a slot that is not owned - // by the client or one for which a buffer associated via requestBuffer - // (an attempt to do so will fail with a return value of BAD_VALUE). - // - // In addition, the input must be described by the client (as documented - // below). Any other properties (zero point, etc) - // are client-dependent, and should be documented by the client. - // - // The slot must be in the range of [0, NUM_BUFFER_SLOTS). - // - // Upon success, the output will be filled with meaningful values - // (refer to the documentation below). - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - one of the below conditions occurred: - // * fence was NULL - // * scaling mode was unknown - // * both in async mode and buffer count was less than the - // max numbers of buffers that can be allocated at once - // * slot index was out of range (see above). - // * the slot was not in the dequeued state - // * the slot was enqueued without requesting a buffer - // * crop rect is out of bounds of the buffer dimensions - - struct QueueBufferInput : public Flattenable { - friend class Flattenable; - inline QueueBufferInput(const Parcel& parcel); - // timestamp - a monotonically increasing value in nanoseconds - // isAutoTimestamp - if the timestamp was synthesized at queue time - // dataSpace - description of the contents, interpretation depends on format - // crop - a crop rectangle that's used as a hint to the consumer - // scalingMode - a set of flags from NATIVE_WINDOW_SCALING_* in - // transform - a set of flags from NATIVE_WINDOW_TRANSFORM_* in - // async - if the buffer is queued in asynchronous mode - // fence - a fence that the consumer must wait on before reading the buffer, - // set this to Fence::NO_FENCE if the buffer is ready immediately - // sticky - the sticky transform set in Surface (only used by the LEGACY - // camera mode). - inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp, - android_dataspace dataSpace, const Rect& crop, int scalingMode, - uint32_t transform, bool async, const sp& fence, - uint32_t sticky = 0) - : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp), - dataSpace(dataSpace), crop(crop), scalingMode(scalingMode), - transform(transform), stickyTransform(sticky), - async(async), fence(fence), surfaceDamage() { } - inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp, - android_dataspace* outDataSpace, - Rect* outCrop, int* outScalingMode, - uint32_t* outTransform, bool* outAsync, sp* outFence, - uint32_t* outStickyTransform = NULL) const { - *outTimestamp = timestamp; - *outIsAutoTimestamp = bool(isAutoTimestamp); - *outDataSpace = dataSpace; - *outCrop = crop; - *outScalingMode = scalingMode; - *outTransform = transform; - *outAsync = bool(async); - *outFence = fence; - if (outStickyTransform != NULL) { - *outStickyTransform = stickyTransform; - } - } - - // Flattenable protocol - size_t getFlattenedSize() const; - size_t getFdCount() const; - status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; - status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); - - const Region& getSurfaceDamage() const { return surfaceDamage; } - void setSurfaceDamage(const Region& damage) { surfaceDamage = damage; } - - private: - int64_t timestamp; - int isAutoTimestamp; - android_dataspace dataSpace; - Rect crop; - int scalingMode; - uint32_t transform; - uint32_t stickyTransform; - int async; - sp fence; - Region surfaceDamage; - }; - - // QueueBufferOutput must be a POD structure - struct __attribute__ ((__packed__)) QueueBufferOutput { - inline QueueBufferOutput() { } - // outWidth - filled with default width applied to the buffer - // outHeight - filled with default height applied to the buffer - // outTransformHint - filled with default transform applied to the buffer - // outNumPendingBuffers - num buffers queued that haven't yet been acquired - // (counting the currently queued buffer) - inline void deflate(uint32_t* outWidth, - uint32_t* outHeight, - uint32_t* outTransformHint, - uint32_t* outNumPendingBuffers) const { - *outWidth = width; - *outHeight = height; - *outTransformHint = transformHint; - *outNumPendingBuffers = numPendingBuffers; - } - inline void inflate(uint32_t inWidth, uint32_t inHeight, - uint32_t inTransformHint, uint32_t inNumPendingBuffers) { - width = inWidth; - height = inHeight; - transformHint = inTransformHint; - numPendingBuffers = inNumPendingBuffers; - } - private: - uint32_t width; - uint32_t height; - uint32_t transformHint; - uint32_t numPendingBuffers; - }; - - virtual status_t queueBuffer(int slot, - const QueueBufferInput& input, QueueBufferOutput* output) = 0; - - // cancelBuffer indicates that the client does not wish to fill in the - // buffer associated with slot and transfers ownership of the slot back to - // the server. - // - // The buffer is not queued for use by the consumer. - // - // The buffer will not be overwritten until the fence signals. The fence - // will usually be the one obtained from dequeueBuffer. - virtual void cancelBuffer(int slot, const sp& fence) = 0; - - // query retrieves some information for this surface - // 'what' tokens allowed are that of NATIVE_WINDOW_* in - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - the buffer queue has been abandoned. - // * BAD_VALUE - what was out of range - virtual int query(int what, int* value) = 0; - - // connect attempts to connect a client API to the IGraphicBufferProducer. - // This must be called before any other IGraphicBufferProducer methods are - // called except for getAllocator. A consumer must be already connected. - // - // This method will fail if the connect was previously called on the - // IGraphicBufferProducer and no corresponding disconnect call was made. - // - // The listener is an optional binder callback object that can be used if - // the producer wants to be notified when the consumer releases a buffer - // back to the BufferQueue. It is also used to detect the death of the - // producer. If only the latter functionality is desired, there is a - // DummyProducerListener class in IProducerListener.h that can be used. - // - // The api should be one of the NATIVE_WINDOW_API_* values in - // - // The producerControlledByApp should be set to true if the producer is hosted - // by an untrusted process (typically app_process-forked processes). If both - // the producer and the consumer are app-controlled then all buffer queues - // will operate in async mode regardless of the async flag. - // - // Upon success, the output will be filled with meaningful data - // (refer to QueueBufferOutput documentation above). - // - // Return of a value other than NO_ERROR means an error has occurred: - // * NO_INIT - one of the following occurred: - // * the buffer queue was abandoned - // * no consumer has yet connected - // * BAD_VALUE - one of the following has occurred: - // * the producer is already connected - // * api was out of range (see above). - // * output was NULL. - // * DEAD_OBJECT - the token is hosted by an already-dead process - // - // Additional negative errors may be returned by the internals, they - // should be treated as opaque fatal unrecoverable errors. - virtual status_t connect(const sp& listener, - int api, bool producerControlledByApp, QueueBufferOutput* output) = 0; - - // disconnect attempts to disconnect a client API from the - // IGraphicBufferProducer. Calling this method will cause any subsequent - // calls to other IGraphicBufferProducer methods to fail except for - // getAllocator and connect. Successfully calling connect after this will - // allow the other methods to succeed again. - // - // This method will fail if the the IGraphicBufferProducer is not currently - // connected to the specified client API. - // - // The api should be one of the NATIVE_WINDOW_API_* values in - // - // Disconnecting from an abandoned IGraphicBufferProducer is legal and - // is considered a no-op. - // - // Return of a value other than NO_ERROR means an error has occurred: - // * BAD_VALUE - one of the following has occurred: - // * the api specified does not match the one that was connected - // * api was out of range (see above). - // * DEAD_OBJECT - the token is hosted by an already-dead process - virtual status_t disconnect(int api) = 0; - - // Attaches a sideband buffer stream to the IGraphicBufferProducer. - // - // A sideband stream is a device-specific mechanism for passing buffers - // from the producer to the consumer without using dequeueBuffer/ - // queueBuffer. If a sideband stream is present, the consumer can choose - // whether to acquire buffers from the sideband stream or from the queued - // buffers. - // - // Passing NULL or a different stream handle will detach the previous - // handle if any. - virtual status_t setSidebandStream(const sp& stream) = 0; - - // Allocates buffers based on the given dimensions/format. - // - // This function will allocate up to the maximum number of buffers - // permitted by the current BufferQueue configuration. It will use the - // given format, dimensions, and usage bits, which are interpreted in the - // same way as for dequeueBuffer, and the async flag must be set the same - // way as for dequeueBuffer to ensure that the correct number of buffers are - // allocated. This is most useful to avoid an allocation delay during - // dequeueBuffer. If there are already the maximum number of buffers - // allocated, this function has no effect. - virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, - PixelFormat format, uint32_t usage) = 0; - - // Sets whether dequeueBuffer is allowed to allocate new buffers. - // - // Normally dequeueBuffer does not discriminate between free slots which - // already have an allocated buffer and those which do not, and will - // allocate a new buffer if the slot doesn't have a buffer or if the slot's - // buffer doesn't match the requested size, format, or usage. This method - // allows the producer to restrict the eligible slots to those which already - // have an allocated buffer of the correct size, format, and usage. If no - // eligible slot is available, dequeueBuffer will block or return an error - // as usual. - virtual status_t allowAllocation(bool allow) = 0; - - // Sets the current generation number of the BufferQueue. - // - // This generation number will be inserted into any buffers allocated by the - // BufferQueue, and any attempts to attach a buffer with a different - // generation number will fail. Buffers already in the queue are not - // affected and will retain their current generation number. The generation - // number defaults to 0. - virtual status_t setGenerationNumber(uint32_t generationNumber) = 0; - - // Returns the name of the connected consumer. - virtual String8 getConsumerName() const = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnGraphicBufferProducer : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_IGRAPHICBUFFERPRODUCER_H diff --git a/third_party/android_frameworks_native/include/gui/IProducerListener.h b/third_party/android_frameworks_native/include/gui/IProducerListener.h deleted file mode 100644 index 3848a6c850..0000000000 --- a/third_party/android_frameworks_native/include/gui/IProducerListener.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2014 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_IPRODUCERLISTENER_H -#define ANDROID_GUI_IPRODUCERLISTENER_H - -#include - -#include - -namespace android { - -// ProducerListener is the interface through which the BufferQueue notifies the -// producer of events that the producer may wish to react to. Because the -// producer will generally have a mutex that is locked during calls from the -// producer to the BufferQueue, these calls from the BufferQueue to the -// producer *MUST* be called only when the BufferQueue mutex is NOT locked. - -class ProducerListener : public virtual RefBase -{ -public: - ProducerListener() {} - virtual ~ProducerListener() {} - - // onBufferReleased is called from IGraphicBufferConsumer::releaseBuffer to - // notify the producer that a new buffer is free and ready to be dequeued. - // - // This is called without any lock held and can be called concurrently by - // multiple threads. - virtual void onBufferReleased() = 0; // Asynchronous -}; - -class IProducerListener : public ProducerListener, public IInterface -{ -public: - DECLARE_META_INTERFACE(ProducerListener) -}; - -class BnProducerListener : public BnInterface -{ -public: - virtual status_t onTransact(uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags = 0); -}; - -class DummyProducerListener : public BnProducerListener -{ -public: - virtual void onBufferReleased() {} -}; - -} // namespace android - -#endif diff --git a/third_party/android_frameworks_native/include/gui/ISensorEventConnection.h b/third_party/android_frameworks_native/include/gui/ISensorEventConnection.h deleted file mode 100644 index f64c6b8604..0000000000 --- a/third_party/android_frameworks_native/include/gui/ISensorEventConnection.h +++ /dev/null @@ -1,59 +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_ISENSOR_EVENT_CONNECTION_H -#define ANDROID_GUI_ISENSOR_EVENT_CONNECTION_H - -#include -#include - -#include -#include - -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class BitTube; - -class ISensorEventConnection : public IInterface -{ -public: - DECLARE_META_INTERFACE(SensorEventConnection); - - virtual sp getSensorChannel() const = 0; - virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs, - nsecs_t maxBatchReportLatencyNs, int reservedFlags) = 0; - virtual status_t setEventRate(int handle, nsecs_t ns) = 0; - virtual status_t flush() = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnSensorEventConnection : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_ISENSOR_EVENT_CONNECTION_H diff --git a/third_party/android_frameworks_native/include/gui/ISensorServer.h b/third_party/android_frameworks_native/include/gui/ISensorServer.h deleted file mode 100644 index 3dca2a3739..0000000000 --- a/third_party/android_frameworks_native/include/gui/ISensorServer.h +++ /dev/null @@ -1,60 +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_ISENSORSERVER_H -#define ANDROID_GUI_ISENSORSERVER_H - -#include -#include - -#include -#include - -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class Sensor; -class ISensorEventConnection; -class String8; - -class ISensorServer : public IInterface -{ -public: - DECLARE_META_INTERFACE(SensorServer); - - virtual Vector getSensorList(const String16& opPackageName) = 0; - virtual sp createSensorEventConnection(const String8& packageName, - int mode, const String16& opPackageName) = 0; - virtual int32_t isDataInjectionEnabled() = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnSensorServer : public BnInterface -{ -public: - virtual status_t onTransact( uint32_t code, - const Parcel& data, - Parcel* reply, - uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_ISENSORSERVER_H diff --git a/third_party/android_frameworks_native/include/gui/ISurfaceComposer.h b/third_party/android_frameworks_native/include/gui/ISurfaceComposer.h deleted file mode 100644 index 6e3fc5a6de..0000000000 --- a/third_party/android_frameworks_native/include/gui/ISurfaceComposer.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2006 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_ISURFACE_COMPOSER_H -#define ANDROID_GUI_ISURFACE_COMPOSER_H - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class ComposerState; -class DisplayState; -struct DisplayInfo; -struct DisplayStatInfo; -class IDisplayEventConnection; -class IMemoryHeap; -class Rect; - -/* - * This class defines the Binder IPC interface for accessing various - * SurfaceFlinger features. - */ -class ISurfaceComposer: public IInterface { -public: - DECLARE_META_INTERFACE(SurfaceComposer); - - // flags for setTransactionState() - enum { - eSynchronous = 0x01, - eAnimation = 0x02, - }; - - enum { - eDisplayIdMain = 0, - eDisplayIdHdmi = 1, -#ifdef QTI_BSP - eDisplayIdTertiary = 2 -#endif - }; - - enum Rotation { - eRotateNone = 0, - eRotate90 = 1, - eRotate180 = 2, - eRotate270 = 3 - }; - - /* create connection with surface flinger, requires - * ACCESS_SURFACE_FLINGER permission - */ - virtual sp createConnection() = 0; - - /* create a graphic buffer allocator - */ - virtual sp createGraphicBufferAlloc() = 0; - - /* return an IDisplayEventConnection */ - virtual sp createDisplayEventConnection() = 0; - - /* create a virtual display - * requires ACCESS_SURFACE_FLINGER permission. - */ - virtual sp createDisplay(const String8& displayName, - bool secure) = 0; - - /* destroy a virtual display - * requires ACCESS_SURFACE_FLINGER permission. - */ - virtual void destroyDisplay(const sp& display) = 0; - - /* get the token for the existing default displays. possible values - * for id are eDisplayIdMain and eDisplayIdHdmi. - */ - virtual sp getBuiltInDisplay(int32_t id) = 0; - - /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */ - virtual void setTransactionState(const Vector& state, - const Vector& displays, uint32_t flags) = 0; - - /* signal that we're done booting. - * Requires ACCESS_SURFACE_FLINGER permission - */ - virtual void bootFinished() = 0; - - /* verify that an IGraphicBufferProducer was created by SurfaceFlinger. - */ - virtual bool authenticateSurfaceTexture( - const sp& surface) const = 0; - - /* set display power mode. depending on the mode, it can either trigger - * screen on, off or low power mode and wait for it to complete. - * requires ACCESS_SURFACE_FLINGER permission. - */ - virtual void setPowerMode(const sp& display, int mode) = 0; - - /* returns information for each configuration of the given display - * intended to be used to get information about built-in displays */ - virtual status_t getDisplayConfigs(const sp& display, - Vector* configs) = 0; - - /* returns display statistics for a given display - * intended to be used by the media framework to properly schedule - * video frames */ - virtual status_t getDisplayStats(const sp& display, - DisplayStatInfo* stats) = 0; - - /* indicates which of the configurations returned by getDisplayInfo is - * currently active */ - virtual int getActiveConfig(const sp& display) = 0; - - /* specifies which configuration (of those returned by getDisplayInfo) - * should be used */ - virtual status_t setActiveConfig(const sp& display, int id) = 0; - - /* Capture the specified screen. requires READ_FRAME_BUFFER permission - * This function will fail if there is a secure window on screen. - */ - virtual status_t captureScreen(const sp& display, - const sp& producer, - Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, - uint32_t minLayerZ, uint32_t maxLayerZ, - bool useIdentityTransform, - Rotation rotation = eRotateNone, - bool isCpuConsumer = false) = 0; - - /* Clears the frame statistics for animations. - * - * Requires the ACCESS_SURFACE_FLINGER permission. - */ - virtual status_t clearAnimationFrameStats() = 0; - - /* Gets the frame statistics for animations. - * - * Requires the ACCESS_SURFACE_FLINGER permission. - */ - virtual status_t getAnimationFrameStats(FrameStats* outStats) const = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnSurfaceComposer: public BnInterface { -public: - enum { - // Note: BOOT_FINISHED must remain this value, it is called from - // Java by ActivityManagerService. - BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION, - CREATE_CONNECTION, - CREATE_GRAPHIC_BUFFER_ALLOC, - CREATE_DISPLAY_EVENT_CONNECTION, - CREATE_DISPLAY, - DESTROY_DISPLAY, - GET_BUILT_IN_DISPLAY, - SET_TRANSACTION_STATE, - AUTHENTICATE_SURFACE, - GET_DISPLAY_CONFIGS, - GET_ACTIVE_CONFIG, - SET_ACTIVE_CONFIG, - CONNECT_DISPLAY, - CAPTURE_SCREEN, - CLEAR_ANIMATION_FRAME_STATS, - GET_ANIMATION_FRAME_STATS, - SET_POWER_MODE, - GET_DISPLAY_STATS, - }; - - virtual status_t onTransact(uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_GUI_ISURFACE_COMPOSER_H diff --git a/third_party/android_frameworks_native/include/gui/ISurfaceComposerClient.h b/third_party/android_frameworks_native/include/gui/ISurfaceComposerClient.h deleted file mode 100644 index d3e8b8ba13..0000000000 --- a/third_party/android_frameworks_native/include/gui/ISurfaceComposerClient.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2007 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_ISURFACE_COMPOSER_CLIENT_H -#define ANDROID_GUI_ISURFACE_COMPOSER_CLIENT_H - -#include -#include - -#include -#include - -#include - -#include -#include - -namespace android { -// ---------------------------------------------------------------------------- - -class IGraphicBufferProducer; - -class ISurfaceComposerClient : public IInterface -{ -public: - DECLARE_META_INTERFACE(SurfaceComposerClient); - - // flags for createSurface() - enum { // (keep in sync with Surface.java) - eHidden = 0x00000004, - eDestroyBackbuffer = 0x00000020, - eSecure = 0x00000080, - eNonPremultiplied = 0x00000100, - eOpaque = 0x00000400, - eProtectedByApp = 0x00000800, - eProtectedByDRM = 0x00001000, - eCursorWindow = 0x00002000, - - eFXSurfaceNormal = 0x00000000, - eFXSurfaceBlur = 0x00010000, - eFXSurfaceDim = 0x00020000, - eFXSurfaceMask = 0x000F0000, - }; - - /* - * Requires ACCESS_SURFACE_FLINGER permission - */ - virtual status_t createSurface( - const String8& name, uint32_t w, uint32_t h, - PixelFormat format, uint32_t flags, - sp* handle, - sp* gbp) = 0; - - /* - * Requires ACCESS_SURFACE_FLINGER permission - */ - virtual status_t destroySurface(const sp& handle) = 0; - - /* - * Requires ACCESS_SURFACE_FLINGER permission - */ - virtual status_t clearLayerFrameStats(const sp& handle) const = 0; - - /* - * Requires ACCESS_SURFACE_FLINGER permission - */ - virtual status_t getLayerFrameStats(const sp& handle, FrameStats* outStats) const = 0; -}; - -// ---------------------------------------------------------------------------- - -class BnSurfaceComposerClient: public BnInterface { -public: - virtual status_t onTransact(uint32_t code, const Parcel& data, - Parcel* reply, uint32_t flags = 0); -}; - -// ---------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_GUI_ISURFACE_COMPOSER_CLIENT_H diff --git a/third_party/android_frameworks_native/include/gui/Sensor.h b/third_party/android_frameworks_native/include/gui/Sensor.h deleted file mode 100644 index 8142be6352..0000000000 --- a/third_party/android_frameworks_native/include/gui/Sensor.h +++ /dev/null @@ -1,113 +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_SENSOR_H -#define ANDROID_GUI_SENSOR_H - -#include -#include - -#include -#include -#include -#include - -#include - -#include - -// ---------------------------------------------------------------------------- -// Concrete types for the NDK -struct ASensor { }; - -// ---------------------------------------------------------------------------- -namespace android { -// ---------------------------------------------------------------------------- - -class Parcel; - -// ---------------------------------------------------------------------------- - -class Sensor : public ASensor, public LightFlattenable -{ -public: - enum { - TYPE_ACCELEROMETER = ASENSOR_TYPE_ACCELEROMETER, - TYPE_MAGNETIC_FIELD = ASENSOR_TYPE_MAGNETIC_FIELD, - TYPE_GYROSCOPE = ASENSOR_TYPE_GYROSCOPE, - TYPE_LIGHT = ASENSOR_TYPE_LIGHT, - TYPE_PROXIMITY = ASENSOR_TYPE_PROXIMITY - }; - - Sensor(); - Sensor(struct sensor_t const* hwSensor, int halVersion = 0); - ~Sensor(); - - const String8& getName() const; - const String8& getVendor() const; - int32_t getHandle() const; - int32_t getType() const; - float getMinValue() const; - float getMaxValue() const; - float getResolution() const; - float getPowerUsage() const; - int32_t getMinDelay() const; - nsecs_t getMinDelayNs() const; - int32_t getVersion() const; - uint32_t getFifoReservedEventCount() const; - uint32_t getFifoMaxEventCount() const; - const String8& getStringType() const; - const String8& getRequiredPermission() const; - bool isRequiredPermissionRuntime() const; - int32_t getRequiredAppOp() const; - int32_t getMaxDelay() const; - uint32_t getFlags() const; - bool isWakeUpSensor() const; - int32_t getReportingMode() const; - - // LightFlattenable protocol - inline bool isFixedSize() const { return false; } - size_t getFlattenedSize() const; - status_t flatten(void* buffer, size_t size) const; - status_t unflatten(void const* buffer, size_t size); - -private: - String8 mName; - String8 mVendor; - int32_t mHandle; - int32_t mType; - float mMinValue; - float mMaxValue; - float mResolution; - float mPower; - int32_t mMinDelay; - int32_t mVersion; - uint32_t mFifoReservedEventCount; - uint32_t mFifoMaxEventCount; - String8 mStringType; - String8 mRequiredPermission; - bool mRequiredPermissionRuntime = false; - int32_t mRequiredAppOp; - int32_t mMaxDelay; - uint32_t mFlags; - static void flattenString8(void*& buffer, size_t& size, const String8& string8); - static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8); -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_SENSOR_H diff --git a/third_party/android_frameworks_native/include/gui/SensorEventQueue.h b/third_party/android_frameworks_native/include/gui/SensorEventQueue.h deleted file mode 100644 index e5b9fc5984..0000000000 --- a/third_party/android_frameworks_native/include/gui/SensorEventQueue.h +++ /dev/null @@ -1,98 +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_SENSOR_EVENT_QUEUE_H -#define ANDROID_SENSOR_EVENT_QUEUE_H - -#include -#include - -#include -#include -#include -#include - -#include - -// ---------------------------------------------------------------------------- -#define WAKE_UP_SENSOR_EVENT_NEEDS_ACK (1U << 31) -struct ALooper; -struct ASensorEvent; - -// Concrete types for the NDK -struct ASensorEventQueue { - ALooper* looper; -}; - -// ---------------------------------------------------------------------------- -namespace android { -// ---------------------------------------------------------------------------- - -class ISensorEventConnection; -class Sensor; -class Looper; - -// ---------------------------------------------------------------------------- - -class SensorEventQueue : public ASensorEventQueue, public RefBase -{ -public: - - enum { MAX_RECEIVE_BUFFER_EVENT_COUNT = 256 }; - - SensorEventQueue(const sp& connection); - virtual ~SensorEventQueue(); - virtual void onFirstRef(); - - int getFd() const; - - static ssize_t write(const sp& tube, - ASensorEvent const* events, size_t numEvents); - - ssize_t read(ASensorEvent* events, size_t numEvents); - - status_t waitForEvent() const; - status_t wake() const; - - status_t enableSensor(Sensor const* sensor) const; - status_t disableSensor(Sensor const* sensor) const; - status_t setEventRate(Sensor const* sensor, nsecs_t ns) const; - - // these are here only to support SensorManager.java - status_t enableSensor(int32_t handle, int32_t samplingPeriodUs, int maxBatchReportLatencyUs, - int reservedFlags) const; - status_t disableSensor(int32_t handle) const; - status_t flush() const; - // Send an ack for every wake_up sensor event that is set to WAKE_UP_SENSOR_EVENT_NEEDS_ACK. - void sendAck(const ASensorEvent* events, int count); - - status_t injectSensorEvent(const ASensorEvent& event); -private: - sp getLooper() const; - sp mSensorEventConnection; - sp mSensorChannel; - mutable Mutex mLock; - mutable sp mLooper; - ASensorEvent* mRecBuffer; - size_t mAvailable; - size_t mConsumed; - uint32_t mNumAcksToSend; -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_SENSOR_EVENT_QUEUE_H diff --git a/third_party/android_frameworks_native/include/gui/SensorManager.h b/third_party/android_frameworks_native/include/gui/SensorManager.h deleted file mode 100644 index 0cff46c076..0000000000 --- a/third_party/android_frameworks_native/include/gui/SensorManager.h +++ /dev/null @@ -1,84 +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_SENSOR_MANAGER_H -#define ANDROID_GUI_SENSOR_MANAGER_H - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -// ---------------------------------------------------------------------------- -// Concrete types for the NDK -struct ASensorManager { }; - -// ---------------------------------------------------------------------------- -namespace android { -// ---------------------------------------------------------------------------- - -class ISensorServer; -class Sensor; -class SensorEventQueue; -// ---------------------------------------------------------------------------- - -class SensorManager : - public ASensorManager -{ -public: - static SensorManager& getInstanceForPackage(const String16& packageName); - ~SensorManager(); - - ssize_t getSensorList(Sensor const* const** list) const; - Sensor const* getDefaultSensor(int type); - sp createEventQueue(String8 packageName = String8(""), int mode = 0); - bool isDataInjectionEnabled(); - -private: - // DeathRecipient interface - void sensorManagerDied(); - - SensorManager(const String16& opPackageName); - status_t assertStateLocked() const; - -private: - static Mutex sLock; - static std::map sPackageInstances; - - mutable Mutex mLock; - mutable sp mSensorServer; - mutable Sensor const** mSensorList; - mutable Vector mSensors; - mutable sp mDeathObserver; - const String16 mOpPackageName; -}; - -// ---------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_SENSOR_MANAGER_H diff --git a/third_party/android_frameworks_native/include/gui/StreamSplitter.h b/third_party/android_frameworks_native/include/gui/StreamSplitter.h deleted file mode 100644 index 8f47eb47ac..0000000000 --- a/third_party/android_frameworks_native/include/gui/StreamSplitter.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2014 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_STREAMSPLITTER_H -#define ANDROID_GUI_STREAMSPLITTER_H - -#include -#include - -#include -#include -#include -#include - -namespace android { - -class GraphicBuffer; -class IGraphicBufferConsumer; -class IGraphicBufferProducer; - -// StreamSplitter is an autonomous class that manages one input BufferQueue -// and multiple output BufferQueues. By using the buffer attach and detach logic -// in BufferQueue, it is able to present the illusion of a single split -// BufferQueue, where each buffer queued to the input is available to be -// acquired by each of the outputs, and is able to be dequeued by the input -// again only once all of the outputs have released it. -class StreamSplitter : public BnConsumerListener { -public: - // createSplitter creates a new splitter, outSplitter, using inputQueue as - // the input BufferQueue. Output BufferQueues must be added using addOutput - // before queueing any buffers to the input. - // - // A return value other than NO_ERROR means that an error has occurred and - // outSplitter has not been modified. BAD_VALUE is returned if inputQueue or - // outSplitter is NULL. See IGraphicBufferConsumer::consumerConnect for - // explanations of other error codes. - static status_t createSplitter(const sp& inputQueue, - sp* outSplitter); - - // addOutput adds an output BufferQueue to the splitter. The splitter - // connects to outputQueue as a CPU producer, and any buffers queued - // to the input will be queued to each output. It is assumed that all of the - // outputs are added before any buffers are queued on the input. If any - // output is abandoned by its consumer, the splitter will abandon its input - // queue (see onAbandoned). - // - // A return value other than NO_ERROR means that an error has occurred and - // outputQueue has not been added to the splitter. BAD_VALUE is returned if - // outputQueue is NULL. See IGraphicBufferProducer::connect for explanations - // of other error codes. - status_t addOutput(const sp& outputQueue); - - // setName sets the consumer name of the input queue - void setName(const String8& name); - -private: - // From IConsumerListener - // - // During this callback, we store some tracking information, detach the - // buffer from the input, and attach it to each of the outputs. This call - // can block if there are too many outstanding buffers. If it blocks, it - // will resume when onBufferReleasedByOutput releases a buffer back to the - // input. - virtual void onFrameAvailable(const BufferItem& item); - - // From IConsumerListener - // We don't care about released buffers because we detach each buffer as - // soon as we acquire it. See the comment for onBufferReleased below for - // some clarifying notes about the name. - virtual void onBuffersReleased() {} - - // From IConsumerListener - // We don't care about sideband streams, since we won't be splitting them - virtual void onSidebandStreamChanged() {} - - // This is the implementation of the onBufferReleased callback from - // IProducerListener. It gets called from an OutputListener (see below), and - // 'from' is which producer interface from which the callback was received. - // - // During this callback, we detach the buffer from the output queue that - // generated the callback, update our state tracking to see if this is the - // last output releasing the buffer, and if so, release it to the input. - // If we release the buffer to the input, we allow a blocked - // onFrameAvailable call to proceed. - void onBufferReleasedByOutput(const sp& from); - - // When this is called, the splitter disconnects from (i.e., abandons) its - // input queue and signals any waiting onFrameAvailable calls to wake up. - // It still processes callbacks from other outputs, but only detaches their - // buffers so they can continue operating until they run out of buffers to - // acquire. This must be called with mMutex locked. - void onAbandonedLocked(); - - // This is a thin wrapper class that lets us determine which BufferQueue - // the IProducerListener::onBufferReleased callback is associated with. We - // create one of these per output BufferQueue, and then pass the producer - // into onBufferReleasedByOutput above. - class OutputListener : public BnProducerListener, - public IBinder::DeathRecipient { - public: - OutputListener(const sp& splitter, - const sp& output); - virtual ~OutputListener(); - - // From IProducerListener - virtual void onBufferReleased(); - - // From IBinder::DeathRecipient - virtual void binderDied(const wp& who); - - private: - sp mSplitter; - sp mOutput; - }; - - class BufferTracker : public LightRefBase { - public: - BufferTracker(const sp& buffer); - - const sp& getBuffer() const { return mBuffer; } - const sp& getMergedFence() const { return mMergedFence; } - - void mergeFence(const sp& with); - - // Returns the new value - // Only called while mMutex is held - size_t incrementReleaseCountLocked() { return ++mReleaseCount; } - - private: - // Only destroy through LightRefBase - friend LightRefBase; - ~BufferTracker(); - - // Disallow copying - BufferTracker(const BufferTracker& other); - BufferTracker& operator=(const BufferTracker& other); - - sp mBuffer; // One instance that holds this native handle - sp mMergedFence; - size_t mReleaseCount; - }; - - // Only called from createSplitter - StreamSplitter(const sp& inputQueue); - - // Must be accessed through RefBase - virtual ~StreamSplitter(); - - static const int MAX_OUTSTANDING_BUFFERS = 2; - - // mIsAbandoned is set to true when an output dies. Once the StreamSplitter - // has been abandoned, it will continue to detach buffers from other - // outputs, but it will disconnect from the input and not attempt to - // communicate with it further. - bool mIsAbandoned; - - Mutex mMutex; - Condition mReleaseCondition; - int mOutstandingBuffers; - sp mInput; - Vector > mOutputs; - - // Map of GraphicBuffer IDs (GraphicBuffer::getId()) to buffer tracking - // objects (which are mostly for counting how many outputs have released the - // buffer, but also contain merged release fences). - KeyedVector > mBuffers; -}; - -} // namespace android - -#endif diff --git a/third_party/android_frameworks_native/include/gui/Surface.h b/third_party/android_frameworks_native/include/gui/Surface.h deleted file mode 100644 index 72f1067076..0000000000 --- a/third_party/android_frameworks_native/include/gui/Surface.h +++ /dev/null @@ -1,324 +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_SURFACE_H -#define ANDROID_GUI_SURFACE_H - -#include -#include - -#include -#include - -#include -#include -#include - -struct ANativeWindow_Buffer; - -namespace android { - -/* - * An implementation of ANativeWindow that feeds graphics buffers into a - * BufferQueue. - * - * This is typically used by programs that want to render frames through - * some means (maybe OpenGL, a software renderer, or a hardware decoder) - * and have the frames they create forwarded to SurfaceFlinger for - * compositing. For example, a video decoder could render a frame and call - * eglSwapBuffers(), which invokes ANativeWindow callbacks defined by - * Surface. Surface then forwards the buffers through Binder IPC - * to the BufferQueue's producer interface, providing the new frame to a - * consumer such as GLConsumer. - */ -class Surface - : public ANativeObjectBase -{ -public: - - /* - * creates a Surface from the given IGraphicBufferProducer (which concrete - * implementation is a BufferQueue). - * - * Surface is mainly state-less while it's disconnected, it can be - * viewed as a glorified IGraphicBufferProducer holder. It's therefore - * safe to create other Surfaces from the same IGraphicBufferProducer. - * - * However, once a Surface is connected, it'll prevent other Surfaces - * referring to the same IGraphicBufferProducer to become connected and - * therefore prevent them to be used as actual producers of buffers. - * - * the controlledByApp flag indicates that this Surface (producer) is - * controlled by the application. This flag is used at connect time. - */ - Surface(const sp& bufferProducer, bool controlledByApp = false); - - /* getIGraphicBufferProducer() returns the IGraphicBufferProducer this - * Surface was created with. Usually it's an error to use the - * IGraphicBufferProducer while the Surface is connected. - */ - sp getIGraphicBufferProducer() const; - - /* convenience function to check that the given surface is non NULL as - * well as its IGraphicBufferProducer */ - static bool isValid(const sp& surface) { - return surface != NULL && surface->getIGraphicBufferProducer() != NULL; - } - - /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer. - * - * A sideband stream is a device-specific mechanism for passing buffers - * from the producer to the consumer without using dequeueBuffer/ - * queueBuffer. If a sideband stream is present, the consumer can choose - * whether to acquire buffers from the sideband stream or from the queued - * buffers. - * - * Passing NULL or a different stream handle will detach the previous - * handle if any. - */ - void setSidebandStream(const sp& stream); - - /* Allocates buffers based on the current dimensions/format. - * - * This function will allocate up to the maximum number of buffers - * permitted by the current BufferQueue configuration. It will use the - * default format and dimensions. This is most useful to avoid an allocation - * delay during dequeueBuffer. If there are already the maximum number of - * buffers allocated, this function has no effect. - */ - void allocateBuffers(); - - /* Sets the generation number on the IGraphicBufferProducer and updates the - * generation number on any buffers attached to the Surface after this call. - * See IGBP::setGenerationNumber for more information. */ - status_t setGenerationNumber(uint32_t generationNumber); - - // See IGraphicBufferProducer::getConsumerName - String8 getConsumerName() const; - -protected: - virtual ~Surface(); - -private: - // can't be copied - Surface& operator = (const Surface& rhs); - Surface(const Surface& rhs); - - // ANativeWindow hooks - static int hook_cancelBuffer(ANativeWindow* window, - ANativeWindowBuffer* buffer, int fenceFd); - static int hook_dequeueBuffer(ANativeWindow* window, - ANativeWindowBuffer** buffer, int* fenceFd); - static int hook_perform(ANativeWindow* window, int operation, ...); - static int hook_query(const ANativeWindow* window, int what, int* value); - static int hook_queueBuffer(ANativeWindow* window, - ANativeWindowBuffer* buffer, int fenceFd); - static int hook_setSwapInterval(ANativeWindow* window, int interval); - - static int hook_cancelBuffer_DEPRECATED(ANativeWindow* window, - ANativeWindowBuffer* buffer); - static int hook_dequeueBuffer_DEPRECATED(ANativeWindow* window, - ANativeWindowBuffer** buffer); - static int hook_lockBuffer_DEPRECATED(ANativeWindow* window, - ANativeWindowBuffer* buffer); - static int hook_queueBuffer_DEPRECATED(ANativeWindow* window, - ANativeWindowBuffer* buffer); - - int dispatchConnect(va_list args); - int dispatchDisconnect(va_list args); - int dispatchSetBufferCount(va_list args); - int dispatchSetBuffersGeometry(va_list args); - int dispatchSetBuffersDimensions(va_list args); - int dispatchSetBuffersUserDimensions(va_list args); - int dispatchSetBuffersFormat(va_list args); - int dispatchSetScalingMode(va_list args); - int dispatchSetBuffersTransform(va_list args); - int dispatchSetBuffersStickyTransform(va_list args); - int dispatchSetBuffersTimestamp(va_list args); - int dispatchSetCrop(va_list args); - int dispatchSetPostTransformCrop(va_list args); - int dispatchSetUsage(va_list args); - int dispatchLock(va_list args); - int dispatchUnlockAndPost(va_list args); - int dispatchSetSidebandStream(va_list args); - int dispatchSetBuffersDataSpace(va_list args); - int dispatchSetSurfaceDamage(va_list args); - -protected: - virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd); - virtual int cancelBuffer(ANativeWindowBuffer* buffer, int fenceFd); - virtual int queueBuffer(ANativeWindowBuffer* buffer, int fenceFd); - virtual int perform(int operation, va_list args); - virtual int query(int what, int* value) const; - virtual int setSwapInterval(int interval); - - virtual int lockBuffer_DEPRECATED(ANativeWindowBuffer* buffer); - - virtual int connect(int api); - virtual int disconnect(int api); - virtual int setBufferCount(int bufferCount); - virtual int setBuffersDimensions(uint32_t width, uint32_t height); - virtual int setBuffersUserDimensions(uint32_t width, uint32_t height); - virtual int setBuffersFormat(PixelFormat format); - virtual int setScalingMode(int mode); - virtual int setBuffersTransform(uint32_t transform); - virtual int setBuffersStickyTransform(uint32_t transform); - virtual int setBuffersTimestamp(int64_t timestamp); - virtual int setBuffersDataSpace(android_dataspace dataSpace); - virtual int setCrop(Rect const* rect); - virtual int setUsage(uint32_t reqUsage); - virtual void setSurfaceDamage(android_native_rect_t* rects, size_t numRects); - -public: - virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds); - virtual int unlockAndPost(); - - virtual int connect(int api, const sp& listener); - virtual int detachNextBuffer(sp* outBuffer, - sp* outFence); - virtual int attachBuffer(ANativeWindowBuffer*); - -protected: - enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS }; - enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 }; - -private: - void freeAllBuffers(); - int getSlotFromBufferLocked(android_native_buffer_t* buffer) const; - - struct BufferSlot { - sp buffer; - Region dirtyRegion; - }; - - // mSurfaceTexture is the interface to the surface texture server. All - // operations on the surface texture client ultimately translate into - // interactions with the server using this interface. - // TODO: rename to mBufferProducer - sp mGraphicBufferProducer; - - // mSlots stores the buffers that have been allocated for each buffer slot. - // It is initialized to null pointers, and gets filled in with the result of - // IGraphicBufferProducer::requestBuffer 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. - BufferSlot mSlots[NUM_BUFFER_SLOTS]; - - // mReqWidth is the buffer width that will be requested at the next dequeue - // operation. It is initialized to 1. - uint32_t mReqWidth; - - // mReqHeight is the buffer height that will be requested at the next - // dequeue operation. It is initialized to 1. - uint32_t mReqHeight; - - // mReqFormat is the buffer pixel format that will be requested at the next - // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888. - PixelFormat mReqFormat; - - // mReqUsage is the set of buffer usage flags that will be requested - // at the next deuque operation. It is initialized to 0. - uint32_t mReqUsage; - - // mTimestamp is the timestamp that will be used for the next buffer queue - // operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that - // a timestamp is auto-generated when queueBuffer is called. - int64_t mTimestamp; - - // mDataSpace is the buffer dataSpace that will be used for the next buffer - // queue operation. It defaults to HAL_DATASPACE_UNKNOWN, which - // means that the buffer contains some type of color data. - android_dataspace mDataSpace; - - // mCrop is the crop rectangle that will be used for the next buffer - // that gets queued. It is set by calling setCrop. - Rect mCrop; - - // mScalingMode is the scaling mode that will be used for the next - // buffers that get queued. It is set by calling setScalingMode. - int mScalingMode; - - // mTransform is the transform identifier that will be used for the next - // buffer that gets queued. It is set by calling setTransform. - uint32_t mTransform; - - // mStickyTransform is a transform that is applied on top of mTransform - // in each buffer that is queued. This is typically used to force the - // compositor to apply a transform, and will prevent the transform hint - // from being set by the compositor. - uint32_t mStickyTransform; - - // mDefaultWidth is default width of the buffers, regardless of the - // native_window_set_buffers_dimensions call. - uint32_t mDefaultWidth; - - // mDefaultHeight is default height of the buffers, regardless of the - // native_window_set_buffers_dimensions call. - uint32_t mDefaultHeight; - - // mUserWidth, if non-zero, is an application-specified override - // of mDefaultWidth. This is lower priority than the width set by - // native_window_set_buffers_dimensions. - uint32_t mUserWidth; - - // mUserHeight, if non-zero, is an application-specified override - // of mDefaultHeight. This is lower priority than the height set - // by native_window_set_buffers_dimensions. - uint32_t mUserHeight; - - // mTransformHint is the transform probably applied to buffers of this - // window. this is only a hint, actual transform may differ. - uint32_t mTransformHint; - - // mProducerControlledByApp whether this buffer producer is controlled - // by the application - bool mProducerControlledByApp; - - // mSwapIntervalZero set if we should drop buffers at queue() time to - // achieve an asynchronous swap interval - bool mSwapIntervalZero; - - // mConsumerRunningBehind whether the consumer is running more than - // one buffer behind the producer. - mutable bool mConsumerRunningBehind; - - // mMutex is the mutex used to prevent concurrent access to the member - // variables of Surface objects. It must be locked whenever the - // member variables are accessed. - mutable Mutex mMutex; - - // must be used from the lock/unlock thread - sp mLockedBuffer; - sp mPostedBuffer; - bool mConnectedToCpu; - - // When a CPU producer is attached, this reflects the region that the - // producer wished to update as well as whether the Surface was able to copy - // the previous buffer back to allow a partial update. - // - // When a non-CPU producer is attached, this reflects the surface damage - // (the change since the previous frame) passed in by the producer. - Region mDirtyRegion; - - // Stores the current generation number. See setGenerationNumber and - // IGraphicBufferProducer::setGenerationNumber for more information. - uint32_t mGenerationNumber; -}; - -}; // namespace android - -#endif // ANDROID_GUI_SURFACE_H diff --git a/third_party/android_frameworks_native/include/gui/SurfaceComposerClient.h b/third_party/android_frameworks_native/include/gui/SurfaceComposerClient.h deleted file mode 100644 index 9ec3f23491..0000000000 --- a/third_party/android_frameworks_native/include/gui/SurfaceComposerClient.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (C) 2007 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_SURFACE_COMPOSER_CLIENT_H -#define ANDROID_GUI_SURFACE_COMPOSER_CLIENT_H - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -namespace android { - -// --------------------------------------------------------------------------- - -class DisplayInfo; -class Composer; -class ISurfaceComposerClient; -class IGraphicBufferProducer; -class Region; - -// --------------------------------------------------------------------------- - -class SurfaceComposerClient : public RefBase -{ - friend class Composer; -public: - SurfaceComposerClient(); - virtual ~SurfaceComposerClient(); - - // Always make sure we could initialize - status_t initCheck() const; - - // Return the connection of this client - sp connection() const; - - // Forcibly remove connection before all references have gone away. - void dispose(); - - // callback when the composer is dies - status_t linkToComposerDeath(const sp& recipient, - void* cookie = NULL, uint32_t flags = 0); - - // Get a list of supported configurations for a given display - static status_t getDisplayConfigs(const sp& display, - Vector* configs); - - // Get the DisplayInfo for the currently-active configuration - static status_t getDisplayInfo(const sp& display, - DisplayInfo* info); - - // Get the index of the current active configuration (relative to the list - // returned by getDisplayInfo) - static int getActiveConfig(const sp& display); - - // Set a new active configuration using an index relative to the list - // returned by getDisplayInfo - static status_t setActiveConfig(const sp& display, int id); - - /* Triggers screen on/off or low power mode and waits for it to complete */ - static void setDisplayPowerMode(const sp& display, int mode); - - // ------------------------------------------------------------------------ - // surface creation / destruction - - //! Create a surface - sp createSurface( - const String8& name,// name of the surface - uint32_t w, // width in pixel - uint32_t h, // height in pixel - PixelFormat format, // pixel-format desired - uint32_t flags = 0 // usage flags - ); - - //! Create a virtual display - static sp createDisplay(const String8& displayName, bool secure); - - //! Destroy a virtual display - static void destroyDisplay(const sp& display); - - //! Get the token for the existing default displays. - //! Possible values for id are eDisplayIdMain and eDisplayIdHdmi. - static sp getBuiltInDisplay(int32_t id); - - // ------------------------------------------------------------------------ - // Composer parameters - // All composer parameters must be changed within a transaction - // several surfaces can be updated in one transaction, all changes are - // committed at once when the transaction is closed. - // closeGlobalTransaction() requires an IPC with the server. - - //! Open a composer transaction on all active SurfaceComposerClients. - static void openGlobalTransaction(); - - //! Close a composer transaction on all active SurfaceComposerClients. - static void closeGlobalTransaction(bool synchronous = false); - - //! Flag the currently open transaction as an animation transaction. - static void setAnimationTransaction(); - - status_t hide(const sp& id); - status_t show(const sp& id); - status_t setFlags(const sp& id, uint32_t flags, uint32_t mask); - status_t setTransparentRegionHint(const sp& id, const Region& transparent); - status_t setLayer(const sp& id, uint32_t layer); - status_t setAlpha(const sp& id, float alpha=1.0f); - status_t setMatrix(const sp& id, float dsdx, float dtdx, float dsdy, float dtdy); - status_t setPosition(const sp& id, float x, float y); - status_t setSize(const sp& id, uint32_t w, uint32_t h); - status_t setCrop(const sp& id, const Rect& crop); - status_t setLayerStack(const sp& id, uint32_t layerStack); - status_t destroySurface(const sp& id); - - status_t clearLayerFrameStats(const sp& token) const; - status_t getLayerFrameStats(const sp& token, FrameStats* outStats) const; - - static status_t clearAnimationFrameStats(); - static status_t getAnimationFrameStats(FrameStats* outStats); - - static void setDisplaySurface(const sp& token, - const sp& bufferProducer); - static void setDisplayLayerStack(const sp& token, - uint32_t layerStack); - static void setDisplaySize(const sp& token, uint32_t width, uint32_t height); - - /* setDisplayProjection() defines the projection of layer stacks - * to a given display. - * - * - orientation defines the display's orientation. - * - layerStackRect defines which area of the window manager coordinate - * space will be used. - * - displayRect defines where on the display will layerStackRect be - * mapped to. displayRect is specified post-orientation, that is - * it uses the orientation seen by the end-user. - */ - static void setDisplayProjection(const sp& token, - uint32_t orientation, - const Rect& layerStackRect, - const Rect& displayRect); - - status_t setBlur(const sp& id, float blur); - status_t setBlurMaskSurface(const sp& id, const sp& maskSurfaceId); - status_t setBlurMaskSampling(const sp& id, uint32_t blurMaskSampling); - status_t setBlurMaskAlphaThreshold(const sp& id, float alpha); - -private: - virtual void onFirstRef(); - Composer& getComposer(); - - mutable Mutex mLock; - status_t mStatus; - sp mClient; - Composer& mComposer; -}; - -// --------------------------------------------------------------------------- - -class ScreenshotClient -{ -public: - // if cropping isn't required, callers may pass in a default Rect, e.g.: - // capture(display, producer, Rect(), reqWidth, ...); - static status_t capture( - const sp& display, - const sp& producer, - Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, - uint32_t minLayerZ, uint32_t maxLayerZ, - bool useIdentityTransform); - -private: - mutable sp mCpuConsumer; - mutable sp mProducer; - CpuConsumer::LockedBuffer mBuffer; - bool mHaveBuffer; - -public: - ScreenshotClient(); - ~ScreenshotClient(); - - // frees the previous screenshot and captures a new one - // if cropping isn't required, callers may pass in a default Rect, e.g.: - // update(display, Rect(), useIdentityTransform); - status_t update(const sp& display, - Rect sourceCrop, bool useIdentityTransform); - status_t update(const sp& display, - Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, - bool useIdentityTransform); - status_t update(const sp& display, - Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, - uint32_t minLayerZ, uint32_t maxLayerZ, - bool useIdentityTransform); - status_t update(const sp& display, - Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, - uint32_t minLayerZ, uint32_t maxLayerZ, - bool useIdentityTransform, uint32_t rotation); - - sp getCpuConsumer() const; - - // release memory occupied by the screenshot - void release(); - - // pixels are valid until this object is freed or - // release() or update() is called - void const* getPixels() const; - - uint32_t getWidth() const; - uint32_t getHeight() const; - PixelFormat getFormat() const; - uint32_t getStride() const; - // size of allocated memory in bytes - size_t getSize() const; -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_GUI_SURFACE_COMPOSER_CLIENT_H diff --git a/third_party/android_frameworks_native/include/gui/SurfaceControl.h b/third_party/android_frameworks_native/include/gui/SurfaceControl.h deleted file mode 100644 index 5fa45d1668..0000000000 --- a/third_party/android_frameworks_native/include/gui/SurfaceControl.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2007 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_SURFACE_CONTROL_H -#define ANDROID_GUI_SURFACE_CONTROL_H - -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -namespace android { - -// --------------------------------------------------------------------------- - -class IGraphicBufferProducer; -class Surface; -class SurfaceComposerClient; - -// --------------------------------------------------------------------------- - -class SurfaceControl : public RefBase -{ -public: - static bool isValid(const sp& surface) { - return (surface != 0) && surface->isValid(); - } - - bool isValid() { - return mHandle!=0 && mClient!=0; - } - - static bool isSameSurface( - const sp& lhs, const sp& rhs); - - // release surface data from java - void clear(); - - status_t setLayerStack(uint32_t layerStack); - status_t setLayer(uint32_t layer); - status_t setPosition(float x, float y); - status_t setSize(uint32_t w, uint32_t h); - status_t hide(); - status_t show(); - status_t setFlags(uint32_t flags, uint32_t mask); - status_t setTransparentRegionHint(const Region& transparent); - status_t setAlpha(float alpha=1.0f); - status_t setMatrix(float dsdx, float dtdx, float dsdy, float dtdy); - status_t setCrop(const Rect& crop); - - static status_t writeSurfaceToParcel( - const sp& control, Parcel* parcel); - - sp getSurface() const; - - status_t clearLayerFrameStats() const; - status_t getLayerFrameStats(FrameStats* outStats) const; - - status_t setBlur(float blur = 0); - status_t setBlurMaskSurface(const sp& maskSurface); - status_t setBlurMaskSampling(uint32_t blurMaskSampling); - status_t setBlurMaskAlphaThreshold(float alpha); - -private: - // can't be copied - SurfaceControl& operator = (SurfaceControl& rhs); - SurfaceControl(const SurfaceControl& rhs); - - friend class SurfaceComposerClient; - friend class Surface; - - SurfaceControl( - const sp& client, - const sp& handle, - const sp& gbp); - - ~SurfaceControl(); - - status_t validate() const; - void destroy(); - - sp mClient; - sp mHandle; - sp mGraphicBufferProducer; - mutable Mutex mLock; - mutable sp mSurfaceData; -}; - -}; // namespace android - -#endif // ANDROID_GUI_SURFACE_CONTROL_H diff --git a/third_party/android_frameworks_native/include/ui/ANativeObjectBase.h b/third_party/android_frameworks_native/include/ui/ANativeObjectBase.h deleted file mode 100644 index 76e850fa27..0000000000 --- a/third_party/android_frameworks_native/include/ui/ANativeObjectBase.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2009 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_ANDROID_NATIVES_H -#define ANDROID_ANDROID_NATIVES_H - -#include -#include - -#include -#include - -// --------------------------------------------------------------------------- - -/* FIXME: this is legacy for pixmaps */ -typedef struct egl_native_pixmap_t -{ - int32_t version; /* must be 32 */ - int32_t width; - int32_t height; - int32_t stride; - uint8_t* data; - uint8_t format; - uint8_t rfu[3]; - union { - uint32_t compressedFormat; - int32_t vstride; - }; - int32_t reserved; -} egl_native_pixmap_t; - -/*****************************************************************************/ - -#ifdef __cplusplus - -#include - -namespace android { - -/* - * This helper class turns a ANativeXXX object type into a C++ - * reference-counted object; with proper type conversions. - */ -template -class ANativeObjectBase : public NATIVE_TYPE, public REF -{ -public: - // Disambiguate between the incStrong in REF and NATIVE_TYPE - void incStrong(const void* id) const { - REF::incStrong(id); - } - void decStrong(const void* id) const { - REF::decStrong(id); - } - -protected: - typedef ANativeObjectBase BASE; - ANativeObjectBase() : NATIVE_TYPE(), REF() { - NATIVE_TYPE::common.incRef = incRef; - NATIVE_TYPE::common.decRef = decRef; - } - static inline TYPE* getSelf(NATIVE_TYPE* self) { - return static_cast(self); - } - static inline TYPE const* getSelf(NATIVE_TYPE const* self) { - return static_cast(self); - } - static inline TYPE* getSelf(android_native_base_t* base) { - return getSelf(reinterpret_cast(base)); - } - static inline TYPE const * getSelf(android_native_base_t const* base) { - return getSelf(reinterpret_cast(base)); - } - static void incRef(android_native_base_t* base) { - ANativeObjectBase* self = getSelf(base); - self->incStrong(self); - } - static void decRef(android_native_base_t* base) { - ANativeObjectBase* self = getSelf(base); - self->decStrong(self); - } -}; - -} // namespace android -#endif // __cplusplus - -/*****************************************************************************/ - -#endif /* ANDROID_ANDROID_NATIVES_H */ diff --git a/third_party/android_frameworks_native/include/ui/DisplayInfo.h b/third_party/android_frameworks_native/include/ui/DisplayInfo.h deleted file mode 100644 index ad73ee72f9..0000000000 --- a/third_party/android_frameworks_native/include/ui/DisplayInfo.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2007 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_UI_DISPLAY_INFO_H -#define ANDROID_UI_DISPLAY_INFO_H - -#include -#include -#include - -#include - -namespace android { - -struct DisplayInfo { - uint32_t w; - uint32_t h; - float xdpi; - float ydpi; - float fps; - float density; - uint8_t orientation; - bool secure; - nsecs_t appVsyncOffset; - nsecs_t presentationDeadline; - int colorTransform; -}; - -/* Display orientations as defined in Surface.java and ISurfaceComposer.h. */ -enum { - DISPLAY_ORIENTATION_0 = 0, - DISPLAY_ORIENTATION_90 = 1, - DISPLAY_ORIENTATION_180 = 2, - DISPLAY_ORIENTATION_270 = 3 -}; - -}; // namespace android - -#endif // ANDROID_COMPOSER_DISPLAY_INFO_H diff --git a/third_party/android_frameworks_native/include/ui/DisplayStatInfo.h b/third_party/android_frameworks_native/include/ui/DisplayStatInfo.h deleted file mode 100644 index 0549a832b5..0000000000 --- a/third_party/android_frameworks_native/include/ui/DisplayStatInfo.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2014 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_UI_DISPLAY_STAT_INFO_H -#define ANDROID_UI_DISPLAY_STAT_INFO_H - -#include - -namespace android { - -struct DisplayStatInfo { - nsecs_t vsyncTime; - nsecs_t vsyncPeriod; -}; - -}; // namespace android - -#endif // ANDROID_COMPOSER_DISPLAY_STAT_INFO_H diff --git a/third_party/android_frameworks_native/include/ui/Fence.h b/third_party/android_frameworks_native/include/ui/Fence.h deleted file mode 100644 index b431bd52aa..0000000000 --- a/third_party/android_frameworks_native/include/ui/Fence.h +++ /dev/null @@ -1,117 +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_FENCE_H -#define ANDROID_FENCE_H - -#include -#include - -#include -#include -#include -#include -#include -#include - -struct ANativeWindowBuffer; - -namespace android { - -// =========================================================================== -// Fence -// =========================================================================== - -class Fence - : public LightRefBase, public Flattenable -{ -public: - static const sp NO_FENCE; - - // TIMEOUT_NEVER may be passed to the wait method to indicate that it - // should wait indefinitely for the fence to signal. - enum { TIMEOUT_NEVER = -1 }; - - // Construct a new Fence object with an invalid file descriptor. This - // should be done when the Fence object will be set up by unflattening - // serialized data. - Fence(); - - // Construct a new Fence object to manage a given fence file descriptor. - // When the new Fence object is destructed the file descriptor will be - // closed. - Fence(int fenceFd); - - // Check whether the Fence has an open fence file descriptor. Most Fence - // methods treat an invalid file descriptor just like a valid fence that - // is already signalled, so using this is usually not necessary. - bool isValid() const { return mFenceFd != -1; } - - // wait waits for up to timeout milliseconds for the fence to signal. If - // the fence signals then NO_ERROR is returned. If the timeout expires - // before the fence signals then -ETIME is returned. A timeout of - // TIMEOUT_NEVER may be used to indicate that the call should wait - // indefinitely for the fence to signal. - status_t wait(int timeout); - - // waitForever is a convenience function for waiting forever for a fence to - // signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the - // system log and fence state to the kernel log if the wait lasts longer - // than a warning timeout. - // The logname argument should be a string identifying - // the caller and will be included in the log message. - status_t waitForever(const char* logname); - - // merge combines two Fence objects, creating a new Fence object that - // becomes signaled when both f1 and f2 are signaled (even if f1 or f2 is - // destroyed before it becomes signaled). The name argument specifies the - // human-readable name to associated with the new Fence object. - static sp merge(const String8& name, const sp& f1, - const sp& f2); - - // Return a duplicate of the fence file descriptor. The caller is - // responsible for closing the returned file descriptor. On error, -1 will - // be returned and errno will indicate the problem. - int dup() const; - - // getSignalTime returns the system monotonic clock time at which the - // fence transitioned to the signaled state. If the fence is not signaled - // then INT64_MAX is returned. If the fence is invalid or if an error - // occurs then -1 is returned. - nsecs_t getSignalTime() const; - - // Flattenable interface - size_t getFlattenedSize() const; - size_t getFdCount() const; - status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; - status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); - -private: - // Only allow instantiation using ref counting. - friend class LightRefBase; - ~Fence(); - - // Disallow copying - Fence(const Fence& rhs); - Fence& operator = (const Fence& rhs); - const Fence& operator = (const Fence& rhs) const; - - int mFenceFd; -}; - -}; // namespace android - -#endif // ANDROID_FENCE_H diff --git a/third_party/android_frameworks_native/include/ui/FrameStats.h b/third_party/android_frameworks_native/include/ui/FrameStats.h deleted file mode 100644 index 6bfe635c72..0000000000 --- a/third_party/android_frameworks_native/include/ui/FrameStats.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2014 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_UI_FRAME_STATS_H -#define ANDROID_UI_FRAME_STATS_H - -#include -#include -#include - -namespace android { - -class FrameStats : public LightFlattenable { -public: - FrameStats() : refreshPeriodNano(0) {}; - - /* - * Approximate refresh time, in nanoseconds. - */ - nsecs_t refreshPeriodNano; - - /* - * The times in nanoseconds for when the frame contents were posted by the producer (e.g. - * the application). They are either explicitly set or defaulted to the time when - * Surface::queueBuffer() was called. - */ - Vector desiredPresentTimesNano; - - /* - * The times in milliseconds for when the frame contents were presented on the screen. - */ - Vector actualPresentTimesNano; - - /* - * The times in nanoseconds for when the frame contents were ready to be presented. Note that - * a frame can be posted and still it contents being rendered asynchronously in GL. In such a - * case these are the times when the frame contents were completely rendered (i.e. their fences - * signaled). - */ - Vector frameReadyTimesNano; - - // LightFlattenable - bool isFixedSize() const; - size_t getFlattenedSize() const; - status_t flatten(void* buffer, size_t size) const; - status_t unflatten(void const* buffer, size_t size); -}; - -}; // namespace android - -#endif // ANDROID_UI_FRAME_STATS_H diff --git a/third_party/android_frameworks_native/include/ui/FramebufferNativeWindow.h b/third_party/android_frameworks_native/include/ui/FramebufferNativeWindow.h deleted file mode 100644 index 6b66d5f66b..0000000000 --- a/third_party/android_frameworks_native/include/ui/FramebufferNativeWindow.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2007 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 INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP -#warning "FramebufferNativeWindow is deprecated" -#endif - -#ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H -#define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H - -#include -#include - -#include - -#include -#include - -#include -#include - -#define MIN_NUM_FRAME_BUFFERS 2 -#define MAX_NUM_FRAME_BUFFERS 3 - -extern "C" EGLNativeWindowType android_createDisplaySurface(void); - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -class Surface; -class NativeBuffer; - -// --------------------------------------------------------------------------- - -class FramebufferNativeWindow - : public ANativeObjectBase< - ANativeWindow, - FramebufferNativeWindow, - LightRefBase > -{ -public: - FramebufferNativeWindow(); - - framebuffer_device_t const * getDevice() const { return fbDev; } - - bool isUpdateOnDemand() const { return mUpdateOnDemand; } - status_t setUpdateRectangle(const Rect& updateRect); - status_t compositionComplete(); - - void dump(String8& result); - - // for debugging only - int getCurrentBufferIndex() const; - -private: - friend class LightRefBase; - ~FramebufferNativeWindow(); // this class cannot be overloaded - static int setSwapInterval(ANativeWindow* window, int interval); - static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); - static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); - static int query(const ANativeWindow* window, int what, int* value); - static int perform(ANativeWindow* window, int operation, ...); - - static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer); - static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); - static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); - - framebuffer_device_t* fbDev; - alloc_device_t* grDev; - - sp buffers[MAX_NUM_FRAME_BUFFERS]; - sp front; - - mutable Mutex mutex; - Condition mCondition; - int32_t mNumBuffers; - int32_t mNumFreeBuffers; - int32_t mBufferHead; - int32_t mCurrentBufferIndex; - bool mUpdateOnDemand; -}; - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H - diff --git a/third_party/android_frameworks_native/include/ui/GraphicBuffer.h b/third_party/android_frameworks_native/include/ui/GraphicBuffer.h deleted file mode 100644 index 3da720ff37..0000000000 --- a/third_party/android_frameworks_native/include/ui/GraphicBuffer.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2007 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_GRAPHIC_BUFFER_H -#define ANDROID_GRAPHIC_BUFFER_H - -#include -#include - -#include -#include -#include -#include -#include - - -struct ANativeWindowBuffer; - -namespace android { - -class GraphicBufferMapper; - -// =========================================================================== -// GraphicBuffer -// =========================================================================== - -class GraphicBuffer - : public ANativeObjectBase< ANativeWindowBuffer, GraphicBuffer, RefBase >, - public Flattenable -{ - friend class Flattenable; -public: - - enum { - USAGE_SW_READ_NEVER = GRALLOC_USAGE_SW_READ_NEVER, - USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY, - USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN, - USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK, - - USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER, - USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY, - USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN, - USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK, - - USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK, - - USAGE_PROTECTED = GRALLOC_USAGE_PROTECTED, - - USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE, - USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER, - USAGE_HW_2D = GRALLOC_USAGE_HW_2D, - USAGE_HW_COMPOSER = GRALLOC_USAGE_HW_COMPOSER, - USAGE_HW_VIDEO_ENCODER = GRALLOC_USAGE_HW_VIDEO_ENCODER, - USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK, - - USAGE_CURSOR = GRALLOC_USAGE_CURSOR, - }; - - GraphicBuffer(); - - // creates w * h buffer - GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, - uint32_t inUsage); - - // create a buffer from an existing handle - GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, - uint32_t inUsage, uint32_t inStride, native_handle_t* inHandle, - bool keepOwnership); - - // create a buffer from an existing ANativeWindowBuffer - GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership); - - // return status - status_t initCheck() const; - - uint32_t getWidth() const { return static_cast(width); } - uint32_t getHeight() const { return static_cast(height); } - uint32_t getStride() const { return static_cast(stride); } - uint32_t getUsage() const { return static_cast(usage); } - PixelFormat getPixelFormat() const { return format; } - Rect getBounds() const { return Rect(width, height); } - uint64_t getId() const { return mId; } - - uint32_t getGenerationNumber() const { return mGenerationNumber; } - void setGenerationNumber(uint32_t generation) { - mGenerationNumber = generation; - } - - status_t reallocate(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inUsage); - - bool needsReallocation(uint32_t inWidth, uint32_t inHeight, - PixelFormat inFormat, uint32_t inUsage); - - status_t lock(uint32_t inUsage, void** vaddr); - status_t lock(uint32_t inUsage, const Rect& rect, void** vaddr); - // For HAL_PIXEL_FORMAT_YCbCr_420_888 - status_t lockYCbCr(uint32_t inUsage, android_ycbcr *ycbcr); - status_t lockYCbCr(uint32_t inUsage, const Rect& rect, - android_ycbcr *ycbcr); - status_t unlock(); - status_t lockAsync(uint32_t inUsage, void** vaddr, int fenceFd); - status_t lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr, - int fenceFd); - status_t lockAsyncYCbCr(uint32_t inUsage, android_ycbcr *ycbcr, - int fenceFd); - status_t lockAsyncYCbCr(uint32_t inUsage, const Rect& rect, - android_ycbcr *ycbcr, int fenceFd); - status_t unlockAsync(int *fenceFd); - - ANativeWindowBuffer* getNativeBuffer() const; - - // for debugging - static void dumpAllocationsToSystemLog(); - - // Flattenable protocol - size_t getFlattenedSize() const; - size_t getFdCount() const; - status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; - status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); - -private: - ~GraphicBuffer(); - - enum { - ownNone = 0, - ownHandle = 1, - ownData = 2, - }; - - inline const GraphicBufferMapper& getBufferMapper() const { - return mBufferMapper; - } - inline GraphicBufferMapper& getBufferMapper() { - return mBufferMapper; - } - uint8_t mOwner; - -private: - friend class Surface; - friend class BpSurface; - friend class BnSurface; - friend class LightRefBase; - GraphicBuffer(const GraphicBuffer& rhs); - GraphicBuffer& operator = (const GraphicBuffer& rhs); - const GraphicBuffer& operator = (const GraphicBuffer& rhs) const; - - status_t initSize(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, - uint32_t inUsage); - - void free_handle(); - - GraphicBufferMapper& mBufferMapper; - ssize_t mInitCheck; - - // If we're wrapping another buffer then this reference will make sure it - // doesn't get freed. - sp mWrappedBuffer; - - uint64_t mId; - - // Stores the generation number of this buffer. If this number does not - // match the BufferQueue's internal generation number (set through - // IGBP::setGenerationNumber), attempts to attach the buffer will fail. - uint32_t mGenerationNumber; -}; - -}; // namespace android - -#endif // ANDROID_GRAPHIC_BUFFER_H diff --git a/third_party/android_frameworks_native/include/ui/GraphicBufferAllocator.h b/third_party/android_frameworks_native/include/ui/GraphicBufferAllocator.h deleted file mode 100644 index 5443f09a10..0000000000 --- a/third_party/android_frameworks_native/include/ui/GraphicBufferAllocator.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -** -** Copyright 2009, 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_BUFFER_ALLOCATOR_H -#define ANDROID_BUFFER_ALLOCATOR_H - -#include - -#include - -#include -#include -#include -#include - -#include - -#include - - -namespace android { -// --------------------------------------------------------------------------- - -class String8; - -class GraphicBufferAllocator : public Singleton -{ -public: - enum { - USAGE_SW_READ_NEVER = GRALLOC_USAGE_SW_READ_NEVER, - USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY, - USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN, - USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK, - - USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER, - USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY, - USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN, - USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK, - - USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK, - - USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE, - USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER, - USAGE_HW_2D = GRALLOC_USAGE_HW_2D, - USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK - }; - - static inline GraphicBufferAllocator& get() { return getInstance(); } - - status_t alloc(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage, - buffer_handle_t* handle, uint32_t* stride); - - status_t free(buffer_handle_t handle); - - void dump(String8& res) const; - static void dumpToSystemLog(); - -private: - struct alloc_rec_t { - uint32_t width; - uint32_t height; - uint32_t stride; - PixelFormat format; - uint32_t usage; - size_t size; - }; - - static Mutex sLock; - static KeyedVector sAllocList; - - friend class Singleton; - GraphicBufferAllocator(); - ~GraphicBufferAllocator(); - - alloc_device_t *mAllocDev; -}; - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_BUFFER_ALLOCATOR_H diff --git a/third_party/android_frameworks_native/include/ui/GraphicBufferMapper.h b/third_party/android_frameworks_native/include/ui/GraphicBufferMapper.h deleted file mode 100644 index 9900624827..0000000000 --- a/third_party/android_frameworks_native/include/ui/GraphicBufferMapper.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2007 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_UI_BUFFER_MAPPER_H -#define ANDROID_UI_BUFFER_MAPPER_H - -#include -#include - -#include - -#include - - -struct gralloc_module_t; - -namespace android { - -// --------------------------------------------------------------------------- - -class Rect; - -class GraphicBufferMapper : public Singleton -{ -public: - static inline GraphicBufferMapper& get() { return getInstance(); } - - status_t registerBuffer(buffer_handle_t handle); - - status_t unregisterBuffer(buffer_handle_t handle); - - status_t lock(buffer_handle_t handle, - uint32_t usage, const Rect& bounds, void** vaddr); - - status_t lockYCbCr(buffer_handle_t handle, - uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr); - - status_t unlock(buffer_handle_t handle); - - status_t lockAsync(buffer_handle_t handle, - uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd); - - status_t lockAsyncYCbCr(buffer_handle_t handle, - uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, - int fenceFd); - - status_t unlockAsync(buffer_handle_t handle, int *fenceFd); - -#ifdef EXYNOS4_ENHANCEMENTS - status_t getphys(buffer_handle_t handle, void** paddr); -#endif - - // dumps information about the mapping of this handle - void dump(buffer_handle_t handle); - -private: - friend class Singleton; - GraphicBufferMapper(); - gralloc_module_t const *mAllocMod; -}; - -// --------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_UI_BUFFER_MAPPER_H - diff --git a/third_party/android_frameworks_native/include/ui/PixelFormat.h b/third_party/android_frameworks_native/include/ui/PixelFormat.h deleted file mode 100644 index f26fecb8b1..0000000000 --- a/third_party/android_frameworks_native/include/ui/PixelFormat.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// - -// Pixel formats used across the system. -// These formats might not all be supported by all renderers, for instance -// skia or SurfaceFlinger are not required to support all of these formats -// (either as source or destination) - - -#ifndef UI_PIXELFORMAT_H -#define UI_PIXELFORMAT_H - -#include - -namespace android { - -enum { - // - // these constants need to match those - // in graphics/PixelFormat.java & pixelflinger/format.h - // - PIXEL_FORMAT_UNKNOWN = 0, - PIXEL_FORMAT_NONE = 0, - - // logical pixel formats used by the SurfaceFlinger ----------------------- - PIXEL_FORMAT_CUSTOM = -4, - // Custom pixel-format described by a PixelFormatInfo structure - - PIXEL_FORMAT_TRANSLUCENT = -3, - // System chooses a format that supports translucency (many alpha bits) - - PIXEL_FORMAT_TRANSPARENT = -2, - // System chooses a format that supports transparency - // (at least 1 alpha bit) - - PIXEL_FORMAT_OPAQUE = -1, - // System chooses an opaque format (no alpha bits required) - - // real pixel formats supported for rendering ----------------------------- - - PIXEL_FORMAT_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888, // 4x8-bit RGBA - PIXEL_FORMAT_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888, // 4x8-bit RGB0 - PIXEL_FORMAT_RGB_888 = HAL_PIXEL_FORMAT_RGB_888, // 3x8-bit RGB - PIXEL_FORMAT_RGB_565 = HAL_PIXEL_FORMAT_RGB_565, // 16-bit RGB - PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA - PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit ARGB - PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit ARGB -}; - -typedef int32_t PixelFormat; - -uint32_t bytesPerPixel(PixelFormat format); -uint32_t bitsPerPixel(PixelFormat format); - -}; // namespace android - -#endif // UI_PIXELFORMAT_H diff --git a/third_party/android_frameworks_native/include/ui/Point.h b/third_party/android_frameworks_native/include/ui/Point.h deleted file mode 100644 index 1d7f64d307..0000000000 --- a/third_party/android_frameworks_native/include/ui/Point.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2006 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_UI_POINT -#define ANDROID_UI_POINT - -#include -#include - -namespace android { - -class Point : public LightFlattenablePod -{ -public: - int x; - int y; - - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - // Default constructor doesn't initialize the Point - inline Point() { - } - inline Point(int x, int y) : x(x), y(y) { - } - - inline bool operator == (const Point& rhs) const { - return (x == rhs.x) && (y == rhs.y); - } - inline bool operator != (const Point& rhs) const { - return !operator == (rhs); - } - - inline bool isOrigin() const { - return !(x|y); - } - - // operator < defines an order which allows to use points in sorted - // vectors. - bool operator < (const Point& rhs) const { - return y -#include -#include -#include - -#include - -namespace android { - -class Rect : public ARect, public LightFlattenablePod -{ -public: - typedef ARect::value_type value_type; - - static const Rect INVALID_RECT; - - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - inline Rect() { - left = right = top = bottom = 0; - } - - inline Rect(int32_t w, int32_t h) { - left = top = 0; - right = w; - bottom = h; - } - - inline Rect(uint32_t w, uint32_t h) { - if (w > INT32_MAX) { - ALOG(LOG_WARN, "Rect", - "Width %u too large for Rect class, clamping", w); - w = INT32_MAX; - } - if (h > INT32_MAX) { - ALOG(LOG_WARN, "Rect", - "Height %u too large for Rect class, clamping", h); - h = INT32_MAX; - } - left = top = 0; - right = w; - bottom = h; - } - - inline Rect(int32_t l, int32_t t, int32_t r, int32_t b) { - left = l; - top = t; - right = r; - bottom = b; - } - - inline Rect(const Point& lt, const Point& rb) { - left = lt.x; - top = lt.y; - right = rb.x; - bottom = rb.y; - } - - void makeInvalid(); - - inline void clear() { - left = top = right = bottom = 0; - } - - // a valid rectangle has a non negative width and height - inline bool isValid() const { - return (getWidth() >= 0) && (getHeight() >= 0); - } - - // an empty rect has a zero width or height, or is invalid - inline bool isEmpty() const { - return (getWidth() <= 0) || (getHeight() <= 0); - } - - // rectangle's width - inline int32_t getWidth() const { - return right - left; - } - - // rectangle's height - inline int32_t getHeight() const { - return bottom - top; - } - - inline Rect getBounds() const { - return Rect(right - left, bottom - top); - } - - void setLeftTop(const Point& lt) { - left = lt.x; - top = lt.y; - } - - void setRightBottom(const Point& rb) { - right = rb.x; - bottom = rb.y; - } - - // the following 4 functions return the 4 corners of the rect as Point - Point leftTop() const { - return Point(left, top); - } - Point rightBottom() const { - return Point(right, bottom); - } - Point rightTop() const { - return Point(right, top); - } - Point leftBottom() const { - return Point(left, bottom); - } - - // comparisons - inline bool operator == (const Rect& rhs) const { - return (left == rhs.left) && (top == rhs.top) && - (right == rhs.right) && (bottom == rhs.bottom); - } - - inline bool operator != (const Rect& rhs) const { - return !operator == (rhs); - } - - // operator < defines an order which allows to use rectangles in sorted - // vectors. - bool operator < (const Rect& rhs) const; - - const Rect operator + (const Point& rhs) const; - const Rect operator - (const Point& rhs) const; - - Rect& operator += (const Point& rhs) { - return offsetBy(rhs.x, rhs.y); - } - Rect& operator -= (const Point& rhs) { - return offsetBy(-rhs.x, -rhs.y); - } - - Rect& offsetToOrigin() { - right -= left; - bottom -= top; - left = top = 0; - return *this; - } - Rect& offsetTo(const Point& p) { - return offsetTo(p.x, p.y); - } - Rect& offsetBy(const Point& dp) { - return offsetBy(dp.x, dp.y); - } - - Rect& offsetTo(int32_t x, int32_t y); - Rect& offsetBy(int32_t x, int32_t y); - - bool intersect(const Rect& with, Rect* result) const; - - // Create a new Rect by transforming this one using a graphics HAL - // transform. This rectangle is defined in a coordinate space starting at - // the origin and extending to (width, height). If the transform includes - // a ROT90 then the output rectangle is defined in a space extending to - // (height, width). Otherwise the output rectangle is in the same space as - // the input. - Rect transform(uint32_t xform, int32_t width, int32_t height) const; - - // this calculates (Region(*this) - exclude).bounds() efficiently - Rect reduce(const Rect& exclude) const; - - - // for backward compatibility - inline int32_t width() const { return getWidth(); } - inline int32_t height() const { return getHeight(); } - inline void set(const Rect& rhs) { operator = (rhs); } -}; - -ANDROID_BASIC_TYPES_TRAITS(Rect) - -}; // namespace android - -#endif // ANDROID_UI_RECT diff --git a/third_party/android_frameworks_native/include/ui/Region.h b/third_party/android_frameworks_native/include/ui/Region.h deleted file mode 100644 index 2a1491837d..0000000000 --- a/third_party/android_frameworks_native/include/ui/Region.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (C) 2007 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_UI_REGION_H -#define ANDROID_UI_REGION_H - -#include -#include - -#include - -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -class SharedBuffer; -class String8; - -// --------------------------------------------------------------------------- -class Region : public LightFlattenable -{ -public: - static const Region INVALID_REGION; - - Region(); - Region(const Region& rhs); - explicit Region(const Rect& rhs); - ~Region(); - - static Region createTJunctionFreeRegion(const Region& r); - - Region& operator = (const Region& rhs); - - inline bool isEmpty() const { return getBounds().isEmpty(); } - inline bool isRect() const { return mStorage.size() == 1; } - - inline Rect getBounds() const { return mStorage[mStorage.size() - 1]; } - inline Rect bounds() const { return getBounds(); } - - bool contains(const Point& point) const; - bool contains(int x, int y) const; - - // the region becomes its bounds - Region& makeBoundsSelf(); - - void clear(); - void set(const Rect& r); - void set(int32_t w, int32_t h); - void set(uint32_t w, uint32_t h); - - Region& orSelf(const Rect& rhs); - Region& xorSelf(const Rect& rhs); - Region& andSelf(const Rect& rhs); - Region& subtractSelf(const Rect& rhs); - - // boolean operators, applied on this - Region& orSelf(const Region& rhs); - Region& xorSelf(const Region& rhs); - Region& andSelf(const Region& rhs); - Region& subtractSelf(const Region& rhs); - - // boolean operators - const Region merge(const Rect& rhs) const; - const Region mergeExclusive(const Rect& rhs) const; - const Region intersect(const Rect& rhs) const; - const Region subtract(const Rect& rhs) const; - - // boolean operators - const Region merge(const Region& rhs) const; - const Region mergeExclusive(const Region& rhs) const; - const Region intersect(const Region& rhs) const; - const Region subtract(const Region& rhs) const; - - // these translate rhs first - Region& translateSelf(int dx, int dy); - Region& orSelf(const Region& rhs, int dx, int dy); - Region& xorSelf(const Region& rhs, int dx, int dy); - Region& andSelf(const Region& rhs, int dx, int dy); - Region& subtractSelf(const Region& rhs, int dx, int dy); - - // these translate rhs first - const Region translate(int dx, int dy) const; - const Region merge(const Region& rhs, int dx, int dy) const; - const Region mergeExclusive(const Region& rhs, int dx, int dy) const; - const Region intersect(const Region& rhs, int dx, int dy) const; - const Region subtract(const Region& rhs, int dx, int dy) const; - - // convenience operators overloads - inline const Region operator | (const Region& rhs) const; - inline const Region operator ^ (const Region& rhs) const; - inline const Region operator & (const Region& rhs) const; - inline const Region operator - (const Region& rhs) const; - inline const Region operator + (const Point& pt) const; - - inline Region& operator |= (const Region& rhs); - inline Region& operator ^= (const Region& rhs); - inline Region& operator &= (const Region& rhs); - inline Region& operator -= (const Region& rhs); - inline Region& operator += (const Point& pt); - - - // returns true if the regions share the same underlying storage - bool isTriviallyEqual(const Region& region) const; - - - /* various ways to access the rectangle list */ - - - // STL-like iterators - typedef Rect const* const_iterator; - const_iterator begin() const; - const_iterator end() const; - - // returns an array of rect which has the same life-time has this - // Region object. - Rect const* getArray(size_t* count) const; - - // returns a SharedBuffer as well as the number of rects. - // ownership is transfered to the caller. - // the caller must call SharedBuffer::release() to free the memory. - SharedBuffer const* getSharedBuffer(size_t* count) const; - - /* no user serviceable parts here... */ - - // add a rectangle to the internal list. This rectangle must - // be sorted in Y and X and must not make the region invalid. - void addRectUnchecked(int l, int t, int r, int b); - - inline bool isFixedSize() const { return false; } - size_t getFlattenedSize() const; - status_t flatten(void* buffer, size_t size) const; - status_t unflatten(void const* buffer, size_t size); - - void dump(String8& out, const char* what, uint32_t flags=0) const; - void dump(const char* what, uint32_t flags=0) const; - -private: - class rasterizer; - friend class rasterizer; - - Region& operationSelf(const Rect& r, int op); - Region& operationSelf(const Region& r, int op); - Region& operationSelf(const Region& r, int dx, int dy, int op); - const Region operation(const Rect& rhs, int op) const; - const Region operation(const Region& rhs, int op) const; - const Region operation(const Region& rhs, int dx, int dy, int op) const; - - static void boolean_operation(int op, Region& dst, - const Region& lhs, const Region& rhs, int dx, int dy); - static void boolean_operation(int op, Region& dst, - const Region& lhs, const Rect& rhs, int dx, int dy); - - static void boolean_operation(int op, Region& dst, - const Region& lhs, const Region& rhs); - static void boolean_operation(int op, Region& dst, - const Region& lhs, const Rect& rhs); - - static void translate(Region& reg, int dx, int dy); - static void translate(Region& dst, const Region& reg, int dx, int dy); - - static bool validate(const Region& reg, - const char* name, bool silent = false); - - // mStorage is a (manually) sorted array of Rects describing the region - // with an extra Rect as the last element which is set to the - // bounds of the region. However, if the region is - // a simple Rect then mStorage contains only that rect. - Vector mStorage; -}; - - -const Region Region::operator | (const Region& rhs) const { - return merge(rhs); -} -const Region Region::operator ^ (const Region& rhs) const { - return mergeExclusive(rhs); -} -const Region Region::operator & (const Region& rhs) const { - return intersect(rhs); -} -const Region Region::operator - (const Region& rhs) const { - return subtract(rhs); -} -const Region Region::operator + (const Point& pt) const { - return translate(pt.x, pt.y); -} - - -Region& Region::operator |= (const Region& rhs) { - return orSelf(rhs); -} -Region& Region::operator ^= (const Region& rhs) { - return xorSelf(rhs); -} -Region& Region::operator &= (const Region& rhs) { - return andSelf(rhs); -} -Region& Region::operator -= (const Region& rhs) { - return subtractSelf(rhs); -} -Region& Region::operator += (const Point& pt) { - return translateSelf(pt.x, pt.y); -} -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_UI_REGION_H - diff --git a/third_party/android_frameworks_native/include/ui/TMatHelpers.h b/third_party/android_frameworks_native/include/ui/TMatHelpers.h deleted file mode 100644 index a6aadcad40..0000000000 --- a/third_party/android_frameworks_native/include/ui/TMatHelpers.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2013 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 TMAT_IMPLEMENTATION -#error "Don't include TMatHelpers.h directly. use ui/mat*.h instead" -#else -#undef TMAT_IMPLEMENTATION -#endif - - -#ifndef UI_TMAT_HELPERS_H -#define UI_TMAT_HELPERS_H - -#include -#include -#include -#include -#include - -#define PURE __attribute__((pure)) - -namespace android { -// ------------------------------------------------------------------------------------- - -/* - * No user serviceable parts here. - * - * Don't use this file directly, instead include ui/mat*.h - */ - - -/* - * Matrix utilities - */ - -namespace matrix { - -inline int PURE transpose(int v) { return v; } -inline float PURE transpose(float v) { return v; } -inline double PURE transpose(double v) { return v; } - -inline int PURE trace(int v) { return v; } -inline float PURE trace(float v) { return v; } -inline double PURE trace(double v) { return v; } - -template -MATRIX PURE inverse(const MATRIX& src) { - - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX::COL_SIZE == MATRIX::ROW_SIZE ); - - typename MATRIX::value_type t; - const size_t N = MATRIX::col_size(); - size_t swap; - MATRIX tmp(src); - MATRIX inverse(1); - - for (size_t i=0 ; i fabs(tmp[i][i])) { - swap = j; - } - } - - if (swap != i) { - /* swap rows. */ - for (size_t k=0 ; k -MATRIX_R PURE multiply(const MATRIX_A& lhs, const MATRIX_B& rhs) { - // pre-requisite: - // lhs : D columns, R rows - // rhs : C columns, D rows - // res : C columns, R rows - - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX_A::ROW_SIZE == MATRIX_B::COL_SIZE ); - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX_R::ROW_SIZE == MATRIX_B::ROW_SIZE ); - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX_R::COL_SIZE == MATRIX_A::COL_SIZE ); - - MATRIX_R res(MATRIX_R::NO_INIT); - for (size_t r=0 ; r -MATRIX PURE transpose(const MATRIX& m) { - // for now we only handle square matrix transpose - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX::ROW_SIZE == MATRIX::COL_SIZE ); - MATRIX result(MATRIX::NO_INIT); - for (size_t r=0 ; r -typename MATRIX::value_type PURE trace(const MATRIX& m) { - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX::ROW_SIZE == MATRIX::COL_SIZE ); - typename MATRIX::value_type result(0); - for (size_t r=0 ; r -typename MATRIX::col_type PURE diag(const MATRIX& m) { - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX::ROW_SIZE == MATRIX::COL_SIZE ); - typename MATRIX::col_type result(MATRIX::col_type::NO_INIT); - for (size_t r=0 ; r -String8 asString(const MATRIX& m) { - String8 s; - for (size_t c=0 ; c. - * - * BASE only needs to implement operator[] and size(). - * By simply inheriting from TMatProductOperators BASE will automatically - * get all the functionality here. - */ - -template class BASE, typename T> -class TMatProductOperators { -public: - // multiply by a scalar - BASE& operator *= (T v) { - BASE& lhs(static_cast< BASE& >(*this)); - for (size_t r=0 ; r& operator /= (T v) { - BASE& lhs(static_cast< BASE& >(*this)); - for (size_t r=0 ; r - friend BASE PURE operator *(const BASE& lhs, const BASE& rhs) { - return matrix::multiply >(lhs, rhs); - } -}; - - -/* - * TMatSquareFunctions implements functions on a matrix of type BASE. - * - * BASE only needs to implement: - * - operator[] - * - col_type - * - row_type - * - COL_SIZE - * - ROW_SIZE - * - * By simply inheriting from TMatSquareFunctions BASE will automatically - * get all the functionality here. - */ - -template class BASE, typename T> -class TMatSquareFunctions { -public: - /* - * NOTE: the functions below ARE NOT member methods. They are friend functions - * with they definition inlined with their declaration. This makes these - * template functions available to the compiler when (and only when) this class - * is instantiated, at which point they're only templated on the 2nd parameter - * (the first one, BASE being known). - */ - friend BASE PURE inverse(const BASE& m) { return matrix::inverse(m); } - friend BASE PURE transpose(const BASE& m) { return matrix::transpose(m); } - friend T PURE trace(const BASE& m) { return matrix::trace(m); } -}; - -template class BASE, typename T> -class TMatDebug { -public: - String8 asString() const { - return matrix::asString( static_cast< const BASE& >(*this) ); - } -}; - -// ------------------------------------------------------------------------------------- -}; // namespace android - -#undef PURE - -#endif /* UI_TMAT_HELPERS_H */ diff --git a/third_party/android_frameworks_native/include/ui/TVecHelpers.h b/third_party/android_frameworks_native/include/ui/TVecHelpers.h deleted file mode 100644 index bb7dbfc2b8..0000000000 --- a/third_party/android_frameworks_native/include/ui/TVecHelpers.h +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 2013 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 TVEC_IMPLEMENTATION -#error "Don't include TVecHelpers.h directly. use ui/vec*.h instead" -#else -#undef TVEC_IMPLEMENTATION -#endif - - -#ifndef UI_TVEC_HELPERS_H -#define UI_TVEC_HELPERS_H - -#include -#include - -#define PURE __attribute__((pure)) - -namespace android { -// ------------------------------------------------------------------------------------- - -/* - * No user serviceable parts here. - * - * Don't use this file directly, instead include ui/vec{2|3|4}.h - */ - -/* - * This class casts itself into anything and assign itself from anything! - * Use with caution! - */ -template -struct Impersonator { - Impersonator& operator = (const TYPE& rhs) { - reinterpret_cast(*this) = rhs; - return *this; - } - operator TYPE& () { - return reinterpret_cast(*this); - } - operator TYPE const& () const { - return reinterpret_cast(*this); - } -}; - -/* - * TVec{Add|Product}Operators implements basic arithmetic and basic compound assignments - * operators on a vector of type BASE. - * - * BASE only needs to implement operator[] and size(). - * By simply inheriting from TVec{Add|Product}Operators BASE will automatically - * get all the functionality here. - */ - -template class BASE, typename T> -class TVecAddOperators { -public: - /* compound assignment from a another vector of the same size but different - * element type. - */ - template - BASE& operator += (const BASE& v) { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - rhs[i] += v[i]; - } - return rhs; - } - template - BASE& operator -= (const BASE& v) { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - rhs[i] -= v[i]; - } - return rhs; - } - - /* compound assignment from a another vector of the same type. - * These operators can be used for implicit conversion and handle operations - * like "vector *= scalar" by letting the compiler implicitly convert a scalar - * to a vector (assuming the BASE allows it). - */ - BASE& operator += (const BASE& v) { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - rhs[i] += v[i]; - } - return rhs; - } - BASE& operator -= (const BASE& v) { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - rhs[i] -= v[i]; - } - return rhs; - } - - /* - * NOTE: the functions below ARE NOT member methods. They are friend functions - * with they definition inlined with their declaration. This makes these - * template functions available to the compiler when (and only when) this class - * is instantiated, at which point they're only templated on the 2nd parameter - * (the first one, BASE being known). - */ - - /* The operators below handle operation between vectors of the same side - * but of a different element type. - */ - template - friend inline - BASE PURE operator +(const BASE& lv, const BASE& rv) { - return BASE(lv) += rv; - } - template - friend inline - BASE PURE operator -(const BASE& lv, const BASE& rv) { - return BASE(lv) -= rv; - } - - /* The operators below (which are not templates once this class is instanced, - * i.e.: BASE is known) can be used for implicit conversion on both sides. - * These handle operations like "vector * scalar" and "scalar * vector" by - * letting the compiler implicitly convert a scalar to a vector (assuming - * the BASE allows it). - */ - friend inline - BASE PURE operator +(const BASE& lv, const BASE& rv) { - return BASE(lv) += rv; - } - friend inline - BASE PURE operator -(const BASE& lv, const BASE& rv) { - return BASE(lv) -= rv; - } -}; - -template class BASE, typename T> -class TVecProductOperators { -public: - /* compound assignment from a another vector of the same size but different - * element type. - */ - template - BASE& operator *= (const BASE& v) { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - rhs[i] *= v[i]; - } - return rhs; - } - template - BASE& operator /= (const BASE& v) { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - rhs[i] /= v[i]; - } - return rhs; - } - - /* compound assignment from a another vector of the same type. - * These operators can be used for implicit conversion and handle operations - * like "vector *= scalar" by letting the compiler implicitly convert a scalar - * to a vector (assuming the BASE allows it). - */ - BASE& operator *= (const BASE& v) { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - rhs[i] *= v[i]; - } - return rhs; - } - BASE& operator /= (const BASE& v) { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - rhs[i] /= v[i]; - } - return rhs; - } - - /* - * NOTE: the functions below ARE NOT member methods. They are friend functions - * with they definition inlined with their declaration. This makes these - * template functions available to the compiler when (and only when) this class - * is instantiated, at which point they're only templated on the 2nd parameter - * (the first one, BASE being known). - */ - - /* The operators below handle operation between vectors of the same side - * but of a different element type. - */ - template - friend inline - BASE PURE operator *(const BASE& lv, const BASE& rv) { - return BASE(lv) *= rv; - } - template - friend inline - BASE PURE operator /(const BASE& lv, const BASE& rv) { - return BASE(lv) /= rv; - } - - /* The operators below (which are not templates once this class is instanced, - * i.e.: BASE is known) can be used for implicit conversion on both sides. - * These handle operations like "vector * scalar" and "scalar * vector" by - * letting the compiler implicitly convert a scalar to a vector (assuming - * the BASE allows it). - */ - friend inline - BASE PURE operator *(const BASE& lv, const BASE& rv) { - return BASE(lv) *= rv; - } - friend inline - BASE PURE operator /(const BASE& lv, const BASE& rv) { - return BASE(lv) /= rv; - } -}; - -/* - * TVecUnaryOperators implements unary operators on a vector of type BASE. - * - * BASE only needs to implement operator[] and size(). - * By simply inheriting from TVecUnaryOperators BASE will automatically - * get all the functionality here. - * - * These operators are implemented as friend functions of TVecUnaryOperators - */ -template class BASE, typename T> -class TVecUnaryOperators { -public: - BASE& operator ++ () { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - ++rhs[i]; - } - return rhs; - } - BASE& operator -- () { - BASE& rhs = static_cast&>(*this); - for (size_t i=0 ; i::size() ; i++) { - --rhs[i]; - } - return rhs; - } - BASE operator - () const { - BASE r(BASE::NO_INIT); - BASE const& rv(static_cast const&>(*this)); - for (size_t i=0 ; i::size() ; i++) { - r[i] = -rv[i]; - } - return r; - } -}; - - -/* - * TVecComparisonOperators implements relational/comparison operators - * on a vector of type BASE. - * - * BASE only needs to implement operator[] and size(). - * By simply inheriting from TVecComparisonOperators BASE will automatically - * get all the functionality here. - */ -template class BASE, typename T> -class TVecComparisonOperators { -public: - /* - * NOTE: the functions below ARE NOT member methods. They are friend functions - * with they definition inlined with their declaration. This makes these - * template functions available to the compiler when (and only when) this class - * is instantiated, at which point they're only templated on the 2nd parameter - * (the first one, BASE being known). - */ - template - friend inline - bool PURE operator ==(const BASE& lv, const BASE& rv) { - for (size_t i = 0; i < BASE::size(); i++) - if (lv[i] != rv[i]) - return false; - return true; - } - - template - friend inline - bool PURE operator !=(const BASE& lv, const BASE& rv) { - return !operator ==(lv, rv); - } - - template - friend inline - bool PURE operator >(const BASE& lv, const BASE& rv) { - for (size_t i = 0; i < BASE::size(); i++) - if (lv[i] <= rv[i]) - return false; - return true; - } - - template - friend inline - bool PURE operator <=(const BASE& lv, const BASE& rv) { - return !(lv > rv); - } - - template - friend inline - bool PURE operator <(const BASE& lv, const BASE& rv) { - for (size_t i = 0; i < BASE::size(); i++) - if (lv[i] >= rv[i]) - return false; - return true; - } - - template - friend inline - bool PURE operator >=(const BASE& lv, const BASE& rv) { - return !(lv < rv); - } -}; - - -/* - * TVecFunctions implements functions on a vector of type BASE. - * - * BASE only needs to implement operator[] and size(). - * By simply inheriting from TVecFunctions BASE will automatically - * get all the functionality here. - */ -template class BASE, typename T> -class TVecFunctions { -public: - /* - * NOTE: the functions below ARE NOT member methods. They are friend functions - * with they definition inlined with their declaration. This makes these - * template functions available to the compiler when (and only when) this class - * is instantiated, at which point they're only templated on the 2nd parameter - * (the first one, BASE being known). - */ - template - friend inline - T PURE dot(const BASE& lv, const BASE& rv) { - T r(0); - for (size_t i = 0; i < BASE::size(); i++) - r += lv[i]*rv[i]; - return r; - } - - friend inline - T PURE length(const BASE& lv) { - return sqrt( dot(lv, lv) ); - } - - template - friend inline - T PURE distance(const BASE& lv, const BASE& rv) { - return length(rv - lv); - } - - friend inline - BASE PURE normalize(const BASE& lv) { - return lv * (1 / length(lv)); - } -}; - -#undef PURE - -// ------------------------------------------------------------------------------------- -}; // namespace android - - -#endif /* UI_TVEC_HELPERS_H */ diff --git a/third_party/android_frameworks_native/include/ui/UiConfig.h b/third_party/android_frameworks_native/include/ui/UiConfig.h deleted file mode 100644 index fcf8ed5d6b..0000000000 --- a/third_party/android_frameworks_native/include/ui/UiConfig.h +++ /dev/null @@ -1,29 +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_UI_CONFIG_H -#define ANDROID_UI_CONFIG_H - -#include - -namespace android { - -// Append the libui configuration details to configStr. -void appendUiConfigString(String8& configStr); - -}; // namespace android - -#endif /*ANDROID_UI_CONFIG_H*/ diff --git a/third_party/android_frameworks_native/include/ui/mat4.h b/third_party/android_frameworks_native/include/ui/mat4.h deleted file mode 100644 index 4fd1effd71..0000000000 --- a/third_party/android_frameworks_native/include/ui/mat4.h +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright 2013 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 UI_MAT4_H -#define UI_MAT4_H - -#include -#include - -#include -#include - -#define TMAT_IMPLEMENTATION -#include - -#define PURE __attribute__((pure)) - -namespace android { -// ------------------------------------------------------------------------------------- - -template -class tmat44 : public TVecUnaryOperators, - public TVecComparisonOperators, - public TVecAddOperators, - public TMatProductOperators, - public TMatSquareFunctions, - public TMatDebug -{ -public: - enum no_init { NO_INIT }; - typedef T value_type; - typedef T& reference; - typedef T const& const_reference; - typedef size_t size_type; - typedef tvec4 col_type; - typedef tvec4 row_type; - - // size of a column (i.e.: number of rows) - enum { COL_SIZE = col_type::SIZE }; - static inline size_t col_size() { return COL_SIZE; } - - // size of a row (i.e.: number of columns) - enum { ROW_SIZE = row_type::SIZE }; - static inline size_t row_size() { return ROW_SIZE; } - static inline size_t size() { return row_size(); } // for TVec*<> - -private: - - /* - * <-- N columns --> - * - * a00 a10 a20 ... aN0 ^ - * a01 a11 a21 ... aN1 | - * a02 a12 a22 ... aN2 M rows - * ... | - * a0M a1M a2M ... aNM v - * - * COL_SIZE = M - * ROW_SIZE = N - * m[0] = [a00 a01 a02 ... a01M] - */ - - col_type mValue[ROW_SIZE]; - -public: - // array access - inline col_type const& operator [] (size_t i) const { return mValue[i]; } - inline col_type& operator [] (size_t i) { return mValue[i]; } - - T const* asArray() const { return &mValue[0][0]; } - - // ----------------------------------------------------------------------- - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - /* - * constructors - */ - - // leaves object uninitialized. use with caution. - explicit tmat44(no_init) { } - - // initialize to identity - tmat44(); - - // initialize to Identity*scalar. - template - explicit tmat44(U v); - - // sets the diagonal to the passed vector - template - explicit tmat44(const tvec4& rhs); - - // construct from another matrix of the same size - template - explicit tmat44(const tmat44& rhs); - - // construct from 4 column vectors - template - tmat44(const tvec4& v0, const tvec4& v1, const tvec4& v2, const tvec4& v3); - - // construct from 16 scalars - template < - typename A, typename B, typename C, typename D, - typename E, typename F, typename G, typename H, - typename I, typename J, typename K, typename L, - typename M, typename N, typename O, typename P> - tmat44( A m00, B m01, C m02, D m03, - E m10, F m11, G m12, H m13, - I m20, J m21, K m22, L m23, - M m30, N m31, O m32, P m33); - - // construct from a C array - template - explicit tmat44(U const* rawArray); - - /* - * helpers - */ - - static tmat44 ortho(T left, T right, T bottom, T top, T near, T far); - - static tmat44 frustum(T left, T right, T bottom, T top, T near, T far); - - template - static tmat44 lookAt(const tvec3& eye, const tvec3& center, const tvec3& up); - - template - static tmat44 translate(const tvec4& t); - - template - static tmat44 scale(const tvec4& s); - - template - static tmat44 rotate(A radian, const tvec3& about); -}; - -// ---------------------------------------------------------------------------------------- -// Constructors -// ---------------------------------------------------------------------------------------- - -/* - * Since the matrix code could become pretty big quickly, we don't inline most - * operations. - */ - -template -tmat44::tmat44() { - mValue[0] = col_type(1,0,0,0); - mValue[1] = col_type(0,1,0,0); - mValue[2] = col_type(0,0,1,0); - mValue[3] = col_type(0,0,0,1); -} - -template -template -tmat44::tmat44(U v) { - mValue[0] = col_type(v,0,0,0); - mValue[1] = col_type(0,v,0,0); - mValue[2] = col_type(0,0,v,0); - mValue[3] = col_type(0,0,0,v); -} - -template -template -tmat44::tmat44(const tvec4& v) { - mValue[0] = col_type(v.x,0,0,0); - mValue[1] = col_type(0,v.y,0,0); - mValue[2] = col_type(0,0,v.z,0); - mValue[3] = col_type(0,0,0,v.w); -} - -// construct from 16 scalars -template -template < - typename A, typename B, typename C, typename D, - typename E, typename F, typename G, typename H, - typename I, typename J, typename K, typename L, - typename M, typename N, typename O, typename P> -tmat44::tmat44( A m00, B m01, C m02, D m03, - E m10, F m11, G m12, H m13, - I m20, J m21, K m22, L m23, - M m30, N m31, O m32, P m33) { - mValue[0] = col_type(m00, m01, m02, m03); - mValue[1] = col_type(m10, m11, m12, m13); - mValue[2] = col_type(m20, m21, m22, m23); - mValue[3] = col_type(m30, m31, m32, m33); -} - -template -template -tmat44::tmat44(const tmat44& rhs) { - for (size_t r=0 ; r -template -tmat44::tmat44(const tvec4& v0, const tvec4& v1, const tvec4& v2, const tvec4& v3) { - mValue[0] = v0; - mValue[1] = v1; - mValue[2] = v2; - mValue[3] = v3; -} - -template -template -tmat44::tmat44(U const* rawArray) { - for (size_t r=0 ; r -tmat44 tmat44::ortho(T left, T right, T bottom, T top, T near, T far) { - tmat44 m; - m[0][0] = 2 / (right - left); - m[1][1] = 2 / (top - bottom); - m[2][2] = -2 / (far - near); - m[3][0] = -(right + left) / (right - left); - m[3][1] = -(top + bottom) / (top - bottom); - m[3][2] = -(far + near) / (far - near); - return m; -} - -template -tmat44 tmat44::frustum(T left, T right, T bottom, T top, T near, T far) { - tmat44 m; - T A = (right + left) / (right - left); - T B = (top + bottom) / (top - bottom); - T C = (far + near) / (far - near); - T D = (2 * far * near) / (far - near); - m[0][0] = (2 * near) / (right - left); - m[1][1] = (2 * near) / (top - bottom); - m[2][0] = A; - m[2][1] = B; - m[2][2] = C; - m[2][3] =-1; - m[3][2] = D; - m[3][3] = 0; - return m; -} - -template -template -tmat44 tmat44::lookAt(const tvec3& eye, const tvec3& center, const tvec3& up) { - tvec3 L(normalize(center - eye)); - tvec3 S(normalize( cross(L, up) )); - tvec3 U(cross(S, L)); - return tmat44( - tvec4( S, 0), - tvec4( U, 0), - tvec4(-L, 0), - tvec4(-eye, 1)); -} - -template -template -tmat44 tmat44::translate(const tvec4& t) { - tmat44 r; - r[3] = t; - return r; -} - -template -template -tmat44 tmat44::scale(const tvec4& s) { - tmat44 r; - r[0][0] = s[0]; - r[1][1] = s[1]; - r[2][2] = s[2]; - r[3][3] = s[3]; - return r; -} - -template -template -tmat44 tmat44::rotate(A radian, const tvec3& about) { - tmat44 rotation; - T* r = const_cast(rotation.asArray()); - T c = cos(radian); - T s = sin(radian); - if (about.x==1 && about.y==0 && about.z==0) { - r[5] = c; r[10]= c; - r[6] = s; r[9] = -s; - } else if (about.x==0 && about.y==1 && about.z==0) { - r[0] = c; r[10]= c; - r[8] = s; r[2] = -s; - } else if (about.x==0 && about.y==0 && about.z==1) { - r[0] = c; r[5] = c; - r[1] = s; r[4] = -s; - } else { - tvec3 nabout = normalize(about); - B x = nabout.x; - B y = nabout.y; - B z = nabout.z; - T nc = 1 - c; - T xy = x * y; - T yz = y * z; - T zx = z * x; - T xs = x * s; - T ys = y * s; - T zs = z * s; - r[ 0] = x*x*nc + c; r[ 4] = xy*nc - zs; r[ 8] = zx*nc + ys; - r[ 1] = xy*nc + zs; r[ 5] = y*y*nc + c; r[ 9] = yz*nc - xs; - r[ 2] = zx*nc - ys; r[ 6] = yz*nc + xs; r[10] = z*z*nc + c; - } - return rotation; -} - -// ---------------------------------------------------------------------------------------- -// Arithmetic operators outside of class -// ---------------------------------------------------------------------------------------- - -/* We use non-friend functions here to prevent the compiler from using - * implicit conversions, for instance of a scalar to a vector. The result would - * not be what the caller expects. - * - * Also note that the order of the arguments in the inner loop is important since - * it determines the output type (only relevant when T != U). - */ - -// matrix * vector, result is a vector of the same type than the input vector -template -typename tmat44::col_type PURE operator *(const tmat44& lv, const tvec4& rv) { - typename tmat44::col_type result; - for (size_t r=0 ; r::row_size() ; r++) - result += rv[r]*lv[r]; - return result; -} - -// vector * matrix, result is a vector of the same type than the input vector -template -typename tmat44::row_type PURE operator *(const tvec4& rv, const tmat44& lv) { - typename tmat44::row_type result(tmat44::row_type::NO_INIT); - for (size_t r=0 ; r::row_size() ; r++) - result[r] = dot(rv, lv[r]); - return result; -} - -// matrix * scalar, result is a matrix of the same type than the input matrix -template -tmat44 PURE operator *(const tmat44& lv, U rv) { - tmat44 result(tmat44::NO_INIT); - for (size_t r=0 ; r::row_size() ; r++) - result[r] = lv[r]*rv; - return result; -} - -// scalar * matrix, result is a matrix of the same type than the input matrix -template -tmat44 PURE operator *(U rv, const tmat44& lv) { - tmat44 result(tmat44::NO_INIT); - for (size_t r=0 ; r::row_size() ; r++) - result[r] = lv[r]*rv; - return result; -} - -// ---------------------------------------------------------------------------------------- - -/* FIXME: this should go into TMatSquareFunctions<> but for some reason - * BASE::col_type is not accessible from there (???) - */ -template -typename tmat44::col_type PURE diag(const tmat44& m) { - return matrix::diag(m); -} - -// ---------------------------------------------------------------------------------------- - -typedef tmat44 mat4; - -// ---------------------------------------------------------------------------------------- -}; // namespace android - -#undef PURE - -#endif /* UI_MAT4_H */ diff --git a/third_party/android_frameworks_native/include/ui/vec2.h b/third_party/android_frameworks_native/include/ui/vec2.h deleted file mode 100644 index c31d0e43e3..0000000000 --- a/third_party/android_frameworks_native/include/ui/vec2.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2013 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 UI_VEC2_H -#define UI_VEC2_H - -#include -#include - -#define TVEC_IMPLEMENTATION -#include - -namespace android { -// ------------------------------------------------------------------------------------- - -template -class tvec2 : public TVecProductOperators, - public TVecAddOperators, - public TVecUnaryOperators, - public TVecComparisonOperators, - public TVecFunctions -{ -public: - enum no_init { NO_INIT }; - typedef T value_type; - typedef T& reference; - typedef T const& const_reference; - typedef size_t size_type; - - union { - struct { T x, y; }; - struct { T s, t; }; - struct { T r, g; }; - }; - - enum { SIZE = 2 }; - inline static size_type size() { return SIZE; } - - // array access - inline T const& operator [] (size_t i) const { return (&x)[i]; } - inline T& operator [] (size_t i) { return (&x)[i]; } - - // ----------------------------------------------------------------------- - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - // constructors - - // leaves object uninitialized. use with caution. - explicit tvec2(no_init) { } - - // default constructor - tvec2() : x(0), y(0) { } - - // handles implicit conversion to a tvec4. must not be explicit. - template - tvec2(A v) : x(v), y(v) { } - - template - tvec2(A x, B y) : x(x), y(y) { } - - template - explicit tvec2(const tvec2& v) : x(v.x), y(v.y) { } - - template - tvec2(const Impersonator< tvec2 >& v) - : x(((const tvec2&)v).x), - y(((const tvec2&)v).y) { } -}; - -// ---------------------------------------------------------------------------------------- - -typedef tvec2 vec2; - -// ---------------------------------------------------------------------------------------- -}; // namespace android - -#endif /* UI_VEC4_H */ diff --git a/third_party/android_frameworks_native/include/ui/vec3.h b/third_party/android_frameworks_native/include/ui/vec3.h deleted file mode 100644 index dde59a96fb..0000000000 --- a/third_party/android_frameworks_native/include/ui/vec3.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2013 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 UI_VEC3_H -#define UI_VEC3_H - -#include -#include - -#include - -namespace android { -// ------------------------------------------------------------------------------------- - -template -class tvec3 : public TVecProductOperators, - public TVecAddOperators, - public TVecUnaryOperators, - public TVecComparisonOperators, - public TVecFunctions -{ -public: - enum no_init { NO_INIT }; - typedef T value_type; - typedef T& reference; - typedef T const& const_reference; - typedef size_t size_type; - - union { - struct { T x, y, z; }; - struct { T s, t, p; }; - struct { T r, g, b; }; - Impersonator< tvec2 > xy; - Impersonator< tvec2 > st; - Impersonator< tvec2 > rg; - }; - - enum { SIZE = 3 }; - inline static size_type size() { return SIZE; } - - // array access - inline T const& operator [] (size_t i) const { return (&x)[i]; } - inline T& operator [] (size_t i) { return (&x)[i]; } - - // ----------------------------------------------------------------------- - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - // constructors - // leaves object uninitialized. use with caution. - explicit tvec3(no_init) { } - - // default constructor - tvec3() : x(0), y(0), z(0) { } - - // handles implicit conversion to a tvec4. must not be explicit. - template - tvec3(A v) : x(v), y(v), z(v) { } - - template - tvec3(A x, B y, C z) : x(x), y(y), z(z) { } - - template - tvec3(const tvec2& v, B z) : x(v.x), y(v.y), z(z) { } - - template - explicit tvec3(const tvec3& v) : x(v.x), y(v.y), z(v.z) { } - - template - tvec3(const Impersonator< tvec3 >& v) - : x(((const tvec3&)v).x), - y(((const tvec3&)v).y), - z(((const tvec3&)v).z) { } - - template - tvec3(const Impersonator< tvec2 >& v, B z) - : x(((const tvec2&)v).x), - y(((const tvec2&)v).y), - z(z) { } - - // cross product works only on vectors of size 3 - template - friend inline - tvec3 __attribute__((pure)) cross(const tvec3& u, const tvec3& v) { - return tvec3( - u.y*v.z - u.z*v.y, - u.z*v.x - u.x*v.z, - u.x*v.y - u.y*v.x); - } -}; - - -// ---------------------------------------------------------------------------------------- - -typedef tvec3 vec3; - -// ---------------------------------------------------------------------------------------- -}; // namespace android - -#endif /* UI_VEC4_H */ diff --git a/third_party/android_frameworks_native/include/ui/vec4.h b/third_party/android_frameworks_native/include/ui/vec4.h deleted file mode 100644 index e03d331fb3..0000000000 --- a/third_party/android_frameworks_native/include/ui/vec4.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2013 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 UI_VEC4_H -#define UI_VEC4_H - -#include -#include - -#include - -namespace android { -// ------------------------------------------------------------------------------------- - -template -class tvec4 : public TVecProductOperators, - public TVecAddOperators, - public TVecUnaryOperators, - public TVecComparisonOperators, - public TVecFunctions -{ -public: - enum no_init { NO_INIT }; - typedef T value_type; - typedef T& reference; - typedef T const& const_reference; - typedef size_t size_type; - - union { - struct { T x, y, z, w; }; - struct { T s, t, p, q; }; - struct { T r, g, b, a; }; - Impersonator< tvec2 > xy; - Impersonator< tvec2 > st; - Impersonator< tvec2 > rg; - Impersonator< tvec3 > xyz; - Impersonator< tvec3 > stp; - Impersonator< tvec3 > rgb; - }; - - enum { SIZE = 4 }; - inline static size_type size() { return SIZE; } - - // array access - inline T const& operator [] (size_t i) const { return (&x)[i]; } - inline T& operator [] (size_t i) { return (&x)[i]; } - - // ----------------------------------------------------------------------- - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - // constructors - - // leaves object uninitialized. use with caution. - explicit tvec4(no_init) { } - - // default constructor - tvec4() : x(0), y(0), z(0), w(0) { } - - // handles implicit conversion to a tvec4. must not be explicit. - template - tvec4(A v) : x(v), y(v), z(v), w(v) { } - - template - tvec4(A x, B y, C z, D w) : x(x), y(y), z(z), w(w) { } - - template - tvec4(const tvec2& v, B z, C w) : x(v.x), y(v.y), z(z), w(w) { } - - template - tvec4(const tvec3& v, B w) : x(v.x), y(v.y), z(v.z), w(w) { } - - template - explicit tvec4(const tvec4& v) : x(v.x), y(v.y), z(v.z), w(v.w) { } - - template - tvec4(const Impersonator< tvec4 >& v) - : x(((const tvec4&)v).x), - y(((const tvec4&)v).y), - z(((const tvec4&)v).z), - w(((const tvec4&)v).w) { } - - template - tvec4(const Impersonator< tvec3 >& v, B w) - : x(((const tvec3&)v).x), - y(((const tvec3&)v).y), - z(((const tvec3&)v).z), - w(w) { } - - template - tvec4(const Impersonator< tvec2 >& v, B z, C w) - : x(((const tvec2&)v).x), - y(((const tvec2&)v).y), - z(z), - w(w) { } -}; - -// ---------------------------------------------------------------------------------------- - -typedef tvec4 vec4; - -// ---------------------------------------------------------------------------------------- -}; // namespace android - -#endif /* UI_VEC4_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/activity_recognition.h b/third_party/android_hardware_libhardware/include/hardware/activity_recognition.h deleted file mode 100644 index 30372b28f3..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/activity_recognition.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:17d8f4ac20a98be10023b8db5593f2dd9d56d0a8d9d31445826d5766af3a9537 -size 10416 diff --git a/third_party/android_hardware_libhardware/include/hardware/audio.h b/third_party/android_hardware_libhardware/include/hardware/audio.h deleted file mode 100644 index a877ce1faf..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cb785c697446189c9608e75fe48fb134f2486b2320654e10468debf17dd3a57d -size 28309 diff --git a/third_party/android_hardware_libhardware/include/hardware/audio_alsaops.h b/third_party/android_hardware_libhardware/include/hardware/audio_alsaops.h deleted file mode 100644 index b7572856ab..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio_alsaops.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:51d2e7ed6b8adcc0a95fee6298dfd5bcebd24d14f5542f1c6857984eb96cd5b2 -size 3146 diff --git a/third_party/android_hardware_libhardware/include/hardware/audio_amplifier.h b/third_party/android_hardware_libhardware/include/hardware/audio_amplifier.h deleted file mode 100644 index 5cea91b809..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio_amplifier.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1ced588b6eda1526f6fe3739026d2ee84fa0d88fc156f65b2bf9df8d100e59d5 -size 4571 diff --git a/third_party/android_hardware_libhardware/include/hardware/audio_effect.h b/third_party/android_hardware_libhardware/include/hardware/audio_effect.h deleted file mode 100644 index 58174d0cf7..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio_effect.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4f5f5ba81540b13bf50d40cd440cdded2fe8d5aca6730f21be5f406375a2bb57 -size 53231 diff --git a/third_party/android_hardware_libhardware/include/hardware/audio_policy.h b/third_party/android_hardware_libhardware/include/hardware/audio_policy.h deleted file mode 100644 index 868c904cfb..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio_policy.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5720e31e4036ae3d990b109b93279b852477bea065e56a83c76ccb3bc3679325 -size 19077 diff --git a/third_party/android_hardware_libhardware/include/hardware/bluetooth.h b/third_party/android_hardware_libhardware/include/hardware/bluetooth.h deleted file mode 100644 index c867a59018..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bluetooth.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:90eb28c9027bad6b3c95d1a79cb013c101e19f299e7531e7ce1724fe2445f4ee -size 20082 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_av.h b/third_party/android_hardware_libhardware/include/hardware/bt_av.h deleted file mode 100644 index 2d96491ba2..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_av.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2c2528b1e852a730c94a2d6f0670d3820ac0f39cfa4569c1f821c5504107c86a -size 4383 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_common_types.h b/third_party/android_hardware_libhardware/include/hardware/bt_common_types.h deleted file mode 100644 index f83fe54913..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_common_types.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4d9299cf15a39edc02e2f4c6c6b12b75811fac4afc63e3caac8d194a786d3d53 -size 1443 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_gatt.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt.h deleted file mode 100644 index 63e16f3ffd..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_gatt.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:540e3526f82d42edac0c5bd35e718abd6bf8360f3facc8d405c2177c8f80ceb7 -size 1699 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_client.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_client.h deleted file mode 100644 index 208f682657..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_client.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ae9b8107ada2b75fece62374c588823fd4c7935ac9a7aeaeef9fd17d1827873a -size 19431 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_server.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_server.h deleted file mode 100644 index ef8e3b2440..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_server.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b912e5fa8ee5a6641b9e043e37a0dae100a6c3f8420883c67d61297b1954066f -size 7891 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_types.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_types.h deleted file mode 100644 index 473f49d6e0..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_types.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:628436ed8930670eaf54d34eaedc8550e196950f12dcf5ff7374b0464dd4141d -size 1428 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hd.h b/third_party/android_hardware_libhardware/include/hardware/bt_hd.h deleted file mode 100644 index b8a59a2938..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hd.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fcef6648a215835538eb35629c8cf610aa8ea8f57b5bee9ed0d73a1ca7e17a8a -size 3917 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hf.h b/third_party/android_hardware_libhardware/include/hardware/bt_hf.h deleted file mode 100644 index 5b0613c23f..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hf.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d43a212763e3462fd685f8cfeea5a59719cea3f328d2c84f021a89a528c5b8cc -size 11329 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hf_client.h b/third_party/android_hardware_libhardware/include/hardware/bt_hf_client.h deleted file mode 100644 index 771d303c69..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hf_client.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7a14b60d2609a6952d43d17ebbe654c6a1e14b3fa93af1dcfbb5fb552445abff -size 13704 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hh.h b/third_party/android_hardware_libhardware/include/hardware/bt_hh.h deleted file mode 100644 index 0cf9f315b4..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hh.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:56673c2d2d24ac40b10cd8e0a41eb4e69e24f18357ed03246aed8cfc428f2ca0 -size 6391 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hl.h b/third_party/android_hardware_libhardware/include/hardware/bt_hl.h deleted file mode 100644 index c3fe09ea19..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hl.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ba98ac4813e5490e1bd2e348cab85f403c8a1b4495753959c6388707474eb0a5 -size 3705 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_mce.h b/third_party/android_hardware_libhardware/include/hardware/bt_mce.h deleted file mode 100644 index ebea16de51..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_mce.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cf36960dafe4ea2c86fb6ffad7cdce574d27295c3f2a815a341a41e716d97846 -size 1617 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_pan.h b/third_party/android_hardware_libhardware/include/hardware/bt_pan.h deleted file mode 100644 index 5aac0441ed..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_pan.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7d3604ca3ac6138abe6233061a80787fcd293c95ce7f3d865759332e322a427f -size 2891 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_rc.h b/third_party/android_hardware_libhardware/include/hardware/bt_rc.h deleted file mode 100644 index 45a4d62d73..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_rc.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c7df7f0ba25b08e509153a1c05dfc5fbf89da46547b1fc210a0278b6f1289d48 -size 21337 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_sdp.h b/third_party/android_hardware_libhardware/include/hardware/bt_sdp.h deleted file mode 100644 index 04c993631a..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_sdp.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6cf44476a521dd8bd6e21c6c496aa1288742a17946015c4d2b06bec961886fa7 -size 4883 diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_sock.h b/third_party/android_hardware_libhardware/include/hardware/bt_sock.h deleted file mode 100644 index 4e67bc946a..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_sock.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9a8c9fb14baee50696cd7d91fc132c952892c41b0719c74a80dfbf67c22a8580 -size 2996 diff --git a/third_party/android_hardware_libhardware/include/hardware/camera.h b/third_party/android_hardware_libhardware/include/hardware/camera.h deleted file mode 100644 index f0a53b710b..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/camera.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f470417bc0a35c37de55636bf27e72dab7715e069bdbb37d24a93df740a91bd8 -size 11242 diff --git a/third_party/android_hardware_libhardware/include/hardware/camera2.h b/third_party/android_hardware_libhardware/include/hardware/camera2.h deleted file mode 100644 index bae46de0ce..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/camera2.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:72e6a43c6f5bd61f0fac8f100a64d5a45aca3aaadee805b88b48c80202b3c474 -size 34282 diff --git a/third_party/android_hardware_libhardware/include/hardware/camera3.h b/third_party/android_hardware_libhardware/include/hardware/camera3.h deleted file mode 100644 index da7c8ebde5..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/camera3.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0b205d54ada9fa6352300b71cb5254de9a36fb038159d9824ce9cbb273bc97ac -size 143197 diff --git a/third_party/android_hardware_libhardware/include/hardware/camera_common.h b/third_party/android_hardware_libhardware/include/hardware/camera_common.h deleted file mode 100644 index 0fa776bb6b..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/camera_common.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:073b2a23176578f28dd6434465c401707fff007cee1d39e7901b695a77ec2c5d -size 39026 diff --git a/third_party/android_hardware_libhardware/include/hardware/consumerir.h b/third_party/android_hardware_libhardware/include/hardware/consumerir.h deleted file mode 100644 index ca6790921c..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/consumerir.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7b6428bf2b4e1efa11ba445263f54a59666b4d2c5b8de173ffa062fdfa725e9a -size 3542 diff --git a/third_party/android_hardware_libhardware/include/hardware/display_defs.h b/third_party/android_hardware_libhardware/include/hardware/display_defs.h deleted file mode 100644 index 396fbb01cd..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/display_defs.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bde82fe0d5148ac7bb2e908c9caa47ea0420f19ef9432ae148926e499c80080e -size 2577 diff --git a/third_party/android_hardware_libhardware/include/hardware/fb.h b/third_party/android_hardware_libhardware/include/hardware/fb.h deleted file mode 100644 index 2617e4b578..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/fb.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:507800f48213ae1f7d248596381c31fc1a7daa979ad89380d2ed6493a446d85e -size 5549 diff --git a/third_party/android_hardware_libhardware/include/hardware/fingerprint.h b/third_party/android_hardware_libhardware/include/hardware/fingerprint.h deleted file mode 100644 index 85b5620e77..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/fingerprint.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c49e6811b8b64e2b5d8d8d61ff23cec0113ec9181f01ea52576512263b913299 -size 11962 diff --git a/third_party/android_hardware_libhardware/include/hardware/fused_location.h b/third_party/android_hardware_libhardware/include/hardware/fused_location.h deleted file mode 100644 index 1ccbd1ef03..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/fused_location.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0b1cf5ae2de801352768c688f189fbce1516475e5799388ab2d9f962dc5a3f9e -size 30967 diff --git a/third_party/android_hardware_libhardware/include/hardware/gatekeeper.h b/third_party/android_hardware_libhardware/include/hardware/gatekeeper.h deleted file mode 100644 index 6a1f36c882..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/gatekeeper.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aa1dac53dee8e9ab012343a1cd7cea4d0a9c19786d0529eabc313e28954c086d -size 8011 diff --git a/third_party/android_hardware_libhardware/include/hardware/gps.h b/third_party/android_hardware_libhardware/include/hardware/gps.h deleted file mode 100644 index 38cd0c9a08..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/gps.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4df2cf269113163f1e43e1d1e544848e8a04b999f74c94695ca6eaf2afa85c49 -size 67836 diff --git a/third_party/android_hardware_libhardware/include/hardware/gralloc.h b/third_party/android_hardware_libhardware/include/hardware/gralloc.h deleted file mode 100644 index a1f97fb026..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/gralloc.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9a7e41995d44196bc5d5cd83ea896c5165fc88a851d787d5e286369f9bf21f52 -size 14872 diff --git a/third_party/android_hardware_libhardware/include/hardware/hardware.h b/third_party/android_hardware_libhardware/include/hardware/hardware.h deleted file mode 100644 index ff17b7e65b..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hardware.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:66eeee3d7fdab1230e0fc3fe709b40a88e1d19841fe190d57dd04667678782e3 -size 7900 diff --git a/third_party/android_hardware_libhardware/include/hardware/hdmi_cec.h b/third_party/android_hardware_libhardware/include/hardware/hdmi_cec.h deleted file mode 100644 index cbb4ecba20..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hdmi_cec.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4a89ebf54794151b0bbd4bbe86e1d806ecf3dcadae66a92bcaed5b298e3b26e2 -size 14538 diff --git a/third_party/android_hardware_libhardware/include/hardware/hw_auth_token.h b/third_party/android_hardware_libhardware/include/hardware/hw_auth_token.h deleted file mode 100644 index 71f08028b2..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hw_auth_token.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c680778154f23346ff2ec9af0edbf0e2d2f07ff7b84b348bc0780e1058b3461a -size 1653 diff --git a/third_party/android_hardware_libhardware/include/hardware/hwcomposer.h b/third_party/android_hardware_libhardware/include/hardware/hwcomposer.h deleted file mode 100644 index eae282a52b..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hwcomposer.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:34d701d4324ae78278fec21ee3a474338a252ae3218b8d22e4dbf65c324f04ea -size 35393 diff --git a/third_party/android_hardware_libhardware/include/hardware/hwcomposer_defs.h b/third_party/android_hardware_libhardware/include/hardware/hwcomposer_defs.h deleted file mode 100644 index 55281f87ca..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hwcomposer_defs.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:95b1363862409edd5b6e397d27e85c71e7b2d02b5839e26d6252bc34e14ea5c2 -size 9015 diff --git a/third_party/android_hardware_libhardware/include/hardware/input.h b/third_party/android_hardware_libhardware/include/hardware/input.h deleted file mode 100644 index 73e160e1fd..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/input.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:24a57558f87aa194b3b39eb7f8e1514063d24f5048b34da1a7dc66260edcaa22 -size 19412 diff --git a/third_party/android_hardware_libhardware/include/hardware/keymaster0.h b/third_party/android_hardware_libhardware/include/hardware/keymaster0.h deleted file mode 100644 index 86a7dc387f..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/keymaster0.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:171d311ac207e8f0919afc2a7881897e6d29937be7f1ac2db4ecd710284d1325 -size 5095 diff --git a/third_party/android_hardware_libhardware/include/hardware/keymaster1.h b/third_party/android_hardware_libhardware/include/hardware/keymaster1.h deleted file mode 100644 index f63f551738..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/keymaster1.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:17b728f8184dc06fae474c11b2da64a5c47af03aa02ab1b9c1c0ccee589d580a -size 28267 diff --git a/third_party/android_hardware_libhardware/include/hardware/keymaster_common.h b/third_party/android_hardware_libhardware/include/hardware/keymaster_common.h deleted file mode 100644 index 1d88d6fba5..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/keymaster_common.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c7502900ae15a0f55e9945156ee2f84716a4ae75a69d851ae1c196bdfb97d30b -size 4955 diff --git a/third_party/android_hardware_libhardware/include/hardware/keymaster_defs.h b/third_party/android_hardware_libhardware/include/hardware/keymaster_defs.h deleted file mode 100644 index e8a82419cc..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/keymaster_defs.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8dfb69fea2ee98c2d8232c1f42a040bed300a2dd2f74771f1ab732140a5e413c -size 22010 diff --git a/third_party/android_hardware_libhardware/include/hardware/lights.h b/third_party/android_hardware_libhardware/include/hardware/lights.h deleted file mode 100644 index 9e0d26eac6..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/lights.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f29fa3b037b8dc5f923a7939e3b011f9860e271176b0776c2643b1a708a401ae -size 4416 diff --git a/third_party/android_hardware_libhardware/include/hardware/local_time_hal.h b/third_party/android_hardware_libhardware/include/hardware/local_time_hal.h deleted file mode 100644 index 4739e7f452..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/local_time_hal.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:826e6e1b87cb40a010b1009827e93cee33251770d1bbcd70e7a546dbf29e9901 -size 3849 diff --git a/third_party/android_hardware_libhardware/include/hardware/memtrack.h b/third_party/android_hardware_libhardware/include/hardware/memtrack.h deleted file mode 100644 index 7a6664081c..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/memtrack.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:190d5111194ac4fc871365dcbcc089dea2ce17bbe7f0a93d2c05ff844615a6da -size 6162 diff --git a/third_party/android_hardware_libhardware/include/hardware/nfc.h b/third_party/android_hardware_libhardware/include/hardware/nfc.h deleted file mode 100644 index cad6cbe1d3..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/nfc.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:378f92a186935e457354fba34b4f381b175199f3ad258c44ed1e436423a16697 -size 10061 diff --git a/third_party/android_hardware_libhardware/include/hardware/nfc_tag.h b/third_party/android_hardware_libhardware/include/hardware/nfc_tag.h deleted file mode 100644 index 6a940d8161..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/nfc_tag.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:42a9d32d2a7dccc4148e98c91242a6451bb42a466daf2895bfb20dace5052893 -size 2919 diff --git a/third_party/android_hardware_libhardware/include/hardware/power.h b/third_party/android_hardware_libhardware/include/hardware/power.h deleted file mode 100644 index 4c38ad46a3..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/power.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:401ce17409bcf761ac963f8f9d54b9d1d26df73f6a4b66ed438e223dd1cef917 -size 6579 diff --git a/third_party/android_hardware_libhardware/include/hardware/qemu_pipe.h b/third_party/android_hardware_libhardware/include/hardware/qemu_pipe.h deleted file mode 100644 index d61d8ca96c..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/qemu_pipe.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:37b3043a9cf447656b2d5a2d5cf2f8397f7248f2fef0ad5e1d87032eba4931d7 -size 2837 diff --git a/third_party/android_hardware_libhardware/include/hardware/qemud.h b/third_party/android_hardware_libhardware/include/hardware/qemud.h deleted file mode 100644 index ee6a04241a..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/qemud.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aa1174926f4316838fc87bdad7cca864570de8aad4906c5fe1f324f5385e78be -size 4260 diff --git a/third_party/android_hardware_libhardware/include/hardware/radio.h b/third_party/android_hardware_libhardware/include/hardware/radio.h deleted file mode 100644 index 2add85077c..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/radio.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f0106a08095506dfefdc828b435fc20f7ac4f958942639246d2e979690c8d5b4 -size 10615 diff --git a/third_party/android_hardware_libhardware/include/hardware/sensors.h b/third_party/android_hardware_libhardware/include/hardware/sensors.h deleted file mode 100644 index 915551171b..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/sensors.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:da5fd6117d9d4724a15e41e9ce2d25b98546d20dbae9016f5b22b03276707216 -size 40148 diff --git a/third_party/android_hardware_libhardware/include/hardware/sound_trigger.h b/third_party/android_hardware_libhardware/include/hardware/sound_trigger.h deleted file mode 100644 index 7aef197606..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/sound_trigger.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9256a4e56a9c6955f41aaaae0c648d721d3b07c1304e854c51a8f16f5eae019d -size 4952 diff --git a/third_party/android_hardware_libhardware/include/hardware/tv_input.h b/third_party/android_hardware_libhardware/include/hardware/tv_input.h deleted file mode 100644 index e072f6da59..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/tv_input.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aa3e81c7f05c07efd4653615138eabfdd2f85c1ae112af527088f7b133a540a2 -size 13839 diff --git a/third_party/android_hardware_libhardware/include/hardware/vibrator.h b/third_party/android_hardware_libhardware/include/hardware/vibrator.h deleted file mode 100644 index 9b869d072f..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/vibrator.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d4083d6b4d7386e1c4135edc761a06d996101917e3e808ee05f73eb734968879 -size 2301 diff --git a/third_party/android_hardware_libhardware/include/hardware/wipower.h b/third_party/android_hardware_libhardware/include/hardware/wipower.h deleted file mode 100644 index 36cd3ecbb6..0000000000 --- a/third_party/android_hardware_libhardware/include/hardware/wipower.h +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:72d28227594e70c0e04f84a3e0aa7ab0916c2b36b2aa57a1cbd88f56b3a65905 -size 3697 diff --git a/third_party/android_system_core/include/cutils/android_reboot.h b/third_party/android_system_core/include/cutils/android_reboot.h deleted file mode 100644 index a3861a02dc..0000000000 --- a/third_party/android_system_core/include/cutils/android_reboot.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2011, 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 __CUTILS_ANDROID_REBOOT_H__ -#define __CUTILS_ANDROID_REBOOT_H__ - -#include - -__BEGIN_DECLS - -/* Commands */ -#define ANDROID_RB_RESTART 0xDEAD0001 -#define ANDROID_RB_POWEROFF 0xDEAD0002 -#define ANDROID_RB_RESTART2 0xDEAD0003 - -/* Properties */ -#define ANDROID_RB_PROPERTY "sys.powerctl" - -int android_reboot(int cmd, int flags, const char *arg); -int android_reboot_with_callback( - int cmd, int flags, const char *arg, - void (*cb_on_remount)(const struct mntent*)); - -__END_DECLS - -#endif /* __CUTILS_ANDROID_REBOOT_H__ */ diff --git a/third_party/android_system_core/include/cutils/aref.h b/third_party/android_system_core/include/cutils/aref.h deleted file mode 100644 index 3bd36ea04c..0000000000 --- a/third_party/android_system_core/include/cutils/aref.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2013 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 _CUTILS_AREF_H_ -#define _CUTILS_AREF_H_ - -#include -#include - -#include - -__BEGIN_DECLS - -#define AREF_TO_ITEM(aref, container, member) \ - (container *) (((char*) (aref)) - offsetof(container, member)) - -struct aref -{ - volatile int32_t count; -}; - -static inline void aref_init(struct aref *r) -{ - r->count = 1; -} - -static inline int32_t aref_count(struct aref *r) -{ - return r->count; -} - -static inline void aref_get(struct aref *r) -{ - android_atomic_inc(&r->count); -} - -static inline void aref_put(struct aref *r, void (*release)(struct aref *)) -{ - if (android_atomic_dec(&r->count) == 1) - release(r); -} - -__END_DECLS - -#endif // _CUTILS_AREF_H_ diff --git a/third_party/android_system_core/include/cutils/ashmem.h b/third_party/android_system_core/include/cutils/ashmem.h deleted file mode 100644 index 25b233e6a1..0000000000 --- a/third_party/android_system_core/include/cutils/ashmem.h +++ /dev/null @@ -1,45 +0,0 @@ -/* cutils/ashmem.h - ** - ** Copyright 2008 The Android Open Source Project - ** - ** This file is dual licensed. It may be redistributed and/or modified - ** under the terms of the Apache 2.0 License OR version 2 of the GNU - ** General Public License. - */ - -#ifndef _CUTILS_ASHMEM_H -#define _CUTILS_ASHMEM_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int ashmem_create_region(const char *name, size_t size); -int ashmem_set_prot_region(int fd, int prot); -int ashmem_pin_region(int fd, size_t offset, size_t len); -int ashmem_unpin_region(int fd, size_t offset, size_t len); -int ashmem_get_size_region(int fd); - -#ifdef __cplusplus -} -#endif - -#ifndef __ASHMEMIOC /* in case someone included too */ - -#define ASHMEM_NAME_LEN 256 - -#define ASHMEM_NAME_DEF "dev/ashmem" - -/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ -#define ASHMEM_NOT_PURGED 0 -#define ASHMEM_WAS_PURGED 1 - -/* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ -#define ASHMEM_IS_UNPINNED 0 -#define ASHMEM_IS_PINNED 1 - -#endif /* ! __ASHMEMIOC */ - -#endif /* _CUTILS_ASHMEM_H */ diff --git a/third_party/android_system_core/include/cutils/atomic.h b/third_party/android_system_core/include/cutils/atomic.h deleted file mode 100644 index ded972acb2..0000000000 --- a/third_party/android_system_core/include/cutils/atomic.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (C) 2007 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_CUTILS_ATOMIC_H -#define ANDROID_CUTILS_ATOMIC_H - -#include -#include -#include - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE static inline -#endif - -/* - * A handful of basic atomic operations. - * THESE ARE HERE FOR LEGACY REASONS ONLY. AVOID. - * - * PREFERRED ALTERNATIVES: - * - Use C++/C/pthread locks/mutexes whenever there is not a - * convincing reason to do otherwise. Note that very clever and - * complicated, but correct, lock-free code is often slower than - * using locks, especially where nontrivial data structures - * are involved. - * - C11 stdatomic.h. - * - Where supported, C++11 std::atomic . - * - * PLEASE STOP READING HERE UNLESS YOU ARE TRYING TO UNDERSTAND - * OR UPDATE OLD CODE. - * - * The "acquire" and "release" terms can be defined intuitively in terms - * of the placement of memory barriers in a simple lock implementation: - * - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds - * - barrier - * - [do work] - * - barrier - * - store(lock-is-free) - * In very crude terms, the initial (acquire) barrier prevents any of the - * "work" from happening before the lock is held, and the later (release) - * barrier ensures that all of the work happens before the lock is released. - * (Think of cached writes, cache read-ahead, and instruction reordering - * around the CAS and store instructions.) - * - * The barriers must apply to both the compiler and the CPU. Note it is - * legal for instructions that occur before an "acquire" barrier to be - * moved down below it, and for instructions that occur after a "release" - * barrier to be moved up above it. - * - * The ARM-driven implementation we use here is short on subtlety, - * and actually requests a full barrier from the compiler and the CPU. - * The only difference between acquire and release is in whether they - * are issued before or after the atomic operation with which they - * are associated. To ease the transition to C/C++ atomic intrinsics, - * you should not rely on this, and instead assume that only the minimal - * acquire/release protection is provided. - * - * NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries. - * If they are not, atomicity is not guaranteed. - */ - -/* - * Basic arithmetic and bitwise operations. These all provide a - * barrier with "release" ordering, and return the previous value. - * - * These have the same characteristics (e.g. what happens on overflow) - * as the equivalent non-atomic C operations. - */ -ANDROID_ATOMIC_INLINE -int32_t android_atomic_inc(volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - /* Int32_t, if it exists, is the same as int_least32_t. */ - return atomic_fetch_add_explicit(a, 1, memory_order_release); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_dec(volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_fetch_sub_explicit(a, 1, memory_order_release); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_fetch_add_explicit(a, value, memory_order_release); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_and(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_fetch_and_explicit(a, value, memory_order_release); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_or(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_fetch_or_explicit(a, value, memory_order_release); -} - -/* - * Perform an atomic load with "acquire" or "release" ordering. - * - * Note that the notion of a "release" ordering for a load does not - * really fit into the C11 or C++11 memory model. The extra ordering - * is normally observable only by code using memory_order_relaxed - * atomics, or data races. In the rare cases in which such ordering - * is called for, use memory_order_relaxed atomics and a leading - * atomic_thread_fence (typically with memory_order_acquire, - * not memory_order_release!) instead. If you do not understand - * this comment, you are in the vast majority, and should not be - * using release loads or replacing them with anything other than - * locks or default sequentially consistent atomics. - */ -ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_load_explicit(a, memory_order_acquire); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - atomic_thread_fence(memory_order_seq_cst); - /* Any reasonable clients of this interface would probably prefer */ - /* something weaker. But some remaining clients seem to be */ - /* abusing this API in strange ways, e.g. by using it as a fence. */ - /* Thus we are conservative until we can get rid of remaining */ - /* clients (and this function). */ - return atomic_load_explicit(a, memory_order_relaxed); -} - -/* - * Perform an atomic store with "acquire" or "release" ordering. - * - * Note that the notion of an "acquire" ordering for a store does not - * really fit into the C11 or C++11 memory model. The extra ordering - * is normally observable only by code using memory_order_relaxed - * atomics, or data races. In the rare cases in which such ordering - * is called for, use memory_order_relaxed atomics and a trailing - * atomic_thread_fence (typically with memory_order_release, - * not memory_order_acquire!) instead. - */ -ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - atomic_store_explicit(a, value, memory_order_relaxed); - atomic_thread_fence(memory_order_seq_cst); - /* Again overly conservative to accomodate weird clients. */ -} - -ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - atomic_store_explicit(a, value, memory_order_release); -} - -/* - * Compare-and-set operation with "acquire" or "release" ordering. - * - * This returns zero if the new value was successfully stored, which will - * only happen when *addr == oldvalue. - * - * (The return value is inverted from implementations on other platforms, - * but matches the ARM ldrex/strex result.) - * - * Implementations that use the release CAS in a loop may be less efficient - * than possible, because we re-issue the memory barrier on each iteration. - */ -ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, - volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return (int)(!atomic_compare_exchange_strong_explicit( - a, &oldvalue, newvalue, - memory_order_acquire, - memory_order_acquire)); -} - -ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, - volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return (int)(!atomic_compare_exchange_strong_explicit( - a, &oldvalue, newvalue, - memory_order_release, - memory_order_relaxed)); -} - -/* - * Fence primitives. - */ -ANDROID_ATOMIC_INLINE -void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); - /* Could probably also be: */ - /* atomic_signal_fence(memory_order_seq_cst); */ -} - -ANDROID_ATOMIC_INLINE -void android_memory_barrier(void) -{ - atomic_thread_fence(memory_order_seq_cst); -} - -/* - * Aliases for code using an older version of this header. These are now - * deprecated and should not be used. The definitions will be removed - * in a future release. - */ -#define android_atomic_write android_atomic_release_store -#define android_atomic_cmpxchg android_atomic_release_cas - -#endif // ANDROID_CUTILS_ATOMIC_H diff --git a/third_party/android_system_core/include/cutils/bitops.h b/third_party/android_system_core/include/cutils/bitops.h deleted file mode 100644 index 045830d90b..0000000000 --- a/third_party/android_system_core/include/cutils/bitops.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2011 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 __CUTILS_BITOPS_H -#define __CUTILS_BITOPS_H - -#include -#include -#include -#include - -__BEGIN_DECLS - -/* - * Bitmask Operations - * - * Note this doesn't provide any locking/exclusion, and isn't atomic. - * Additionally no bounds checking is done on the bitmask array. - * - * Example: - * - * int num_resources; - * unsigned int resource_bits[BITS_TO_WORDS(num_resources)]; - * bitmask_init(resource_bits, num_resources); - * ... - * int bit = bitmask_ffz(resource_bits, num_resources); - * bitmask_set(resource_bits, bit); - * ... - * if (bitmask_test(resource_bits, bit)) { ... } - * ... - * bitmask_clear(resource_bits, bit); - * - */ - -#define BITS_PER_WORD (sizeof(unsigned int) * 8) -#define BITS_TO_WORDS(x) (((x) + BITS_PER_WORD - 1) / BITS_PER_WORD) -#define BIT_IN_WORD(x) ((x) % BITS_PER_WORD) -#define BIT_WORD(x) ((x) / BITS_PER_WORD) -#define BIT_MASK(x) (1 << BIT_IN_WORD(x)) - -static inline void bitmask_init(unsigned int *bitmask, int num_bits) -{ - memset(bitmask, 0, BITS_TO_WORDS(num_bits)*sizeof(unsigned int)); -} - -static inline int bitmask_ffz(unsigned int *bitmask, int num_bits) -{ - int bit, result; - size_t i; - - for (i = 0; i < BITS_TO_WORDS(num_bits); i++) { - bit = ffs(~bitmask[i]); - if (bit) { - // ffs is 1-indexed, return 0-indexed result - bit--; - result = BITS_PER_WORD * i + bit; - if (result >= num_bits) - return -1; - return result; - } - } - return -1; -} - -static inline int bitmask_weight(unsigned int *bitmask, int num_bits) -{ - size_t i; - int weight = 0; - - for (i = 0; i < BITS_TO_WORDS(num_bits); i++) - weight += __builtin_popcount(bitmask[i]); - return weight; -} - -static inline void bitmask_set(unsigned int *bitmask, int bit) -{ - bitmask[BIT_WORD(bit)] |= BIT_MASK(bit); -} - -static inline void bitmask_clear(unsigned int *bitmask, int bit) -{ - bitmask[BIT_WORD(bit)] &= ~BIT_MASK(bit); -} - -static inline bool bitmask_test(unsigned int *bitmask, int bit) -{ - return bitmask[BIT_WORD(bit)] & BIT_MASK(bit); -} - -static inline int popcount(unsigned int x) -{ - return __builtin_popcount(x); -} - -static inline int popcountl(unsigned long x) -{ - return __builtin_popcountl(x); -} - -static inline int popcountll(unsigned long long x) -{ - return __builtin_popcountll(x); -} - -__END_DECLS - -#endif /* __CUTILS_BITOPS_H */ diff --git a/third_party/android_system_core/include/cutils/compiler.h b/third_party/android_system_core/include/cutils/compiler.h deleted file mode 100644 index 70f884a1e7..0000000000 --- a/third_party/android_system_core/include/cutils/compiler.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2009 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_CUTILS_COMPILER_H -#define ANDROID_CUTILS_COMPILER_H - -/* - * helps the compiler's optimizer predicting branches - */ - -#ifdef __cplusplus -# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) -# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) -#else -# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) -# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) -#endif - -/** - * exports marked symbols - * - * if used on a C++ class declaration, this macro must be inserted - * after the "class" keyword. For instance: - * - * template - * class ANDROID_API Singleton { } - */ - -#define ANDROID_API __attribute__((visibility("default"))) - -#endif // ANDROID_CUTILS_COMPILER_H diff --git a/third_party/android_system_core/include/cutils/config_utils.h b/third_party/android_system_core/include/cutils/config_utils.h deleted file mode 100644 index 2dea6f19fa..0000000000 --- a/third_party/android_system_core/include/cutils/config_utils.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2006 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 __CUTILS_CONFIG_UTILS_H -#define __CUTILS_CONFIG_UTILS_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct cnode cnode; - - -struct cnode -{ - cnode *next; - cnode *first_child; - cnode *last_child; - const char *name; - const char *value; -}; - -/* parse a text string into a config node tree */ -void config_load(cnode *root, char *data); - -/* parse a file into a config node tree */ -void config_load_file(cnode *root, const char *fn); - -/* create a single config node */ -cnode* config_node(const char *name, const char *value); - -/* locate a named child of a config node */ -cnode* config_find(cnode *root, const char *name); - -/* look up a child by name and return the boolean value */ -int config_bool(cnode *root, const char *name, int _default); - -/* look up a child by name and return the string value */ -const char* config_str(cnode *root, const char *name, const char *_default); - -/* add a named child to a config node (or modify it if it already exists) */ -void config_set(cnode *root, const char *name, const char *value); - -/* free a config node tree */ -void config_free(cnode *root); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/third_party/android_system_core/include/cutils/debugger.h b/third_party/android_system_core/include/cutils/debugger.h deleted file mode 100644 index 285e1afcd7..0000000000 --- a/third_party/android_system_core/include/cutils/debugger.h +++ /dev/null @@ -1,77 +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 __CUTILS_DEBUGGER_H -#define __CUTILS_DEBUGGER_H - -#include -#include - -__BEGIN_DECLS - -#define DEBUGGER_SOCKET_NAME "android:debuggerd" -#define DEBUGGER32_SOCKET_NAME "android:debuggerd32" -#define DEBUGGER64_SOCKET_NAME DEBUGGER_SOCKET_NAME - -typedef enum { - // dump a crash - DEBUGGER_ACTION_CRASH, - // dump a tombstone file - DEBUGGER_ACTION_DUMP_TOMBSTONE, - // dump a backtrace only back to the socket - DEBUGGER_ACTION_DUMP_BACKTRACE, -} debugger_action_t; - -// Make sure that all values have a fixed size so that this structure -// is the same for 32 bit and 64 bit processes. -// NOTE: Any changes to this structure must also be reflected in -// bionic/linker/debugger.cpp. -typedef struct __attribute__((packed)) { - int32_t action; - pid_t tid; - uint64_t abort_msg_address; - int32_t original_si_code; -} debugger_msg_t; - -/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). - * Stores the tombstone path in the provided buffer. - * Returns 0 on success, -1 on error. - */ -int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen); - -/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). - * Stores the tombstone path in the provided buffer. - * If reading debugger data from debuggerd ever takes longer than timeout_secs - * seconds, then stop and return an error. - * Returns 0 on success, -1 on error. - */ -int dump_tombstone_timeout(pid_t tid, char* pathbuf, size_t pathlen, int timeout_secs); - -/* Dumps a process backtrace only to the specified file (requires root). - * Returns 0 on success, -1 on error. - */ -int dump_backtrace_to_file(pid_t tid, int fd); - -/* Dumps a process backtrace only to the specified file (requires root). - * If reading debugger data from debuggerd ever takes longer than timeout_secs - * seconds, then stop and return an error. - * Returns 0 on success, -1 on error. - */ -int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs); - -__END_DECLS - -#endif /* __CUTILS_DEBUGGER_H */ diff --git a/third_party/android_system_core/include/cutils/fs.h b/third_party/android_system_core/include/cutils/fs.h deleted file mode 100644 index 70f0b92919..0000000000 --- a/third_party/android_system_core/include/cutils/fs.h +++ /dev/null @@ -1,71 +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 __CUTILS_FS_H -#define __CUTILS_FS_H - -#include -#include - -/* - * TEMP_FAILURE_RETRY is defined by some, but not all, versions of - * . (Alas, it is not as standard as we'd hoped!) So, if it's - * not already defined, then define it here. - */ -#ifndef TEMP_FAILURE_RETRY -/* Used to retry syscalls that can return EINTR. */ -#define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ - do { \ - _rc = (exp); \ - } while (_rc == -1 && errno == EINTR); \ - _rc; }) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Ensure that directory exists with given mode and owners. - */ -extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); - -/* - * Read single plaintext integer from given file, correctly handling files - * partially written with fs_write_atomic_int(). - */ -extern int fs_read_atomic_int(const char* path, int* value); - -/* - * Write single plaintext integer to given file, creating backup while - * in progress. - */ -extern int fs_write_atomic_int(const char* path, int value); - -/* - * Ensure that all directories along given path exist, creating parent - * directories as needed. Validates that given path is absolute and that - * it contains no relative "." or ".." paths or symlinks. Last path segment - * is treated as filename and ignored, unless the path ends with "/". - */ -extern int fs_mkdirs(const char* path, mode_t mode); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_FS_H */ diff --git a/third_party/android_system_core/include/cutils/hashmap.h b/third_party/android_system_core/include/cutils/hashmap.h deleted file mode 100644 index 5cb344c152..0000000000 --- a/third_party/android_system_core/include/cutils/hashmap.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -/** - * Hash map. - */ - -#ifndef __HASHMAP_H -#define __HASHMAP_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** A hash map. */ -typedef struct Hashmap Hashmap; - -/** - * Creates a new hash map. Returns NULL if memory allocation fails. - * - * @param initialCapacity number of expected entries - * @param hash function which hashes keys - * @param equals function which compares keys for equality - */ -Hashmap* hashmapCreate(size_t initialCapacity, - int (*hash)(void* key), bool (*equals)(void* keyA, void* keyB)); - -/** - * Frees the hash map. Does not free the keys or values themselves. - */ -void hashmapFree(Hashmap* map); - -/** - * Hashes the memory pointed to by key with the given size. Useful for - * implementing hash functions. - */ -int hashmapHash(void* key, size_t keySize); - -/** - * Puts value for the given key in the map. Returns pre-existing value if - * any. - * - * If memory allocation fails, this function returns NULL, the map's size - * does not increase, and errno is set to ENOMEM. - */ -void* hashmapPut(Hashmap* map, void* key, void* value); - -/** - * Gets a value from the map. Returns NULL if no entry for the given key is - * found or if the value itself is NULL. - */ -void* hashmapGet(Hashmap* map, void* key); - -/** - * Returns true if the map contains an entry for the given key. - */ -bool hashmapContainsKey(Hashmap* map, void* key); - -/** - * Gets the value for a key. If a value is not found, this function gets a - * value and creates an entry using the given callback. - * - * If memory allocation fails, the callback is not called, this function - * returns NULL, and errno is set to ENOMEM. - */ -void* hashmapMemoize(Hashmap* map, void* key, - void* (*initialValue)(void* key, void* context), void* context); - -/** - * Removes an entry from the map. Returns the removed value or NULL if no - * entry was present. - */ -void* hashmapRemove(Hashmap* map, void* key); - -/** - * Gets the number of entries in this map. - */ -size_t hashmapSize(Hashmap* map); - -/** - * Invokes the given callback on each entry in the map. Stops iterating if - * the callback returns false. - */ -void hashmapForEach(Hashmap* map, - bool (*callback)(void* key, void* value, void* context), - void* context); - -/** - * Concurrency support. - */ - -/** - * Locks the hash map so only the current thread can access it. - */ -void hashmapLock(Hashmap* map); - -/** - * Unlocks the hash map so other threads can access it. - */ -void hashmapUnlock(Hashmap* map); - -/** - * Key utilities. - */ - -/** - * Hashes int keys. 'key' is a pointer to int. - */ -int hashmapIntHash(void* key); - -/** - * Compares two int keys for equality. - */ -bool hashmapIntEquals(void* keyA, void* keyB); - -/** - * For debugging. - */ - -/** - * Gets current capacity. - */ -size_t hashmapCurrentCapacity(Hashmap* map); - -/** - * Counts the number of entry collisions. - */ -size_t hashmapCountCollisions(Hashmap* map); - -#ifdef __cplusplus -} -#endif - -#endif /* __HASHMAP_H */ diff --git a/third_party/android_system_core/include/cutils/iosched_policy.h b/third_party/android_system_core/include/cutils/iosched_policy.h deleted file mode 100644 index 25b87bac0a..0000000000 --- a/third_party/android_system_core/include/cutils/iosched_policy.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2007 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 __CUTILS_IOSCHED_POLICY_H -#define __CUTILS_IOSCHED_POLICY_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - IoSchedClass_NONE, - IoSchedClass_RT, - IoSchedClass_BE, - IoSchedClass_IDLE, -} IoSchedClass; - -extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); -extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); - -extern int android_set_rt_ioprio(int pid, int rt); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_IOSCHED_POLICY_H */ diff --git a/third_party/android_system_core/include/cutils/jstring.h b/third_party/android_system_core/include/cutils/jstring.h deleted file mode 100644 index a3426081a0..0000000000 --- a/third_party/android_system_core/include/cutils/jstring.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2006 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 __CUTILS_STRING16_H -#define __CUTILS_STRING16_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if __STDC_VERSION__ < 201112L && __cplusplus < 201103L - typedef uint16_t char16_t; -#endif - // otherwise char16_t is a keyword with the right semantics - -extern char * strndup16to8 (const char16_t* s, size_t n); -extern size_t strnlen16to8 (const char16_t* s, size_t n); -extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); - -extern char16_t * strdup8to16 (const char* s, size_t *out_len); -extern size_t strlen8to16 (const char* utf8Str); -extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); -extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, - size_t *out_len); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_STRING16_H */ diff --git a/third_party/android_system_core/include/cutils/klog.h b/third_party/android_system_core/include/cutils/klog.h deleted file mode 100644 index 295d62be37..0000000000 --- a/third_party/android_system_core/include/cutils/klog.h +++ /dev/null @@ -1,51 +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 _CUTILS_KLOG_H_ -#define _CUTILS_KLOG_H_ - -#include -#include -#include - -__BEGIN_DECLS - -void klog_init(void); -int klog_get_level(void); -void klog_set_level(int level); -/* TODO: void klog_close(void); - and make klog_fd users thread safe. */ - -void klog_write(int level, const char *fmt, ...) - __attribute__ ((format(printf, 2, 3))); -void klog_writev(int level, const struct iovec* iov, int iov_count); - -__END_DECLS - -#define KLOG_ERROR_LEVEL 3 -#define KLOG_WARNING_LEVEL 4 -#define KLOG_NOTICE_LEVEL 5 -#define KLOG_INFO_LEVEL 6 -#define KLOG_DEBUG_LEVEL 7 - -#define KLOG_ERROR(tag,x...) klog_write(KLOG_ERROR_LEVEL, "<3>" tag ": " x) -#define KLOG_WARNING(tag,x...) klog_write(KLOG_WARNING_LEVEL, "<4>" tag ": " x) -#define KLOG_NOTICE(tag,x...) klog_write(KLOG_NOTICE_LEVEL, "<5>" tag ": " x) -#define KLOG_INFO(tag,x...) klog_write(KLOG_INFO_LEVEL, "<6>" tag ": " x) -#define KLOG_DEBUG(tag,x...) klog_write(KLOG_DEBUG_LEVEL, "<7>" tag ": " x) - -#define KLOG_DEFAULT_LEVEL 3 /* messages <= this level are logged */ - -#endif diff --git a/third_party/android_system_core/include/cutils/list.h b/third_party/android_system_core/include/cutils/list.h deleted file mode 100644 index 4ba2cfd499..0000000000 --- a/third_party/android_system_core/include/cutils/list.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2008-2013 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 _CUTILS_LIST_H_ -#define _CUTILS_LIST_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -struct listnode -{ - struct listnode *next; - struct listnode *prev; -}; - -#define node_to_item(node, container, member) \ - (container *) (((char*) (node)) - offsetof(container, member)) - -#define list_declare(name) \ - struct listnode name = { \ - .next = &name, \ - .prev = &name, \ - } - -#define list_for_each(node, list) \ - for (node = (list)->next; node != (list); node = node->next) - -#define list_for_each_reverse(node, list) \ - for (node = (list)->prev; node != (list); node = node->prev) - -#define list_for_each_safe(node, n, list) \ - for (node = (list)->next, n = node->next; \ - node != (list); \ - node = n, n = node->next) - -static inline void list_init(struct listnode *node) -{ - node->next = node; - node->prev = node; -} - -static inline void list_add_tail(struct listnode *head, struct listnode *item) -{ - item->next = head; - item->prev = head->prev; - head->prev->next = item; - head->prev = item; -} - -static inline void list_add_head(struct listnode *head, struct listnode *item) -{ - item->next = head->next; - item->prev = head; - head->next->prev = item; - head->next = item; -} - -static inline void list_remove(struct listnode *item) -{ - item->next->prev = item->prev; - item->prev->next = item->next; -} - -#define list_empty(list) ((list) == (list)->next) -#define list_head(list) ((list)->next) -#define list_tail(list) ((list)->prev) - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif diff --git a/third_party/android_system_core/include/cutils/log.h b/third_party/android_system_core/include/cutils/log.h deleted file mode 100644 index 0e0248e50f..0000000000 --- a/third_party/android_system_core/include/cutils/log.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/third_party/android_system_core/include/cutils/memory.h b/third_party/android_system_core/include/cutils/memory.h deleted file mode 100644 index 4d26882556..0000000000 --- a/third_party/android_system_core/include/cutils/memory.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2006 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_CUTILS_MEMORY_H -#define ANDROID_CUTILS_MEMORY_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* size is given in bytes and must be multiple of 2 */ -void android_memset16(uint16_t* dst, uint16_t value, size_t size); - -/* size is given in bytes and must be multiple of 4 */ -void android_memset32(uint32_t* dst, uint32_t value, size_t size); - -#if defined(__GLIBC__) || defined(_WIN32) -/* Declaration of strlcpy() for platforms that don't already have it. */ -size_t strlcpy(char *dst, const char *src, size_t size); -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // ANDROID_CUTILS_MEMORY_H diff --git a/third_party/android_system_core/include/cutils/misc.h b/third_party/android_system_core/include/cutils/misc.h deleted file mode 100644 index 0de505f277..0000000000 --- a/third_party/android_system_core/include/cutils/misc.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2006 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 __CUTILS_MISC_H -#define __CUTILS_MISC_H - -#ifdef __cplusplus -extern "C" { -#endif - - /* Load an entire file into a malloc'd chunk of memory - * that is length_of_file + 1 (null terminator). If - * sz is non-zero, return the size of the file via sz. - * Returns 0 on failure. - */ -extern void *load_file(const char *fn, unsigned *sz); - - /* This is the range of UIDs (and GIDs) that are reserved - * for assigning to applications. - */ -#define FIRST_APPLICATION_UID 10000 -#define LAST_APPLICATION_UID 99999 - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_MISC_H */ diff --git a/third_party/android_system_core/include/cutils/multiuser.h b/third_party/android_system_core/include/cutils/multiuser.h deleted file mode 100644 index 635ddb1358..0000000000 --- a/third_party/android_system_core/include/cutils/multiuser.h +++ /dev/null @@ -1,41 +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 __CUTILS_MULTIUSER_H -#define __CUTILS_MULTIUSER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// NOTE: keep in sync with android.os.UserId - -#define MULTIUSER_APP_PER_USER_RANGE 100000 - -typedef uid_t userid_t; -typedef uid_t appid_t; - -extern userid_t multiuser_get_user_id(uid_t uid); -extern appid_t multiuser_get_app_id(uid_t uid); -extern uid_t multiuser_get_uid(userid_t userId, appid_t appId); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_MULTIUSER_H */ diff --git a/third_party/android_system_core/include/cutils/native_handle.h b/third_party/android_system_core/include/cutils/native_handle.h deleted file mode 100644 index 268c5d3f51..0000000000 --- a/third_party/android_system_core/include/cutils/native_handle.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2009 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 NATIVE_HANDLE_H_ -#define NATIVE_HANDLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct native_handle -{ - int version; /* sizeof(native_handle_t) */ - int numFds; /* number of file-descriptors at &data[0] */ - int numInts; /* number of ints at &data[numFds] */ - int data[0]; /* numFds + numInts ints */ -} native_handle_t; - -/* - * native_handle_close - * - * closes the file descriptors contained in this native_handle_t - * - * return 0 on success, or a negative error code on failure - * - */ -int native_handle_close(const native_handle_t* h); - - -/* - * native_handle_create - * - * creates a native_handle_t and initializes it. must be destroyed with - * native_handle_delete(). - * - */ -native_handle_t* native_handle_create(int numFds, int numInts); - -/* - * native_handle_delete - * - * frees a native_handle_t allocated with native_handle_create(). - * This ONLY frees the memory allocated for the native_handle_t, but doesn't - * close the file descriptors; which can be achieved with native_handle_close(). - * - * return 0 on success, or a negative error code on failure - * - */ -int native_handle_delete(native_handle_t* h); - - -#ifdef __cplusplus -} -#endif - -#endif /* NATIVE_HANDLE_H_ */ diff --git a/third_party/android_system_core/include/cutils/open_memstream.h b/third_party/android_system_core/include/cutils/open_memstream.h deleted file mode 100644 index c1a81ebbcb..0000000000 --- a/third_party/android_system_core/include/cutils/open_memstream.h +++ /dev/null @@ -1,36 +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 __CUTILS_OPEN_MEMSTREAM_H__ -#define __CUTILS_OPEN_MEMSTREAM_H__ - -#include - -#if defined(__APPLE__) - -#ifdef __cplusplus -extern "C" { -#endif - -FILE* open_memstream(char** bufp, size_t* sizep); - -#ifdef __cplusplus -} -#endif - -#endif /* __APPLE__ */ - -#endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ diff --git a/third_party/android_system_core/include/cutils/partition_utils.h b/third_party/android_system_core/include/cutils/partition_utils.h deleted file mode 100644 index 72ca80d350..0000000000 --- a/third_party/android_system_core/include/cutils/partition_utils.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2011, 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 __CUTILS_PARTITION_WIPED_H__ -#define __CUTILS_PARTITION_WIPED_H__ - -__BEGIN_DECLS - -int partition_wiped(char *source); - -__END_DECLS - -#endif /* __CUTILS_PARTITION_WIPED_H__ */ diff --git a/third_party/android_system_core/include/cutils/process_name.h b/third_party/android_system_core/include/cutils/process_name.h deleted file mode 100644 index 1e72e5c3ad..0000000000 --- a/third_party/android_system_core/include/cutils/process_name.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -/** - * Gives the current process a name. - */ - -#ifndef __PROCESS_NAME_H -#define __PROCESS_NAME_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Sets the current process name. - * - * Warning: This leaks a string every time you call it. Use judiciously! - */ -void set_process_name(const char* process_name); - -/** Gets the current process name. */ -const char* get_process_name(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __PROCESS_NAME_H */ diff --git a/third_party/android_system_core/include/cutils/properties.h b/third_party/android_system_core/include/cutils/properties.h deleted file mode 100644 index 24aa224f64..0000000000 --- a/third_party/android_system_core/include/cutils/properties.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2006 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 __CUTILS_PROPERTIES_H -#define __CUTILS_PROPERTIES_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* System properties are *small* name value pairs managed by the -** property service. If your data doesn't fit in the provided -** space it is not appropriate for a system property. -** -** WARNING: system/bionic/include/sys/system_properties.h also defines -** these, but with different names. (TODO: fix that) -*/ -#define PROPERTY_KEY_MAX PROP_NAME_MAX -#define PROPERTY_VALUE_MAX PROP_VALUE_MAX - -/* property_get: returns the length of the value which will never be -** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. -** (the length does not include the terminating zero). -** -** If the property read fails or returns an empty value, the default -** value is used (if nonnull). -*/ -int property_get(const char *key, char *value, const char *default_value); - -/* property_get_bool: returns the value of key coerced into a -** boolean. If the property is not set, then the default value is returned. -** -* The following is considered to be true (1): -** "1", "true", "y", "yes", "on" -** -** The following is considered to be false (0): -** "0", "false", "n", "no", "off" -** -** The conversion is whitespace-sensitive (e.g. " off" will not be false). -** -** If no property with this key is set (or the key is NULL) or the boolean -** conversion fails, the default value is returned. -**/ -int8_t property_get_bool(const char *key, int8_t default_value); - -/* property_get_int64: returns the value of key truncated and coerced into a -** int64_t. If the property is not set, then the default value is used. -** -** The numeric conversion is identical to strtoimax with the base inferred: -** - All digits up to the first non-digit characters are read -** - The longest consecutive prefix of digits is converted to a long -** -** Valid strings of digits are: -** - An optional sign character + or - -** - An optional prefix indicating the base (otherwise base 10 is assumed) -** -- 0 prefix is octal -** -- 0x / 0X prefix is hex -** -** Leading/trailing whitespace is ignored. Overflow/underflow will cause -** numeric conversion to fail. -** -** If no property with this key is set (or the key is NULL) or the numeric -** conversion fails, the default value is returned. -**/ -int64_t property_get_int64(const char *key, int64_t default_value); - -/* property_get_int32: returns the value of key truncated and coerced into an -** int32_t. If the property is not set, then the default value is used. -** -** The numeric conversion is identical to strtoimax with the base inferred: -** - All digits up to the first non-digit characters are read -** - The longest consecutive prefix of digits is converted to a long -** -** Valid strings of digits are: -** - An optional sign character + or - -** - An optional prefix indicating the base (otherwise base 10 is assumed) -** -- 0 prefix is octal -** -- 0x / 0X prefix is hex -** -** Leading/trailing whitespace is ignored. Overflow/underflow will cause -** numeric conversion to fail. -** -** If no property with this key is set (or the key is NULL) or the numeric -** conversion fails, the default value is returned. -**/ -int32_t property_get_int32(const char *key, int32_t default_value); - -/* property_set: returns 0 on success, < 0 on failure -*/ -int property_set(const char *key, const char *value); - -int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); - -#if defined(__BIONIC_FORTIFY) - -extern int __property_get_real(const char *, char *, const char *) - __asm__(__USER_LABEL_PREFIX__ "property_get"); -__errordecl(__property_get_too_small_error, "property_get() called with too small of a buffer"); - -__BIONIC_FORTIFY_INLINE -int property_get(const char *key, char *value, const char *default_value) { - size_t bos = __bos(value); - if (bos < PROPERTY_VALUE_MAX) { - __property_get_too_small_error(); - } - return __property_get_real(key, value, default_value); -} - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/third_party/android_system_core/include/cutils/qtaguid.h b/third_party/android_system_core/include/cutils/qtaguid.h deleted file mode 100644 index f8550fda83..0000000000 --- a/third_party/android_system_core/include/cutils/qtaguid.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2011 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 __CUTILS_QTAGUID_H -#define __CUTILS_QTAGUID_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Set tags (and owning UIDs) for network sockets. -*/ -extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid); - -/* - * Untag a network socket before closing. -*/ -extern int qtaguid_untagSocket(int sockfd); - -/* - * For the given uid, switch counter sets. - * The kernel only keeps a limited number of sets. - * 2 for now. - */ -extern int qtaguid_setCounterSet(int counterSetNum, uid_t uid); - -/* - * Delete all tag info that relates to the given tag an uid. - * If the tag is 0, then ALL info about the uid is freeded. - * The delete data also affects active tagged socketd, which are - * then untagged. - * The calling process can only operate on its own tags. - * Unless it is part of the happy AID_NET_BW_ACCT group. - * In which case it can clobber everything. - */ -extern int qtaguid_deleteTagData(int tag, uid_t uid); - -/* - * Enable/disable qtaguid functionnality at a lower level. - * When pacified, the kernel will accept commands but do nothing. - */ -extern int qtaguid_setPacifier(int on); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_QTAG_UID_H */ diff --git a/third_party/android_system_core/include/cutils/record_stream.h b/third_party/android_system_core/include/cutils/record_stream.h deleted file mode 100644 index bfac87a53c..0000000000 --- a/third_party/android_system_core/include/cutils/record_stream.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -/* - * A simple utility for reading fixed records out of a stream fd - */ - -#ifndef _CUTILS_RECORD_STREAM_H -#define _CUTILS_RECORD_STREAM_H - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct RecordStream RecordStream; - -extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); -extern void record_stream_free(RecordStream *p_rs); - -extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, - size_t *p_outRecordLen); - -#ifdef __cplusplus -} -#endif - - -#endif /*_CUTILS_RECORD_STREAM_H*/ - diff --git a/third_party/android_system_core/include/cutils/sched_policy.h b/third_party/android_system_core/include/cutils/sched_policy.h deleted file mode 100644 index 6a8d570b2c..0000000000 --- a/third_party/android_system_core/include/cutils/sched_policy.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2007 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 __CUTILS_SCHED_POLICY_H -#define __CUTILS_SCHED_POLICY_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ -typedef enum { - SP_DEFAULT = -1, - SP_BACKGROUND = 0, - SP_FOREGROUND = 1, - SP_SYSTEM = 2, // can't be used with set_sched_policy() - SP_AUDIO_APP = 3, - SP_AUDIO_SYS = 4, - SP_CNT, - SP_MAX = SP_CNT - 1, - SP_SYSTEM_DEFAULT = SP_FOREGROUND, -} SchedPolicy; - -extern int set_cpuset_policy(int tid, SchedPolicy policy); - -/* Assign thread tid to the cgroup associated with the specified policy. - * If the thread is a thread group leader, that is it's gettid() == getpid(), - * then the other threads in the same thread group are _not_ affected. - * On platforms which support gettid(), zero tid means current thread. - * Return value: 0 for success, or -errno for error. - */ -extern int set_sched_policy(int tid, SchedPolicy policy); - -/* Return the policy associated with the cgroup of thread tid via policy pointer. - * On platforms which support gettid(), zero tid means current thread. - * Return value: 0 for success, or -1 for error and set errno. - */ -extern int get_sched_policy(int tid, SchedPolicy *policy); - -/* Return a displayable string corresponding to policy. - * Return value: non-NULL NUL-terminated name of unspecified length; - * the caller is responsible for displaying the useful part of the string. - */ -extern const char *get_sched_policy_name(SchedPolicy policy); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_SCHED_POLICY_H */ diff --git a/third_party/android_system_core/include/cutils/sockets.h b/third_party/android_system_core/include/cutils/sockets.h deleted file mode 100644 index f8076ca452..0000000000 --- a/third_party/android_system_core/include/cutils/sockets.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2006 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 __CUTILS_SOCKETS_H -#define __CUTILS_SOCKETS_H - -#include -#include -#include -#include -#include - -#ifdef HAVE_WINSOCK -#include -typedef int socklen_t; -#else -#include -#endif - -#define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_" -#define ANDROID_SOCKET_DIR "/dev/socket" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * android_get_control_socket - simple helper function to get the file - * descriptor of our init-managed Unix domain socket. `name' is the name of the - * socket, as given in init.rc. Returns -1 on error. - * - * This is inline and not in libcutils proper because we want to use this in - * third-party daemons with minimal modification. - */ -static inline int android_get_control_socket(const char *name) -{ - char key[64]; - snprintf(key, sizeof(key), ANDROID_SOCKET_ENV_PREFIX "%s", name); - - const char* val = getenv(key); - if (!val) { - return -1; - } - - errno = 0; - int fd = strtol(val, NULL, 10); - if (errno) { - return -1; - } - - return fd; -} - -/* - * See also android.os.LocalSocketAddress.Namespace - */ -// Linux "abstract" (non-filesystem) namespace -#define ANDROID_SOCKET_NAMESPACE_ABSTRACT 0 -// Android "reserved" (/dev/socket) namespace -#define ANDROID_SOCKET_NAMESPACE_RESERVED 1 -// Normal filesystem namespace -#define ANDROID_SOCKET_NAMESPACE_FILESYSTEM 2 - -extern int socket_loopback_client(int port, int type); -extern int socket_network_client(const char *host, int port, int type); -extern int socket_network_client_timeout(const char *host, int port, int type, - int timeout); -extern int socket_loopback_server(int port, int type); -extern int socket_local_server(const char *name, int namespaceId, int type); -extern int socket_local_server_bind(int s, const char *name, int namespaceId); -extern int socket_local_client_connect(int fd, - const char *name, int namespaceId, int type); -extern int socket_local_client(const char *name, int namespaceId, int type); -extern int socket_inaddr_any_server(int port, int type); - -/* - * socket_peer_is_trusted - Takes a socket which is presumed to be a - * connected local socket (e.g. AF_LOCAL) and returns whether the peer - * (the userid that owns the process on the other end of that socket) - * is one of the two trusted userids, root or shell. - * - * Note: This only works as advertised on the Android OS and always - * just returns true when called on other operating systems. - */ -extern bool socket_peer_is_trusted(int fd); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_SOCKETS_H */ diff --git a/third_party/android_system_core/include/cutils/str_parms.h b/third_party/android_system_core/include/cutils/str_parms.h deleted file mode 100644 index aa1435a080..0000000000 --- a/third_party/android_system_core/include/cutils/str_parms.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2011 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 __CUTILS_STR_PARMS_H -#define __CUTILS_STR_PARMS_H - -#include -#include - -__BEGIN_DECLS - -struct str_parms; - -struct str_parms *str_parms_create(void); -struct str_parms *str_parms_create_str(const char *_string); -void str_parms_destroy(struct str_parms *str_parms); - -void str_parms_del(struct str_parms *str_parms, const char *key); - -int str_parms_add_str(struct str_parms *str_parms, const char *key, - const char *value); -int str_parms_add_int(struct str_parms *str_parms, const char *key, int value); - -int str_parms_add_float(struct str_parms *str_parms, const char *key, - float value); - -// Returns non-zero if the str_parms contains the specified key. -int str_parms_has_key(struct str_parms *str_parms, const char *key); - -// Gets value associated with the specified key (if present), placing it in the buffer -// pointed to by the out_val parameter. Returns the length of the returned string value. -// If 'key' isn't in the parms, then return -ENOENT (-2) and leave 'out_val' untouched. -int str_parms_get_str(struct str_parms *str_parms, const char *key, - char *out_val, int len); -int str_parms_get_int(struct str_parms *str_parms, const char *key, - int *out_val); -int str_parms_get_float(struct str_parms *str_parms, const char *key, - float *out_val); - -char *str_parms_to_str(struct str_parms *str_parms); - -/* debug */ -void str_parms_dump(struct str_parms *str_parms); - -__END_DECLS - -#endif /* __CUTILS_STR_PARMS_H */ diff --git a/third_party/android_system_core/include/cutils/threads.h b/third_party/android_system_core/include/cutils/threads.h deleted file mode 100644 index 5727494079..0000000000 --- a/third_party/android_system_core/include/cutils/threads.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_CUTILS_THREADS_H -#define _LIBS_CUTILS_THREADS_H - -#include - -#if !defined(_WIN32) -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/***********************************************************************/ -/***********************************************************************/ -/***** *****/ -/***** local thread storage *****/ -/***** *****/ -/***********************************************************************/ -/***********************************************************************/ - -extern pid_t gettid(); - -#if !defined(_WIN32) - -typedef struct { - pthread_mutex_t lock; - int has_tls; - pthread_key_t tls; -} thread_store_t; - -#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } - -#else // !defined(_WIN32) - -typedef struct { - int lock_init; - int has_tls; - DWORD tls; - CRITICAL_SECTION lock; -} thread_store_t; - -#define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } - -#endif // !defined(_WIN32) - -typedef void (*thread_store_destruct_t)(void* value); - -extern void* thread_store_get(thread_store_t* store); - -extern void thread_store_set(thread_store_t* store, - void* value, - thread_store_destruct_t destroy); - -/***********************************************************************/ -/***********************************************************************/ -/***** *****/ -/***** mutexes *****/ -/***** *****/ -/***********************************************************************/ -/***********************************************************************/ - -#if !defined(_WIN32) - -typedef pthread_mutex_t mutex_t; - -#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - -static __inline__ void mutex_lock(mutex_t* lock) -{ - pthread_mutex_lock(lock); -} -static __inline__ void mutex_unlock(mutex_t* lock) -{ - pthread_mutex_unlock(lock); -} -static __inline__ int mutex_init(mutex_t* lock) -{ - return pthread_mutex_init(lock, NULL); -} -static __inline__ void mutex_destroy(mutex_t* lock) -{ - pthread_mutex_destroy(lock); -} - -#else // !defined(_WIN32) - -typedef struct { - int init; - CRITICAL_SECTION lock[1]; -} mutex_t; - -#define MUTEX_INITIALIZER { 0, {{ NULL, 0, 0, NULL, NULL, 0 }} } - -static __inline__ void mutex_lock(mutex_t* lock) -{ - if (!lock->init) { - lock->init = 1; - InitializeCriticalSection( lock->lock ); - lock->init = 2; - } else while (lock->init != 2) - Sleep(10); - - EnterCriticalSection(lock->lock); -} - -static __inline__ void mutex_unlock(mutex_t* lock) -{ - LeaveCriticalSection(lock->lock); -} -static __inline__ int mutex_init(mutex_t* lock) -{ - InitializeCriticalSection(lock->lock); - lock->init = 2; - return 0; -} -static __inline__ void mutex_destroy(mutex_t* lock) -{ - if (lock->init) { - lock->init = 0; - DeleteCriticalSection(lock->lock); - } -} -#endif // !defined(_WIN32) - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBS_CUTILS_THREADS_H */ diff --git a/third_party/android_system_core/include/cutils/trace.h b/third_party/android_system_core/include/cutils/trace.h deleted file mode 100644 index e4ed17983d..0000000000 --- a/third_party/android_system_core/include/cutils/trace.h +++ /dev/null @@ -1,252 +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 _LIBS_CUTILS_TRACE_H -#define _LIBS_CUTILS_TRACE_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -__BEGIN_DECLS - -/** - * The ATRACE_TAG macro can be defined before including this header to trace - * using one of the tags defined below. It must be defined to one of the - * following ATRACE_TAG_* macros. The trace tag is used to filter tracing in - * userland to avoid some of the runtime cost of tracing when it is not desired. - * - * Defining ATRACE_TAG to be ATRACE_TAG_ALWAYS will result in the tracing always - * being enabled - this should ONLY be done for debug code, as userland tracing - * has a performance cost even when the trace is not being recorded. Defining - * ATRACE_TAG to be ATRACE_TAG_NEVER or leaving ATRACE_TAG undefined will result - * in the tracing always being disabled. - * - * ATRACE_TAG_HAL should be bitwise ORed with the relevant tags for tracing - * within a hardware module. For example a camera hardware module would set: - * #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) - * - * Keep these in sync with frameworks/base/core/java/android/os/Trace.java. - */ -#define ATRACE_TAG_NEVER 0 // This tag is never enabled. -#define ATRACE_TAG_ALWAYS (1<<0) // This tag is always enabled. -#define ATRACE_TAG_GRAPHICS (1<<1) -#define ATRACE_TAG_INPUT (1<<2) -#define ATRACE_TAG_VIEW (1<<3) -#define ATRACE_TAG_WEBVIEW (1<<4) -#define ATRACE_TAG_WINDOW_MANAGER (1<<5) -#define ATRACE_TAG_ACTIVITY_MANAGER (1<<6) -#define ATRACE_TAG_SYNC_MANAGER (1<<7) -#define ATRACE_TAG_AUDIO (1<<8) -#define ATRACE_TAG_VIDEO (1<<9) -#define ATRACE_TAG_CAMERA (1<<10) -#define ATRACE_TAG_HAL (1<<11) -#define ATRACE_TAG_APP (1<<12) -#define ATRACE_TAG_RESOURCES (1<<13) -#define ATRACE_TAG_DALVIK (1<<14) -#define ATRACE_TAG_RS (1<<15) -#define ATRACE_TAG_BIONIC (1<<16) -#define ATRACE_TAG_POWER (1<<17) -#define ATRACE_TAG_LAST ATRACE_TAG_POWER - -// Reserved for initialization. -#define ATRACE_TAG_NOT_READY (1LL<<63) - -#define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST) - -#ifndef ATRACE_TAG -#define ATRACE_TAG ATRACE_TAG_NEVER -#elif ATRACE_TAG > ATRACE_TAG_VALID_MASK -#error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h -#endif - -/** - * Opens the trace file for writing and reads the property for initial tags. - * The atrace.tags.enableflags property sets the tags to trace. - * This function should not be explicitly called, the first call to any normal - * trace function will cause it to be run safely. - */ -void atrace_setup(); - -/** - * If tracing is ready, set atrace_enabled_tags to the system property - * debug.atrace.tags.enableflags. Can be used as a sysprop change callback. - */ -void atrace_update_tags(); - -/** - * Set whether the process is debuggable. By default the process is not - * considered debuggable. If the process is not debuggable then application- - * level tracing is not allowed unless the ro.debuggable system property is - * set to '1'. - */ -void atrace_set_debuggable(bool debuggable); - -/** - * Set whether tracing is enabled for the current process. This is used to - * prevent tracing within the Zygote process. - */ -void atrace_set_tracing_enabled(bool enabled); - -/** - * Flag indicating whether setup has been completed, initialized to 0. - * Nonzero indicates setup has completed. - * Note: This does NOT indicate whether or not setup was successful. - */ -extern atomic_bool atrace_is_ready; - -/** - * Set of ATRACE_TAG flags to trace for, initialized to ATRACE_TAG_NOT_READY. - * A value of zero indicates setup has failed. - * Any other nonzero value indicates setup has succeeded, and tracing is on. - */ -extern uint64_t atrace_enabled_tags; - -/** - * Handle to the kernel's trace buffer, initialized to -1. - * Any other value indicates setup has succeeded, and is a valid fd for tracing. - */ -extern int atrace_marker_fd; - -/** - * atrace_init readies the process for tracing by opening the trace_marker file. - * Calling any trace function causes this to be run, so calling it is optional. - * This can be explicitly run to avoid setup delay on first trace function. - */ -#define ATRACE_INIT() atrace_init() -static inline void atrace_init() -{ - if (CC_UNLIKELY(!atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) { - atrace_setup(); - } -} - -/** - * Get the mask of all tags currently enabled. - * It can be used as a guard condition around more expensive trace calculations. - * Every trace function calls this, which ensures atrace_init is run. - */ -#define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags() -static inline uint64_t atrace_get_enabled_tags() -{ - atrace_init(); - return atrace_enabled_tags; -} - -/** - * Test if a given tag is currently enabled. - * Returns nonzero if the tag is enabled, otherwise zero. - * It can be used as a guard condition around more expensive trace calculations. - */ -#define ATRACE_ENABLED() atrace_is_tag_enabled(ATRACE_TAG) -static inline uint64_t atrace_is_tag_enabled(uint64_t tag) -{ - return atrace_get_enabled_tags() & tag; -} - -/** - * Trace the beginning of a context. name is used to identify the context. - * This is often used to time function execution. - */ -#define ATRACE_BEGIN(name) atrace_begin(ATRACE_TAG, name) -static inline void atrace_begin(uint64_t tag, const char* name) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_begin_body(const char*); - atrace_begin_body(name); - } -} - -/** - * Trace the end of a context. - * This should match up (and occur after) a corresponding ATRACE_BEGIN. - */ -#define ATRACE_END() atrace_end(ATRACE_TAG) -static inline void atrace_end(uint64_t tag) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char c = 'E'; - write(atrace_marker_fd, &c, 1); - } -} - -/** - * Trace the beginning of an asynchronous event. Unlike ATRACE_BEGIN/ATRACE_END - * contexts, asynchronous events do not need to be nested. The name describes - * the event, and the cookie provides a unique identifier for distinguishing - * simultaneous events. The name and cookie used to begin an event must be - * used to end it. - */ -#define ATRACE_ASYNC_BEGIN(name, cookie) \ - atrace_async_begin(ATRACE_TAG, name, cookie) -static inline void atrace_async_begin(uint64_t tag, const char* name, - int32_t cookie) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_async_begin_body(const char*, int32_t); - atrace_async_begin_body(name, cookie); - } -} - -/** - * Trace the end of an asynchronous event. - * This should have a corresponding ATRACE_ASYNC_BEGIN. - */ -#define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) -static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_async_end_body(const char*, int32_t); - atrace_async_end_body(name, cookie); - } -} - -/** - * Traces an integer counter value. name is used to identify the counter. - * This can be used to track how a value changes over time. - */ -#define ATRACE_INT(name, value) atrace_int(ATRACE_TAG, name, value) -static inline void atrace_int(uint64_t tag, const char* name, int32_t value) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_int_body(const char*, int32_t); - atrace_int_body(name, value); - } -} - -/** - * Traces a 64-bit integer counter value. name is used to identify the - * counter. This can be used to track how a value changes over time. - */ -#define ATRACE_INT64(name, value) atrace_int64(ATRACE_TAG, name, value) -static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_int64_body(const char*, int64_t); - atrace_int64_body(name, value); - } -} - -__END_DECLS - -#endif // _LIBS_CUTILS_TRACE_H diff --git a/third_party/android_system_core/include/cutils/uevent.h b/third_party/android_system_core/include/cutils/uevent.h deleted file mode 100644 index da1c2aae6b..0000000000 --- a/third_party/android_system_core/include/cutils/uevent.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2011 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 __CUTILS_UEVENT_H -#define __CUTILS_UEVENT_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int uevent_open_socket(int buf_sz, bool passcred); -ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length); -ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid); -ssize_t uevent_kernel_recv(int socket, void *buffer, size_t length, bool require_group, uid_t *uid); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_UEVENT_H */ diff --git a/third_party/android_system_core/include/log/event_tag_map.h b/third_party/android_system_core/include/log/event_tag_map.h deleted file mode 100644 index 1653c61e9a..0000000000 --- a/third_party/android_system_core/include/log/event_tag_map.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_CUTILS_EVENTTAGMAP_H -#define _LIBS_CUTILS_EVENTTAGMAP_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" - -struct EventTagMap; -typedef struct EventTagMap EventTagMap; - -/* - * Open the specified file as an event log tag map. - * - * Returns NULL on failure. - */ -EventTagMap* android_openEventTagMap(const char* fileName); - -/* - * Close the map. - */ -void android_closeEventTagMap(EventTagMap* map); - -/* - * Look up a tag by index. Returns the tag string, or NULL if not found. - */ -const char* android_lookupEventTag(const EventTagMap* map, int tag); - -#ifdef __cplusplus -} -#endif - -#endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ diff --git a/third_party/android_system_core/include/log/log.h b/third_party/android_system_core/include/log/log.h deleted file mode 100644 index 63a441a689..0000000000 --- a/third_party/android_system_core/include/log/log.h +++ /dev/null @@ -1,642 +0,0 @@ -/* - * Copyright (C) 2005-2014 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. - */ - -// -// C/C++ logging functions. See the logging documentation for API details. -// -// We'd like these to be available from C code (in case we import some from -// somewhere), so this has a C interface. -// -// The output will be correct when the log file is shared between multiple -// threads and/or multiple processes so long as the operating system -// supports O_APPEND. These calls have mutex-protected data structures -// and so are NOT reentrant. Do not use LOG in a signal handler. -// -#ifndef _LIBS_LOG_LOG_H -#define _LIBS_LOG_LOG_H - -#include -#include -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// --------------------------------------------------------------------- - -/* - * Normally we strip ALOGV (VERBOSE messages) from release builds. - * You can modify this (for example with "#define LOG_NDEBUG 0" - * at the top of your source file) to change that behavior. - */ -#ifndef LOG_NDEBUG -#ifdef NDEBUG -#define LOG_NDEBUG 1 -#else -#define LOG_NDEBUG 0 -#endif -#endif - -/* - * This is the local tag used for the following simplified - * logging macros. You can change this preprocessor definition - * before using the other macros to change the tag. - */ -#ifndef LOG_TAG -#define LOG_TAG NULL -#endif - -// --------------------------------------------------------------------- - -#ifndef __predict_false -#define __predict_false(exp) __builtin_expect((exp) != 0, 0) -#endif - -/* - * -DLINT_RLOG in sources that you want to enforce that all logging - * goes to the radio log buffer. If any logging goes to any of the other - * log buffers, there will be a compile or link error to highlight the - * problem. This is not a replacement for a full audit of the code since - * this only catches compiled code, not ifdef'd debug code. Options to - * defining this, either temporarily to do a spot check, or permanently - * to enforce, in all the communications trees; We have hopes to ensure - * that by supplying just the radio log buffer that the communications - * teams will have their one-stop shop for triaging issues. - */ -#ifndef LINT_RLOG - -/* - * Simplified macro to send a verbose log message using the current LOG_TAG. - */ -#ifndef ALOGV -#define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define ALOGV(...) do { if (0) { __ALOGV(__VA_ARGS__); } } while (0) -#else -#define ALOGV(...) __ALOGV(__VA_ARGS__) -#endif -#endif - -#ifndef ALOGV_IF -#if LOG_NDEBUG -#define ALOGV_IF(cond, ...) ((void)0) -#else -#define ALOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif - -/* - * Simplified macro to send a debug log message using the current LOG_TAG. - */ -#ifndef ALOGD -#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGD_IF -#define ALOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info log message using the current LOG_TAG. - */ -#ifndef ALOGI -#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGI_IF -#define ALOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning log message using the current LOG_TAG. - */ -#ifndef ALOGW -#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGW_IF -#define ALOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an error log message using the current LOG_TAG. - */ -#ifndef ALOGE -#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGE_IF -#define ALOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -// --------------------------------------------------------------------- - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * verbose priority. - */ -#ifndef IF_ALOGV -#if LOG_NDEBUG -#define IF_ALOGV() if (false) -#else -#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG) -#endif -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * debug priority. - */ -#ifndef IF_ALOGD -#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * info priority. - */ -#ifndef IF_ALOGI -#define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * warn priority. - */ -#ifndef IF_ALOGW -#define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * error priority. - */ -#ifndef IF_ALOGE -#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG) -#endif - - -// --------------------------------------------------------------------- - -/* - * Simplified macro to send a verbose system log message using the current LOG_TAG. - */ -#ifndef SLOGV -#define __SLOGV(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define SLOGV(...) do { if (0) { __SLOGV(__VA_ARGS__); } } while (0) -#else -#define SLOGV(...) __SLOGV(__VA_ARGS__) -#endif -#endif - -#ifndef SLOGV_IF -#if LOG_NDEBUG -#define SLOGV_IF(cond, ...) ((void)0) -#else -#define SLOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif - -/* - * Simplified macro to send a debug system log message using the current LOG_TAG. - */ -#ifndef SLOGD -#define SLOGD(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGD_IF -#define SLOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info system log message using the current LOG_TAG. - */ -#ifndef SLOGI -#define SLOGI(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGI_IF -#define SLOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning system log message using the current LOG_TAG. - */ -#ifndef SLOGW -#define SLOGW(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGW_IF -#define SLOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an error system log message using the current LOG_TAG. - */ -#ifndef SLOGE -#define SLOGE(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGE_IF -#define SLOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -#endif /* !LINT_RLOG */ - -// --------------------------------------------------------------------- - -/* - * Simplified macro to send a verbose radio log message using the current LOG_TAG. - */ -#ifndef RLOGV -#define __RLOGV(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0) -#else -#define RLOGV(...) __RLOGV(__VA_ARGS__) -#endif -#endif - -#ifndef RLOGV_IF -#if LOG_NDEBUG -#define RLOGV_IF(cond, ...) ((void)0) -#else -#define RLOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif - -/* - * Simplified macro to send a debug radio log message using the current LOG_TAG. - */ -#ifndef RLOGD -#define RLOGD(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGD_IF -#define RLOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info radio log message using the current LOG_TAG. - */ -#ifndef RLOGI -#define RLOGI(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGI_IF -#define RLOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning radio log message using the current LOG_TAG. - */ -#ifndef RLOGW -#define RLOGW(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGW_IF -#define RLOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an error radio log message using the current LOG_TAG. - */ -#ifndef RLOGE -#define RLOGE(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGE_IF -#define RLOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - - -// --------------------------------------------------------------------- - -/* - * Log a fatal error. If the given condition fails, this stops program - * execution like a normal assertion, but also generating the given message. - * It is NOT stripped from release builds. Note that the condition test - * is -inverted- from the normal assert() semantics. - */ -#ifndef LOG_ALWAYS_FATAL_IF -#define LOG_ALWAYS_FATAL_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \ - : (void)0 ) -#endif - -#ifndef LOG_ALWAYS_FATAL -#define LOG_ALWAYS_FATAL(...) \ - ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) ) -#endif - -/* - * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that - * are stripped out of release builds. - */ -#if LOG_NDEBUG - -#ifndef LOG_FATAL_IF -#define LOG_FATAL_IF(cond, ...) ((void)0) -#endif -#ifndef LOG_FATAL -#define LOG_FATAL(...) ((void)0) -#endif - -#else - -#ifndef LOG_FATAL_IF -#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__) -#endif -#ifndef LOG_FATAL -#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__) -#endif - -#endif - -/* - * Assertion that generates a log message when the assertion fails. - * Stripped out of release builds. Uses the current LOG_TAG. - */ -#ifndef ALOG_ASSERT -#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__) -//#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) -#endif - -// --------------------------------------------------------------------- - -/* - * Basic log message macro. - * - * Example: - * ALOG(LOG_WARN, NULL, "Failed with error %d", errno); - * - * The second argument may be NULL or "" to indicate the "global" tag. - */ -#ifndef ALOG -#define ALOG(priority, tag, ...) \ - LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) -#endif - -/* - * Log macro that allows you to specify a number for the priority. - */ -#ifndef LOG_PRI -#define LOG_PRI(priority, tag, ...) \ - android_printLog(priority, tag, __VA_ARGS__) -#endif - -/* - * Log macro that allows you to pass in a varargs ("args" is a va_list). - */ -#ifndef LOG_PRI_VA -#define LOG_PRI_VA(priority, tag, fmt, args) \ - android_vprintLog(priority, NULL, tag, fmt, args) -#endif - -/* - * Conditional given a desired logging priority and tag. - */ -#ifndef IF_ALOG -#define IF_ALOG(priority, tag) \ - if (android_testLog(ANDROID_##priority, tag)) -#endif - -// --------------------------------------------------------------------- - -/* - * Event logging. - */ - -/* - * Event log entry types. These must match up with the declarations in - * java/android/android/util/EventLog.java. - */ -typedef enum { - EVENT_TYPE_INT = 0, - EVENT_TYPE_LONG = 1, - EVENT_TYPE_STRING = 2, - EVENT_TYPE_LIST = 3, - EVENT_TYPE_FLOAT = 4, -} AndroidEventLogType; -#define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType) -#define typeof_AndroidEventLogType unsigned char - -#ifndef LOG_EVENT_INT -#define LOG_EVENT_INT(_tag, _value) { \ - int intBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, \ - sizeof(intBuf)); \ - } -#endif -#ifndef LOG_EVENT_LONG -#define LOG_EVENT_LONG(_tag, _value) { \ - long long longBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, \ - sizeof(longBuf)); \ - } -#endif -#ifndef LOG_EVENT_FLOAT -#define LOG_EVENT_FLOAT(_tag, _value) { \ - float floatBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \ - sizeof(floatBuf)); \ - } -#endif -#ifndef LOG_EVENT_STRING -#define LOG_EVENT_STRING(_tag, _value) \ - (void) __android_log_bswrite(_tag, _value); -#endif -/* TODO: something for LIST */ - -/* - * =========================================================================== - * - * The stuff in the rest of this file should not be used directly. - */ - -#define android_printLog(prio, tag, fmt...) \ - __android_log_print(prio, tag, fmt) - -#define android_vprintLog(prio, cond, tag, fmt...) \ - __android_log_vprint(prio, tag, fmt) - -/* XXX Macros to work around syntax errors in places where format string - * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF - * (happens only in debug builds). - */ - -/* Returns 2nd arg. Used to substitute default value if caller's vararg list - * is empty. - */ -#define __android_second(dummy, second, ...) second - -/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise - * returns nothing. - */ -#define __android_rest(first, ...) , ## __VA_ARGS__ - -#define android_printAssert(cond, tag, fmt...) \ - __android_log_assert(cond, tag, \ - __android_second(0, ## fmt, NULL) __android_rest(fmt)) - -#define android_writeLog(prio, tag, text) \ - __android_log_write(prio, tag, text) - -#define android_bWriteLog(tag, payload, len) \ - __android_log_bwrite(tag, payload, len) -#define android_btWriteLog(tag, type, payload, len) \ - __android_log_btwrite(tag, type, payload, len) - -#define android_errorWriteLog(tag, subTag) \ - __android_log_error_write(tag, subTag, -1, NULL, 0) - -#define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \ - __android_log_error_write(tag, subTag, uid, data, dataLen) - -/* - * IF_ALOG uses android_testLog, but IF_ALOG can be overridden. - * android_testLog will remain constant in its purpose as a wrapper - * for Android logging filter policy, and can be subject to - * change. It can be reused by the developers that override - * IF_ALOG as a convenient means to reimplement their policy - * over Android. - */ -#if LOG_NDEBUG /* Production */ -#define android_testLog(prio, tag) \ - (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0) -#else -#define android_testLog(prio, tag) \ - (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0) -#endif - -// TODO: remove these prototypes and their users -#define android_writevLog(vec,num) do{}while(0) -#define android_write1Log(str,len) do{}while (0) -#define android_setMinPriority(tag, prio) do{}while(0) -//#define android_logToCallback(func) do{}while(0) -#define android_logToFile(tag, file) (0) -#define android_logToFd(tag, fd) (0) - -#ifndef log_id_t_defined -#define log_id_t_defined - -typedef enum log_id { - LOG_ID_MIN = 0, - -#ifndef LINT_RLOG - LOG_ID_MAIN = 0, -#endif - LOG_ID_RADIO = 1, -#ifndef LINT_RLOG - LOG_ID_EVENTS = 2, - LOG_ID_SYSTEM = 3, - LOG_ID_CRASH = 4, - LOG_ID_KERNEL = 5, -#endif - - LOG_ID_MAX -} log_id_t; -#endif -#define sizeof_log_id_t sizeof(typeof_log_id_t) -#define typeof_log_id_t unsigned char - -/* - * Use the per-tag properties "log.tag." to generate a runtime - * result of non-zero to expose a log. - */ -int __android_log_is_loggable(int prio, const char *tag, int def); - -int __android_log_error_write(int tag, const char *subTag, int32_t uid, const char *data, - uint32_t dataLen); - -/* - * Send a simple string to the log. - */ -int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text); -int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...) -#if defined(__GNUC__) - __attribute__((__format__(printf, 4, 5))) -#endif - ; - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBS_LOG_LOG_H */ diff --git a/third_party/android_system_core/include/log/log_read.h b/third_party/android_system_core/include/log/log_read.h deleted file mode 100644 index 1b70affc35..0000000000 --- a/third_party/android_system_core/include/log/log_read.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2013-2014 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 _LIBS_LOG_LOG_READ_H -#define _LIBS_LOG_LOG_READ_H - -#include -#include - -/* struct log_time is a wire-format variant of struct timespec */ -#define NS_PER_SEC 1000000000ULL - -#ifdef __cplusplus - -// NB: do NOT define a copy constructor. This will result in structure -// no longer being compatible with pass-by-value which is desired -// efficient behavior. Also, pass-by-reference breaks C/C++ ABI. -struct log_time { -public: - uint32_t tv_sec; // good to Feb 5 2106 - uint32_t tv_nsec; - - static const uint32_t tv_sec_max = 0xFFFFFFFFUL; - static const uint32_t tv_nsec_max = 999999999UL; - - log_time(const timespec &T) - { - tv_sec = T.tv_sec; - tv_nsec = T.tv_nsec; - } - log_time(uint32_t sec, uint32_t nsec) - { - tv_sec = sec; - tv_nsec = nsec; - } - static const timespec EPOCH; - log_time() - { - } - log_time(clockid_t id) - { - timespec T; - clock_gettime(id, &T); - tv_sec = T.tv_sec; - tv_nsec = T.tv_nsec; - } - log_time(const char *T) - { - const uint8_t *c = (const uint8_t *) T; - tv_sec = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24); - tv_nsec = c[4] | (c[5] << 8) | (c[6] << 16) | (c[7] << 24); - } - - // timespec - bool operator== (const timespec &T) const - { - return (tv_sec == static_cast(T.tv_sec)) - && (tv_nsec == static_cast(T.tv_nsec)); - } - bool operator!= (const timespec &T) const - { - return !(*this == T); - } - bool operator< (const timespec &T) const - { - return (tv_sec < static_cast(T.tv_sec)) - || ((tv_sec == static_cast(T.tv_sec)) - && (tv_nsec < static_cast(T.tv_nsec))); - } - bool operator>= (const timespec &T) const - { - return !(*this < T); - } - bool operator> (const timespec &T) const - { - return (tv_sec > static_cast(T.tv_sec)) - || ((tv_sec == static_cast(T.tv_sec)) - && (tv_nsec > static_cast(T.tv_nsec))); - } - bool operator<= (const timespec &T) const - { - return !(*this > T); - } - log_time operator-= (const timespec &T); - log_time operator- (const timespec &T) const - { - log_time local(*this); - return local -= T; - } - log_time operator+= (const timespec &T); - log_time operator+ (const timespec &T) const - { - log_time local(*this); - return local += T; - } - - // log_time - bool operator== (const log_time &T) const - { - return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec); - } - bool operator!= (const log_time &T) const - { - return !(*this == T); - } - bool operator< (const log_time &T) const - { - return (tv_sec < T.tv_sec) - || ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec)); - } - bool operator>= (const log_time &T) const - { - return !(*this < T); - } - bool operator> (const log_time &T) const - { - return (tv_sec > T.tv_sec) - || ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec)); - } - bool operator<= (const log_time &T) const - { - return !(*this > T); - } - log_time operator-= (const log_time &T); - log_time operator- (const log_time &T) const - { - log_time local(*this); - return local -= T; - } - log_time operator+= (const log_time &T); - log_time operator+ (const log_time &T) const - { - log_time local(*this); - return local += T; - } - - uint64_t nsec() const - { - return static_cast(tv_sec) * NS_PER_SEC + tv_nsec; - } - - static const char default_format[]; - - // Add %#q for the fraction of a second to the standard library functions - char *strptime(const char *s, const char *format = default_format); -} __attribute__((__packed__)); - -#else - -typedef struct log_time { - uint32_t tv_sec; - uint32_t tv_nsec; -} __attribute__((__packed__)) log_time; - -#endif - -#endif /* define _LIBS_LOG_LOG_READ_H */ diff --git a/third_party/android_system_core/include/log/logd.h b/third_party/android_system_core/include/log/logd.h deleted file mode 100644 index 0fe515f2ab..0000000000 --- a/third_party/android_system_core/include/log/logd.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2009 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_CUTILS_LOGD_H -#define _ANDROID_CUTILS_LOGD_H - -/* the stable/frozen log-related definitions have been - * moved to this header, which is exposed by the NDK - */ -#include - -/* the rest is only used internally by the system */ -#if !defined(_WIN32) -#include -#endif -#include -#include -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int __android_log_bwrite(int32_t tag, const void *payload, size_t len); -int __android_log_btwrite(int32_t tag, char type, const void *payload, - size_t len); -int __android_log_bswrite(int32_t tag, const char *payload); - -#ifdef __cplusplus -} -#endif - -#endif /* _LOGD_H */ diff --git a/third_party/android_system_core/include/log/logger.h b/third_party/android_system_core/include/log/logger.h deleted file mode 100644 index f030dab5a9..0000000000 --- a/third_party/android_system_core/include/log/logger.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -** -** Copyright 2007-2014, The Android Open Source Project -** -** This file is dual licensed. It may be redistributed and/or modified -** under the terms of the Apache 2.0 License OR version 2 of the GNU -** General Public License. -*/ - -#ifndef _LIBS_LOG_LOGGER_H -#define _LIBS_LOG_LOGGER_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The userspace structure for version 1 of the logger_entry ABI. - * This structure is returned to userspace by the kernel logger - * driver unless an upgrade to a newer ABI version is requested. - */ -struct logger_entry { - uint16_t len; /* length of the payload */ - uint16_t __pad; /* no matter what, we get 2 bytes of padding */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -/* - * The userspace structure for version 2 of the logger_entry ABI. - * This structure is returned to userspace if ioctl(LOGGER_SET_VERSION) - * is called with version==2; or used with the user space log daemon. - */ -struct logger_entry_v2 { - uint16_t len; /* length of the payload */ - uint16_t hdr_size; /* sizeof(struct logger_entry_v2) */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - uint32_t euid; /* effective UID of logger */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -struct logger_entry_v3 { - uint16_t len; /* length of the payload */ - uint16_t hdr_size; /* sizeof(struct logger_entry_v3) */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - uint32_t lid; /* log id of the payload */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -/* - * The maximum size of the log entry payload that can be - * written to the logger. An attempt to write more than - * this amount will result in a truncated log entry. - */ -#define LOGGER_ENTRY_MAX_PAYLOAD 4076 - -/* - * The maximum size of a log entry which can be read from the - * kernel logger driver. An attempt to read less than this amount - * may result in read() returning EINVAL. - */ -#define LOGGER_ENTRY_MAX_LEN (5*1024) - -#define NS_PER_SEC 1000000000ULL - -struct log_msg { - union { - unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1]; - struct logger_entry_v3 entry; - struct logger_entry_v3 entry_v3; - struct logger_entry_v2 entry_v2; - struct logger_entry entry_v1; - } __attribute__((aligned(4))); -#ifdef __cplusplus - /* Matching log_time operators */ - bool operator== (const log_msg &T) const - { - return (entry.sec == T.entry.sec) && (entry.nsec == T.entry.nsec); - } - bool operator!= (const log_msg &T) const - { - return !(*this == T); - } - bool operator< (const log_msg &T) const - { - return (entry.sec < T.entry.sec) - || ((entry.sec == T.entry.sec) - && (entry.nsec < T.entry.nsec)); - } - bool operator>= (const log_msg &T) const - { - return !(*this < T); - } - bool operator> (const log_msg &T) const - { - return (entry.sec > T.entry.sec) - || ((entry.sec == T.entry.sec) - && (entry.nsec > T.entry.nsec)); - } - bool operator<= (const log_msg &T) const - { - return !(*this > T); - } - uint64_t nsec() const - { - return static_cast(entry.sec) * NS_PER_SEC + entry.nsec; - } - - /* packet methods */ - log_id_t id() - { - return (log_id_t) entry.lid; - } - char *msg() - { - return entry.hdr_size ? (char *) buf + entry.hdr_size : entry_v1.msg; - } - unsigned int len() - { - return (entry.hdr_size ? entry.hdr_size : sizeof(entry_v1)) + entry.len; - } -#endif -}; - -struct logger; - -log_id_t android_logger_get_id(struct logger *logger); - -int android_logger_clear(struct logger *logger); -long android_logger_get_log_size(struct logger *logger); -int android_logger_set_log_size(struct logger *logger, unsigned long size); -long android_logger_get_log_readable_size(struct logger *logger); -int android_logger_get_log_version(struct logger *logger); - -struct logger_list; - -ssize_t android_logger_get_statistics(struct logger_list *logger_list, - char *buf, size_t len); -ssize_t android_logger_get_prune_list(struct logger_list *logger_list, - char *buf, size_t len); -int android_logger_set_prune_list(struct logger_list *logger_list, - char *buf, size_t len); - -#define ANDROID_LOG_RDONLY O_RDONLY -#define ANDROID_LOG_WRONLY O_WRONLY -#define ANDROID_LOG_RDWR O_RDWR -#define ANDROID_LOG_ACCMODE O_ACCMODE -#define ANDROID_LOG_NONBLOCK O_NONBLOCK -#define ANDROID_LOG_PSTORE 0x80000000 - -struct logger_list *android_logger_list_alloc(int mode, - unsigned int tail, - pid_t pid); -struct logger_list *android_logger_list_alloc_time(int mode, - log_time start, - pid_t pid); -void android_logger_list_free(struct logger_list *logger_list); -/* In the purest sense, the following two are orthogonal interfaces */ -int android_logger_list_read(struct logger_list *logger_list, - struct log_msg *log_msg); - -/* Multiple log_id_t opens */ -struct logger *android_logger_open(struct logger_list *logger_list, - log_id_t id); -#define android_logger_close android_logger_free -/* Single log_id_t open */ -struct logger_list *android_logger_list_open(log_id_t id, - int mode, - unsigned int tail, - pid_t pid); -#define android_logger_list_close android_logger_list_free - -/* - * log_id_t helpers - */ -log_id_t android_name_to_log_id(const char *logName); -const char *android_log_id_to_name(log_id_t log_id); - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBS_LOG_LOGGER_H */ diff --git a/third_party/android_system_core/include/log/logprint.h b/third_party/android_system_core/include/log/logprint.h deleted file mode 100644 index 4b812cc941..0000000000 --- a/third_party/android_system_core/include/log/logprint.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2006 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 _LOGPRINT_H -#define _LOGPRINT_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - FORMAT_OFF = 0, - FORMAT_BRIEF, - FORMAT_PROCESS, - FORMAT_TAG, - FORMAT_THREAD, - FORMAT_RAW, - FORMAT_TIME, - FORMAT_THREADTIME, - FORMAT_LONG, - /* The following three are modifiers to above formats */ - FORMAT_MODIFIER_COLOR, /* converts priority to color */ - FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */ - FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */ -} AndroidLogPrintFormat; - -typedef struct AndroidLogFormat_t AndroidLogFormat; - -typedef struct AndroidLogEntry_t { - time_t tv_sec; - long tv_nsec; - android_LogPriority priority; - int32_t pid; - int32_t tid; - const char * tag; - size_t messageLen; - const char * message; -} AndroidLogEntry; - -AndroidLogFormat *android_log_format_new(); - -void android_log_format_free(AndroidLogFormat *p_format); - -/* currently returns 0 if format is a modifier, 1 if not */ -int android_log_setPrintFormat(AndroidLogFormat *p_format, - AndroidLogPrintFormat format); - -/** - * Returns FORMAT_OFF on invalid string - */ -AndroidLogPrintFormat android_log_formatFromString(const char *s); - -/** - * filterExpression: a single filter expression - * eg "AT:d" - * - * returns 0 on success and -1 on invalid expression - * - * Assumes single threaded execution - * - */ - -int android_log_addFilterRule(AndroidLogFormat *p_format, - const char *filterExpression); - - -/** - * filterString: a whitespace-separated set of filter expressions - * eg "AT:d *:i" - * - * returns 0 on success and -1 on invalid expression - * - * Assumes single threaded execution - * - */ - -int android_log_addFilterString(AndroidLogFormat *p_format, - const char *filterString); - - -/** - * returns 1 if this log line should be printed based on its priority - * and tag, and 0 if it should not - */ -int android_log_shouldPrintLine ( - AndroidLogFormat *p_format, const char *tag, android_LogPriority pri); - - -/** - * Splits a wire-format buffer into an AndroidLogEntry - * entry allocated by caller. Pointers will point directly into buf - * - * Returns 0 on success and -1 on invalid wire format (entry will be - * in unspecified state) - */ -int android_log_processLogBuffer(struct logger_entry *buf, - AndroidLogEntry *entry); - -/** - * Like android_log_processLogBuffer, but for binary logs. - * - * If "map" is non-NULL, it will be used to convert the log tag number - * into a string. - */ -int android_log_processBinaryLogBuffer(struct logger_entry *buf, - AndroidLogEntry *entry, const EventTagMap* map, char* messageBuf, - int messageBufLen); - - -/** - * Formats a log message into a buffer - * - * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer - * If return value != defaultBuffer, caller must call free() - * Returns NULL on malloc error - */ - -char *android_log_formatLogLine ( - AndroidLogFormat *p_format, - char *defaultBuffer, - size_t defaultBufferSize, - const AndroidLogEntry *p_line, - size_t *p_outLength); - - -/** - * Either print or do not print log line, based on filter - * - * Assumes single threaded execution - * - */ -int android_log_printLogLine( - AndroidLogFormat *p_format, - int fd, - const AndroidLogEntry *entry); - - -#ifdef __cplusplus -} -#endif - - -#endif /*_LOGPRINT_H*/ diff --git a/third_party/android_system_core/include/log/uio.h b/third_party/android_system_core/include/log/uio.h deleted file mode 100644 index 7059da5f76..0000000000 --- a/third_party/android_system_core/include/log/uio.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2007-2014 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 _LIBS_CUTILS_UIO_H -#define _LIBS_CUTILS_UIO_H - -#if !defined(_WIN32) - -#include - -#else - -#ifdef __cplusplus -extern "C" { -#endif - -// -// Implementation of sys/uio.h for Win32. -// - -#include - -struct iovec { - void* iov_base; - size_t iov_len; -}; - -extern int readv( int fd, struct iovec* vecs, int count ); -extern int writev( int fd, const struct iovec* vecs, int count ); - -#ifdef __cplusplus -} -#endif - -#endif - -#endif /* _LIBS_UTILS_UIO_H */ - diff --git a/third_party/android_system_core/include/system/camera.h b/third_party/android_system_core/include/system/camera.h deleted file mode 100644 index 0570ca04c6..0000000000 --- a/third_party/android_system_core/include/system/camera.h +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright (C) 2011 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 SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H -#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H - -#include -#include -#include -#include -#include -#include - -__BEGIN_DECLS - -/** - * A set of bit masks for specifying how the received preview frames are - * handled before the previewCallback() call. - * - * The least significant 3 bits of an "int" value are used for this purpose: - * - * ..... 0 0 0 - * ^ ^ ^ - * | | |---------> determine whether the callback is enabled or not - * | |-----------> determine whether the callback is one-shot or not - * |-------------> determine whether the frame is copied out or not - * - * WARNING: When a frame is sent directly without copying, it is the frame - * receiver's responsiblity to make sure that the frame data won't get - * corrupted by subsequent preview frames filled by the camera. This flag is - * recommended only when copying out data brings significant performance price - * and the handling/processing of the received frame data is always faster than - * the preview frame rate so that data corruption won't occur. - * - * For instance, - * 1. 0x00 disables the callback. In this case, copy out and one shot bits - * are ignored. - * 2. 0x01 enables a callback without copying out the received frames. A - * typical use case is the Camcorder application to avoid making costly - * frame copies. - * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical - * use case is the Camera application. - * 4. 0x07 is enabling a callback with frame copied out only once. A typical - * use case is the Barcode scanner application. - */ - -enum { - CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01, - CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02, - CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04, - /** Typical use cases */ - CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00, - CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01, - CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05, - CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07 -}; - -/** msgType in notifyCallback and dataCallback functions */ -enum { - CAMERA_MSG_ERROR = 0x0001, // notifyCallback - CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback - CAMERA_MSG_FOCUS = 0x0004, // notifyCallback - CAMERA_MSG_ZOOM = 0x0008, // notifyCallback - CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback - CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback - CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback - CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback - CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback - CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback - // Preview frame metadata. This can be combined with - // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can - // request FRAME and METADATA. Or the apps can request only FRAME or only - // METADATA. - CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback - // Notify on autofocus start and stop. This is useful in continuous - // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. - CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback - CAMERA_MSG_VENDOR_START = 0x1000, - CAMERA_MSG_STATS_DATA = CAMERA_MSG_VENDOR_START, - CAMERA_MSG_META_DATA = 0x2000, - CAMERA_MSG_VENDOR_END = 0x8000, - CAMERA_MSG_ALL_MSGS = 0xFFFF -}; - -/** meta data type in CameraMetaDataCallback */ -enum { - CAMERA_META_DATA_ASD = 0x001, //ASD data - CAMERA_META_DATA_FD = 0x002, //FD/FP data - CAMERA_META_DATA_HDR = 0x003, //Auto HDR data -}; - -/** cmdType in sendCommand functions */ -enum { - CAMERA_CMD_START_SMOOTH_ZOOM = 1, - CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, - - /** - * Set the clockwise rotation of preview display (setPreviewDisplay) in - * degrees. This affects the preview frames and the picture displayed after - * snapshot. This method is useful for portrait mode applications. Note - * that preview display of front-facing cameras is flipped horizontally - * before the rotation, that is, the image is reflected along the central - * vertical axis of the camera sensor. So the users can see themselves as - * looking into a mirror. - * - * This does not affect the order of byte array of - * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME, - * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or - * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview - * since API level 14. - */ - CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, - - /** - * cmdType to disable/enable shutter sound. In sendCommand passing arg1 = - * 0 will disable, while passing arg1 = 1 will enable the shutter sound. - */ - CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, - - /* cmdType to play recording sound */ - CAMERA_CMD_PLAY_RECORDING_SOUND = 5, - - /** - * Start the face detection. This should be called after preview is started. - * The camera will notify the listener of CAMERA_MSG_FACE and the detected - * faces in the preview frame. The detected faces may be the same as the - * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop - * the face detection. This method is supported if CameraParameters - * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is - * bigger than 0. Hardware and software face detection should not be running - * at the same time. If the face detection has started, apps should not send - * this again. - * - * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE, - * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. - * - * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or - * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not - * supported, the HAL must return BAD_VALUE. - */ - CAMERA_CMD_START_FACE_DETECTION = 6, - - /** - * Stop the face detection. - */ - CAMERA_CMD_STOP_FACE_DETECTION = 7, - - /** - * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing - * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. - */ - CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, - - /** - * Ping camera service to see if camera hardware is released. - * - * When any camera method returns error, the client can use ping command - * to see if the camera has been taken away by other clients. If the result - * is NO_ERROR, it means the camera hardware is not released. If the result - * is not NO_ERROR, the camera has been released and the existing client - * can silently finish itself or show a dialog. - */ - CAMERA_CMD_PING = 9, - - /** - * Configure the number of video buffers used for recording. The intended - * video buffer count for recording is passed as arg1, which must be - * greater than 0. This command must be sent before recording is started. - * This command returns INVALID_OPERATION error if it is sent after video - * recording is started, or the command is not supported at all. This - * command also returns a BAD_VALUE error if the intended video buffer - * count is non-positive or too big to be realized. - */ - CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, - - /** - * Configure an explicit format to use for video recording metadata mode. - * This can be used to switch the format from the - * default IMPLEMENTATION_DEFINED gralloc format to some other - * device-supported format, and the default dataspace from the BT_709 color - * space to some other device-supported dataspace. arg1 is the HAL pixel - * format, and arg2 is the HAL dataSpace. This command returns - * INVALID_OPERATION error if it is sent after video recording is started, - * or the command is not supported at all. - * - * If the gralloc format is set to a format other than - * IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags - * of SW_READ_OFTEN. - */ -#ifndef CAMERA_VENDOR_L_COMPAT - CAMERA_CMD_SET_VIDEO_FORMAT = 11, - - CAMERA_CMD_VENDOR_START = 20, - /** - * Commands to enable/disable preview histogram - * - * Based on user's input to enable/disable histogram from the camera - * UI, send the appropriate command to the HAL to turn on/off the histogram - * stats and start sending the data to the application. - */ - CAMERA_CMD_HISTOGRAM_ON = CAMERA_CMD_VENDOR_START, - CAMERA_CMD_HISTOGRAM_OFF = CAMERA_CMD_VENDOR_START + 1, - CAMERA_CMD_HISTOGRAM_SEND_DATA = CAMERA_CMD_VENDOR_START + 2, - CAMERA_CMD_LONGSHOT_ON = CAMERA_CMD_VENDOR_START + 3, - CAMERA_CMD_LONGSHOT_OFF = CAMERA_CMD_VENDOR_START + 4, - CAMERA_CMD_STOP_LONGSHOT = CAMERA_CMD_VENDOR_START + 5, - CAMERA_CMD_METADATA_ON = CAMERA_CMD_VENDOR_START + 6, - CAMERA_CMD_METADATA_OFF = CAMERA_CMD_VENDOR_START + 7, - CAMERA_CMD_VENDOR_END = 200, -#else - - /** - * Values used by older HALs, provided as an option for compatibility - */ - CAMERA_CMD_HISTOGRAM_ON = 11, - CAMERA_CMD_HISTOGRAM_OFF = 12, - CAMERA_CMD_HISTOGRAM_SEND_DATA = 13, - CAMERA_CMD_LONGSHOT_ON = 14, - CAMERA_CMD_LONGSHOT_OFF = 15, - CAMERA_CMD_STOP_LONGSHOT = 16, - CAMERA_CMD_METADATA_ON = 100, - CAMERA_CMD_METADATA_OFF = 101, - CAMERA_CMD_SET_VIDEO_FORMAT = 102, -#endif -}; - -/** camera fatal errors */ -enum { - CAMERA_ERROR_UNKNOWN = 1, - /** - * Camera was released because another client has connected to the camera. - * The original client should call Camera::disconnect immediately after - * getting this notification. Otherwise, the camera will be released by - * camera service in a short time. The client should not call any method - * (except disconnect and sending CAMERA_CMD_PING) after getting this. - */ - CAMERA_ERROR_RELEASED = 2, - CAMERA_ERROR_SERVER_DIED = 100 -}; - -enum { - /** The facing of the camera is opposite to that of the screen. */ - CAMERA_FACING_BACK = 0, - /** The facing of the camera is the same as that of the screen. */ - CAMERA_FACING_FRONT = 1, - /** - * The facing of the camera is not fixed relative to the screen. - * The cameras with this facing are external cameras, e.g. USB cameras. - */ - CAMERA_FACING_EXTERNAL = 2 -}; - -enum { - /** Hardware face detection. It does not use much CPU. */ - CAMERA_FACE_DETECTION_HW = 0, - /** - * Software face detection. It uses some CPU. Applications must use - * Camera.setPreviewTexture for preview in this mode. - */ - CAMERA_FACE_DETECTION_SW = 1 -}; - -/** - * The information of a face from camera face detection. - */ -typedef struct camera_face { - /** - * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents - * the top-left of the camera field of view, and (1000, 1000) represents the - * bottom-right of the field of view. The width and height cannot be 0 or - * negative. This is supported by both hardware and software face detection. - * - * The direction is relative to the sensor orientation, that is, what the - * sensor sees. The direction is not affected by the rotation or mirroring - * of CAMERA_CMD_SET_DISPLAY_ORIENTATION. - */ - int32_t rect[4]; - - /** - * The confidence level of the face. The range is 1 to 100. 100 is the - * highest confidence. This is supported by both hardware and software - * face detection. - */ - int32_t score; - - /** - * An unique id per face while the face is visible to the tracker. If - * the face leaves the field-of-view and comes back, it will get a new - * id. If the value is 0, id is not supported. - */ - int32_t id; - - /** - * The coordinates of the center of the left eye. The range is -1000 to - * 1000. -2000, -2000 if this is not supported. - */ - int32_t left_eye[2]; - - /** - * The coordinates of the center of the right eye. The range is -1000 to - * 1000. -2000, -2000 if this is not supported. - */ - int32_t right_eye[2]; - - /** - * The coordinates of the center of the mouth. The range is -1000 to 1000. - * -2000, -2000 if this is not supported. - */ - int32_t mouth[2]; - int32_t smile_degree; - int32_t smile_score; - int32_t blink_detected; - int32_t face_recognised; - int32_t gaze_angle; - int32_t updown_dir; - int32_t leftright_dir; - int32_t roll_dir; - int32_t left_right_gaze; - int32_t top_bottom_gaze; - int32_t leye_blink; - int32_t reye_blink; - -} camera_face_t; - -/** - * The information of a data type received in a camera frame. - */ -typedef enum { - /** Data buffer */ - CAMERA_FRAME_DATA_BUF = 0x000, - /** File descriptor */ - CAMERA_FRAME_DATA_FD = 0x100 -} camera_frame_data_type_t; - -/** - * The metadata of the frame data. - */ -typedef struct camera_frame_metadata { - /** - * The number of detected faces in the frame. - */ - int32_t number_of_faces; - - /** - * An array of the detected faces. The length is number_of_faces. - */ - camera_face_t *faces; -} camera_frame_metadata_t; - -__END_DECLS - -#endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ diff --git a/third_party/android_system_core/include/system/graphics.h b/third_party/android_system_core/include/system/graphics.h deleted file mode 100644 index afd9f7bdb3..0000000000 --- a/third_party/android_system_core/include/system/graphics.h +++ /dev/null @@ -1,763 +0,0 @@ -/* - * Copyright (C) 2011 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 SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H -#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * If the HAL needs to create service threads to handle graphics related - * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority - * if they can block the main rendering thread in any way. - * - * the priority of the current thread can be set with: - * - * #include - * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); - * - */ - -#define HAL_PRIORITY_URGENT_DISPLAY (-8) - -/** - * pixel format definitions - */ - -enum { - /* - * "linear" color pixel formats: - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - * - * The color space determines, for example, if the formats are linear or - * gamma-corrected; or whether any special operations are performed when - * reading or writing into a buffer in one of these formats. - */ - HAL_PIXEL_FORMAT_RGBA_8888 = 1, - HAL_PIXEL_FORMAT_RGBX_8888 = 2, - HAL_PIXEL_FORMAT_RGB_888 = 3, - HAL_PIXEL_FORMAT_RGB_565 = 4, - HAL_PIXEL_FORMAT_BGRA_8888 = 5, - - /* - * 0x100 - 0x1FF - * - * This range is reserved for pixel formats that are specific to the HAL - * implementation. Implementations can use any value in this range to - * communicate video pixel formats between their HAL modules. These formats - * must not have an alpha channel. Additionally, an EGLimage created from a - * gralloc buffer of one of these formats must be supported for use with the - * GL_OES_EGL_image_external OpenGL ES extension. - */ - - /* - * Android YUV format: - * - * This format is exposed outside of the HAL to software decoders and - * applications. EGLImageKHR must support it in conjunction with the - * OES_EGL_image_external extension. - * - * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed - * by (W/2) x (H/2) Cr and Cb planes. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * y_size = stride * height - * c_stride = ALIGN(stride/2, 16) - * c_size = c_stride * height/2 - * size = y_size + c_size * 2 - * cr_offset = y_size - * cb_offset = y_size + c_size - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar - - - /* - * Android Y8 format: - * - * This format is exposed outside of the HAL to the framework. - * The expected gralloc usage flags are SW_* and HW_CAMERA_*, - * and no other HW_ flags will be used. - * - * Y8 is a YUV planar format comprised of a WxH Y plane, - * with each pixel being represented by 8 bits. - * - * It is equivalent to just the Y plane from YV12. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * size = stride * height - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_Y8 = 0x20203859, - - /* - * Android Y16 format: - * - * This format is exposed outside of the HAL to the framework. - * The expected gralloc usage flags are SW_* and HW_CAMERA_*, - * and no other HW_ flags will be used. - * - * Y16 is a YUV planar format comprised of a WxH Y plane, - * with each pixel being represented by 16 bits. - * - * It is just like Y8, but has double the bits per pixel (little endian). - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer, except that dataSpace field - * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth - * image where each sample is a distance value measured by a depth camera, - * plus an associated confidence value. - */ - HAL_PIXEL_FORMAT_Y16 = 0x20363159, - - /* - * Android RAW sensor format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW16 is a single-channel, 16-bit, little endian format, typically - * representing raw Bayer-pattern images from an image sensor, with minimal - * processing. - * - * The exact pixel layout of the data in the buffer is sensor-dependent, and - * needs to be queried from the camera device. - * - * Generally, not all 16 bits are used; more common values are 10 or 12 - * bits. If not all bits are used, the lower-order bits are filled first. - * All parameters to interpret the raw data (black and white points, - * color space, etc) must be queried from the camera device. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW16 = 0x20, - - /* - * Android RAW10 format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one - * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte - * contains the 2 least significant bits of the 4 pixels, the exact layout data - * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth - * bit of the ith pixel): - * - * bit 7 bit 0 - * =====|=====|=====|=====|=====|=====|=====|=====| - * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| - * =============================================== - * - * This format assumes - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (10 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (10 / 8), padding bytes will be present at the end of each - * row (including the last row). - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW10 = 0x25, - - /* - * Android RAW12 format: - * - * This format is exposed outside of camera HAL to applications. - * - * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first - * and second byte contains the top 8 bits of first and second pixel. The third - * byte contains the 4 least significant bits of the two pixels, the exact layout - * data for each two consecutive pixels is illustrated below (Pi[j] stands for - * the jth bit of the ith pixel): - * - * bit 7 bit 0 - * ======|======|======|======|======|======|======|======| - * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| - * ======================================================= - * - * This format assumes: - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (12 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (12 / 8), padding bytes will be present at the end of - * each row (including the last row). - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW12 = 0x26, - - /* - * Android opaque RAW format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an - * image sensor. The actual structure of buffers of this format is - * implementation-dependent. - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24, - - /* - * Android binary blob graphics buffer format: - * - * This format is used to carry task-specific data which does not have a - * standard image structure. The details of the format are left to the two - * endpoints. - * - * A typical use case is for transporting JPEG-compressed images from the - * Camera HAL to the framework or to applications. - * - * Buffers of this format must have a height of 1, and width equal to their - * size in bytes. - * - * When used with ANativeWindow, the mapping of the dataSpace field to - * buffer contents for BLOB is as follows: - * - * dataSpace value | Buffer contents - * -------------------------------+----------------------------------------- - * HAL_DATASPACE_JFIF | An encoded JPEG image - * HAL_DATASPACE_DEPTH | An android_depth_points buffer - * Other | Unsupported - * - */ - HAL_PIXEL_FORMAT_BLOB = 0x21, - - /* - * Android format indicating that the choice of format is entirely up to the - * device-specific Gralloc implementation. - * - * The Gralloc implementation should examine the usage bits passed in when - * allocating a buffer with this format, and it should derive the pixel - * format from those usage flags. This format will never be used with any - * of the GRALLOC_USAGE_SW_* usage flags. - * - * If a buffer of this format is to be used as an OpenGL ES texture, the - * framework will assume that sampling the texture will always return an - * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values). - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, - - /* - * Android flexible YCbCr 4:2:0 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * struct android_ycbcr (below) is the the struct used to describe it. - * - * This format must be accepted by the gralloc module when - * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set. - * - * This format is locked for use by gralloc's (*lock_ycbcr) method, and - * locking with the (*lock) method will return an error. - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, - - /* - * Android flexible YCbCr 4:2:2 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27, - - /* - * Android flexible YCbCr 4:4:4 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28, - - /* - * Android flexible RGB 888 formats - * - * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX - * buffer layout, while still describing the general format in a - * layout-independent manner. While called RGB, it can be - * used to describe formats with either color ordering and optional - * padding, as well as whole planar layout. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29, - - /* - * Android flexible RGBA 8888 formats - * - * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR - * buffer layout, while still describing the general format in a - * layout-independent manner. While called RGBA, it can be - * used to describe formats with any of the component orderings, as - * well as whole planar layout. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A, - - /* Legacy formats (deprecated), used by ImageFormat.java */ - HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 - HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 - HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 -}; - -/* - * Structure for describing YCbCr formats for consumption by applications. - * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. - * - * Buffer chroma subsampling is defined in the format. - * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0. - * - * Buffers must have a 8 bit depth. - * - * @y, @cb, and @cr point to the first byte of their respective planes. - * - * Stride describes the distance in bytes from the first value of one row of - * the image to the first value of the next row. It includes the width of the - * image plus padding. - * @ystride is the stride of the luma plane. - * @cstride is the stride of the chroma planes. - * - * @chroma_step is the distance in bytes from one chroma pixel value to the - * next. This is 2 bytes for semiplanar (because chroma values are interleaved - * and each chroma value is one byte) and 1 for planar. - */ - -struct android_ycbcr { - void *y; - void *cb; - void *cr; - size_t ystride; - size_t cstride; - size_t chroma_step; - - /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */ - uint32_t reserved[8]; -}; - -/** - * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB - * with dataSpace value of HAL_DATASPACE_DEPTH. - * When locking a native buffer of the above format and dataSpace value, - * the vaddr pointer can be cast to this structure. - * - * A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y, - * z) represents a measured point's position, with the coordinate system defined - * by the data source. Confidence represents the estimated likelihood that this - * measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f == - * 100% confidence. - * - * @num_points is the number of points in the list - * - * @xyz_points is the flexible array of floating-point values. - * It contains (num_points) * 4 floats. - * - * For example: - * android_depth_points d = get_depth_buffer(); - * struct { - * float x; float y; float z; float confidence; - * } firstPoint, lastPoint; - * - * firstPoint.x = d.xyzc_points[0]; - * firstPoint.y = d.xyzc_points[1]; - * firstPoint.z = d.xyzc_points[2]; - * firstPoint.confidence = d.xyzc_points[3]; - * lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0]; - * lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1]; - * lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2]; - * lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3]; - */ - -struct android_depth_points { - uint32_t num_points; - - /** reserved for future use, set to 0 by gralloc's (*lock)() */ - uint32_t reserved[8]; - - float xyzc_points[]; -}; - -/** - * Transformation definitions - * - * IMPORTANT NOTE: - * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. - * - */ - -enum { - /* flip source image horizontally (around the vertical axis) */ - HAL_TRANSFORM_FLIP_H = 0x01, - /* flip source image vertically (around the horizontal axis)*/ - HAL_TRANSFORM_FLIP_V = 0x02, - /* rotate source image 90 degrees clockwise */ - HAL_TRANSFORM_ROT_90 = 0x04, - /* rotate source image 180 degrees */ - HAL_TRANSFORM_ROT_180 = 0x03, - /* rotate source image 270 degrees clockwise */ - HAL_TRANSFORM_ROT_270 = 0x07, - /* don't use. see system/window.h */ - HAL_TRANSFORM_RESERVED = 0x08, -}; - -/** - * Dataspace Definitions - * ====================== - * - * Dataspace is the definition of how pixel values should be interpreted. - * - * For many formats, this is the colorspace of the image data, which includes - * primaries (including white point) and the transfer characteristic function, - * which describes both gamma curve and numeric range (within the bit depth). - * - * Other dataspaces include depth measurement data from a depth camera. - */ - -typedef enum android_dataspace { - /* - * Default-assumption data space, when not explicitly specified. - * - * It is safest to assume the buffer is an image with sRGB primaries and - * encoding ranges, but the consumer and/or the producer of the data may - * simply be using defaults. No automatic gamma transform should be - * expected, except for a possible display gamma transform when drawn to a - * screen. - */ - HAL_DATASPACE_UNKNOWN = 0x0, - - /* - * Arbitrary dataspace with manually defined characteristics. Definition - * for colorspaces or other meaning must be communicated separately. - * - * This is used when specifying primaries, transfer characteristics, - * etc. separately. - * - * A typical use case is in video encoding parameters (e.g. for H.264), - * where a colorspace can have separately defined primaries, transfer - * characteristics, etc. - */ - HAL_DATASPACE_ARBITRARY = 0x1, - - /* - * RGB Colorspaces - * ----------------- - * - * Primaries are given using (x,y) coordinates in the CIE 1931 definition - * of x and y specified by ISO 11664-1. - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - */ - - /* - * sRGB linear encoding: - * - * The red, green, and blue components are stored in sRGB space, but - * are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are encoded using the full range ([0,255] for 8-bit) for all - * components. - */ - HAL_DATASPACE_SRGB_LINEAR = 0x200, - - /* - * sRGB gamma encoding: - * - * The red, green and blue components are stored in sRGB space, and - * converted to linear space when read, using the standard sRGB to linear - * equation: - * - * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 - * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 - * - * When written the inverse transformation is performed: - * - * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 - * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 - * - * - * The alpha component, if present, is always stored in linear space and - * is left unmodified when read or written. - * - * The RGB primaries and the white point are the same as BT.709. - * - * The values are encoded using the full range ([0,255] for 8-bit) for all - * components. - * - */ - HAL_DATASPACE_SRGB = 0x201, - - /* - * YCbCr Colorspaces - * ----------------- - * - * Primaries are given using (x,y) coordinates in the CIE 1931 definition - * of x and y specified by ISO 11664-1. - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - */ - - /* - * JPEG File Interchange Format (JFIF) - * - * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 - * E = 4.500 L, 0.018 > L >= 0 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - * - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - HAL_DATASPACE_JFIF = 0x101, - - /* - * ITU-R Recommendation 601 (BT.601) - 625-line - * - * Standard-definition television, 625 Lines (PAL) - * - * For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 - * E = 4.500 L, 0.018 > L >= 0 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - * - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - HAL_DATASPACE_BT601_625 = 0x102, - - /* - * ITU-R Recommendation 601 (BT.601) - 525-line - * - * Standard-definition television, 525 Lines (NTSC) - * - * For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 - * E = 4.500 L, 0.018 > L >= 0 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - * - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - */ - HAL_DATASPACE_BT601_525 = 0x103, - - /* - * ITU-R Recommendation 709 (BT.709) - * - * High-definition television - * - * For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - * - * Primaries: x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - HAL_DATASPACE_BT709 = 0x104, - - /* - * The buffer contains depth ranging measurements from a depth camera. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement - * and an associated confidence value. The 3 MSBs of the sample make - * up the confidence value, and the low 13 LSBs of the sample make up - * the depth measurement. - * For the confidence section, 0 means 100% confidence, 1 means 0% - * confidence. The mapping to a linear float confidence value between - * 0.f and 1.f can be obtained with - * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; - * The depth measurement can be extracted simply with - * uint16_t range = (depthSample & 0x1FFF); - * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as - * a variable-length float (x,y,z, confidence) coordinate point list. - * The point cloud will be represented with the android_depth_points - * structure. - */ - HAL_DATASPACE_DEPTH = 0x1000 - -} android_dataspace_t; - -#ifdef __cplusplus -} -#endif - -#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ diff --git a/third_party/android_system_core/include/system/radio.h b/third_party/android_system_core/include/system/radio.h deleted file mode 100644 index a088526046..0000000000 --- a/third_party/android_system_core/include/system/radio.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (C) 2015 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_RADIO_H -#define ANDROID_RADIO_H - -#include -#include -#include -#include -#include - - -#define RADIO_NUM_BANDS_MAX 16 -#define RADIO_NUM_SPACINGS_MAX 16 -#define RADIO_STRING_LEN_MAX 128 - -/* - * Radio hardware module class. A given radio hardware module HAL is of one class - * only. The platform can not have more than one hardware module of each class. - * Current version of the framework only supports RADIO_CLASS_AM_FM. - */ -typedef enum { - RADIO_CLASS_AM_FM = 0, /* FM (including HD radio) and AM */ - RADIO_CLASS_SAT = 1, /* Satellite Radio */ - RADIO_CLASS_DT = 2, /* Digital Radio (DAB) */ -} radio_class_t; - -/* value for field "type" of radio band described in struct radio_hal_band_config */ -typedef enum { - RADIO_BAND_AM = 0, /* Amplitude Modulation band: LW, MW, SW */ - RADIO_BAND_FM = 1, /* Frequency Modulation band: FM */ - RADIO_BAND_FM_HD = 2, /* FM HD Radio / DRM (IBOC) */ - RADIO_BAND_AM_HD = 3, /* AM HD Radio / DRM (IBOC) */ -} radio_band_t; - -/* RDS variant implemented. A struct radio_hal_fm_band_config can list none or several. */ -enum { - RADIO_RDS_NONE = 0x0, - RADIO_RDS_WORLD = 0x01, - RADIO_RDS_US = 0x02, -}; -typedef unsigned int radio_rds_t; - -/* FM deemphasis variant implemented. A struct radio_hal_fm_band_config can list one or more. */ -enum { - RADIO_DEEMPHASIS_50 = 0x1, - RADIO_DEEMPHASIS_75 = 0x2, -}; -typedef unsigned int radio_deemphasis_t; - -/* Region a particular radio band configuration corresponds to. Not used at the HAL. - * Derived by the framework when converting the band descriptors retrieved from the HAL to - * individual band descriptors for each supported region. */ -typedef enum { - RADIO_REGION_NONE = -1, - RADIO_REGION_ITU_1 = 0, - RADIO_REGION_ITU_2 = 1, - RADIO_REGION_OIRT = 2, - RADIO_REGION_JAPAN = 3, - RADIO_REGION_KOREA = 4, -} radio_region_t; - -/* scanning direction for scan() and step() tuner APIs */ -typedef enum { - RADIO_DIRECTION_UP, - RADIO_DIRECTION_DOWN -} radio_direction_t; - -/* unique handle allocated to a radio module */ -typedef unsigned int radio_handle_t; - -/* Opaque meta data structure used by radio meta data API (see system/radio_metadata.h) */ -typedef struct radio_medtadata radio_metadata_t; - - -/* Additional attributes for an FM band configuration */ -typedef struct radio_hal_fm_band_config { - radio_deemphasis_t deemphasis; /* deemphasis variant */ - bool stereo; /* stereo supported */ - radio_rds_t rds; /* RDS variants supported */ - bool ta; /* Traffic Announcement supported */ - bool af; /* Alternate Frequency supported */ -} radio_hal_fm_band_config_t; - -/* Additional attributes for an AM band configuration */ -typedef struct radio_hal_am_band_config { - bool stereo; /* stereo supported */ -} radio_hal_am_band_config_t; - -/* Radio band configuration. Describes a given band supported by the radio module. - * The HAL can expose only one band per type with the the maximum range supported and all options. - * THe framework will derive the actual regions were this module can operate and expose separate - * band configurations for applications to chose from. */ -typedef struct radio_hal_band_config { - radio_band_t type; - bool antenna_connected; - unsigned int lower_limit; - unsigned int upper_limit; - unsigned int num_spacings; - unsigned int spacings[RADIO_NUM_SPACINGS_MAX]; - union { - radio_hal_fm_band_config_t fm; - radio_hal_am_band_config_t am; - }; -} radio_hal_band_config_t; - -/* Used internally by the framework to represent a band for s specific region */ -typedef struct radio_band_config { - radio_region_t region; - radio_hal_band_config_t band; -} radio_band_config_t; - - -/* Exposes properties of a given hardware radio module. - * NOTE: current framework implementation supports only one audio source (num_audio_sources = 1). - * The source corresponds to AUDIO_DEVICE_IN_FM_TUNER. - * If more than one tuner is supported (num_tuners > 1), only one can be connected to the audio - * source. */ -typedef struct radio_hal_properties { - radio_class_t class_id; /* Class of this module. E.g RADIO_CLASS_AM_FM */ - char implementor[RADIO_STRING_LEN_MAX]; /* implementor name */ - char product[RADIO_STRING_LEN_MAX]; /* product name */ - char version[RADIO_STRING_LEN_MAX]; /* product version */ - char serial[RADIO_STRING_LEN_MAX]; /* serial number (for subscription services) */ - unsigned int num_tuners; /* number of tuners controllable independently */ - unsigned int num_audio_sources; /* number of audio sources driven simultaneously */ - bool supports_capture; /* the hardware supports capture of audio source audio HAL */ - unsigned int num_bands; /* number of band descriptors */ - radio_hal_band_config_t bands[RADIO_NUM_BANDS_MAX]; /* band descriptors */ -} radio_hal_properties_t; - -/* Used internally by the framework. Same information as in struct radio_hal_properties plus a - * unique handle and one band configuration per region. */ -typedef struct radio_properties { - radio_handle_t handle; - radio_class_t class_id; - char implementor[RADIO_STRING_LEN_MAX]; - char product[RADIO_STRING_LEN_MAX]; - char version[RADIO_STRING_LEN_MAX]; - char serial[RADIO_STRING_LEN_MAX]; - unsigned int num_tuners; - unsigned int num_audio_sources; - bool supports_capture; - unsigned int num_bands; - radio_band_config_t bands[RADIO_NUM_BANDS_MAX]; -} radio_properties_t; - -/* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED. - * Contains information on currently tuned channel. - */ -typedef struct radio_program_info { - unsigned int channel; /* current channel. (e.g kHz for band type RADIO_BAND_FM) */ - unsigned int sub_channel; /* current sub channel. (used for RADIO_BAND_FM_HD) */ - bool tuned; /* tuned to a program or not */ - bool stereo; /* program is stereo or not */ - bool digital; /* digital program or not (e.g HD Radio program) */ - unsigned int signal_strength; /* signal strength from 0 to 100 */ - radio_metadata_t *metadata; /* non null if meta data are present (e.g PTY, song title ...) */ -} radio_program_info_t; - - -/* Events sent to the framework via the HAL callback. An event can notify the completion of an - * asynchronous command (configuration, tune, scan ...) or a spontaneous change (antenna connection, - * failure, AF switching, meta data reception... */ -enum { - RADIO_EVENT_HW_FAILURE = 0, /* hardware module failure. Requires reopening the tuner */ - RADIO_EVENT_CONFIG = 1, /* configuration change completed */ - RADIO_EVENT_ANTENNA = 2, /* Antenna connected, disconnected */ - RADIO_EVENT_TUNED = 3, /* tune, step, scan completed */ - RADIO_EVENT_METADATA = 4, /* New meta data received */ - RADIO_EVENT_TA = 5, /* Traffic announcement start or stop */ - RADIO_EVENT_AF_SWITCH = 6, /* Switch to Alternate Frequency */ - // begin framework only events - RADIO_EVENT_CONTROL = 100, /* loss/gain of tuner control */ - RADIO_EVENT_SERVER_DIED = 101, /* radio service died */ -}; -typedef unsigned int radio_event_type_t; - -/* Event passed to the framework by the HAL callback */ -typedef struct radio_hal_event { - radio_event_type_t type; /* event type */ - int status; /* used by RADIO_EVENT_CONFIG, RADIO_EVENT_TUNED */ - union { - bool on; /* RADIO_EVENT_ANTENNA, RADIO_EVENT_TA */ - radio_hal_band_config_t config; /* RADIO_EVENT_CONFIG */ - radio_program_info_t info; /* RADIO_EVENT_TUNED, RADIO_EVENT_AF_SWITCH */ - radio_metadata_t *metadata; /* RADIO_EVENT_METADATA */ - }; -} radio_hal_event_t; - -/* Used internally by the framework. Same information as in struct radio_hal_event */ -typedef struct radio_event { - radio_event_type_t type; - int status; - union { - bool on; - radio_band_config_t config; - radio_program_info_t info; - radio_metadata_t *metadata; /* offset from start of struct when in shared memory */ - }; -} radio_event_t; - - -static radio_rds_t radio_rds_for_region(bool rds, radio_region_t region) { - if (!rds) - return RADIO_RDS_NONE; - switch(region) { - case RADIO_REGION_ITU_1: - case RADIO_REGION_OIRT: - case RADIO_REGION_JAPAN: - case RADIO_REGION_KOREA: - return RADIO_RDS_WORLD; - case RADIO_REGION_ITU_2: - return RADIO_RDS_US; - default: - return RADIO_REGION_NONE; - } -} - -static radio_deemphasis_t radio_demephasis_for_region(radio_region_t region) { - switch(region) { - case RADIO_REGION_KOREA: - case RADIO_REGION_ITU_2: - return RADIO_DEEMPHASIS_75; - case RADIO_REGION_ITU_1: - case RADIO_REGION_OIRT: - case RADIO_REGION_JAPAN: - default: - return RADIO_DEEMPHASIS_50; - } -} - -#endif // ANDROID_RADIO_H diff --git a/third_party/android_system_core/include/system/thread_defs.h b/third_party/android_system_core/include/system/thread_defs.h deleted file mode 100644 index 377a48ce92..0000000000 --- a/third_party/android_system_core/include/system/thread_defs.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2013 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_THREAD_DEFS_H -#define ANDROID_THREAD_DEFS_H - -#include "graphics.h" - -#if defined(__cplusplus) -extern "C" { -#endif - -enum { - /* - * *********************************************** - * ** Keep in sync with android.os.Process.java ** - * *********************************************** - * - * This maps directly to the "nice" priorities we use in Android. - * A thread priority should be chosen inverse-proportionally to - * the amount of work the thread is expected to do. The more work - * a thread will do, the less favorable priority it should get so that - * it doesn't starve the system. Threads not behaving properly might - * be "punished" by the kernel. - * Use the levels below when appropriate. Intermediate values are - * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below. - */ - ANDROID_PRIORITY_LOWEST = 19, - - /* use for background tasks */ - ANDROID_PRIORITY_BACKGROUND = 10, - - /* most threads run at normal priority */ - ANDROID_PRIORITY_NORMAL = 0, - - /* threads currently running a UI that the user is interacting with */ - ANDROID_PRIORITY_FOREGROUND = -2, - - /* the main UI thread has a slightly more favorable priority */ - ANDROID_PRIORITY_DISPLAY = -4, - - /* ui service treads might want to run at a urgent display (uncommon) */ - ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, - - /* all normal audio threads */ - ANDROID_PRIORITY_AUDIO = -16, - - /* service audio threads (uncommon) */ - ANDROID_PRIORITY_URGENT_AUDIO = -19, - - /* should never be used in practice. regular process might not - * be allowed to use this level */ - ANDROID_PRIORITY_HIGHEST = -20, - - ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL, - ANDROID_PRIORITY_MORE_FAVORABLE = -1, - ANDROID_PRIORITY_LESS_FAVORABLE = +1, -}; - -#if defined(__cplusplus) -} -#endif - -#endif /* ANDROID_THREAD_DEFS_H */ diff --git a/third_party/android_system_core/include/system/window.h b/third_party/android_system_core/include/system/window.h deleted file mode 100644 index 508ce00bac..0000000000 --- a/third_party/android_system_core/include/system/window.h +++ /dev/null @@ -1,954 +0,0 @@ -/* - * Copyright (C) 2011 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 SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H -#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef __UNUSED -#define __UNUSED __attribute__((__unused__)) -#endif -#ifndef __deprecated -#define __deprecated __attribute__((__deprecated__)) -#endif - -__BEGIN_DECLS - -/*****************************************************************************/ - -#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ - (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d)) - -#define ANDROID_NATIVE_WINDOW_MAGIC \ - ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') - -#define ANDROID_NATIVE_BUFFER_MAGIC \ - ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') - -// --------------------------------------------------------------------------- - -// This #define may be used to conditionally compile device-specific code to -// support either the prior ANativeWindow interface, which did not pass libsync -// fences around, or the new interface that does. This #define is only present -// when the ANativeWindow interface does include libsync support. -#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1 - -// --------------------------------------------------------------------------- - -typedef const native_handle_t* buffer_handle_t; - -// --------------------------------------------------------------------------- - -typedef struct android_native_rect_t -{ - int32_t left; - int32_t top; - int32_t right; - int32_t bottom; -} android_native_rect_t; - -// --------------------------------------------------------------------------- - -typedef struct android_native_base_t -{ - /* a magic value defined by the actual EGL native type */ - int magic; - - /* the sizeof() of the actual EGL native type */ - int version; - - void* reserved[4]; - - /* reference-counting interface */ - void (*incRef)(struct android_native_base_t* base); - void (*decRef)(struct android_native_base_t* base); -} android_native_base_t; - -typedef struct ANativeWindowBuffer -{ -#ifdef __cplusplus - ANativeWindowBuffer() { - common.magic = ANDROID_NATIVE_BUFFER_MAGIC; - common.version = sizeof(ANativeWindowBuffer); - memset(common.reserved, 0, sizeof(common.reserved)); - } - - // Implement the methods that sp expects so that it - // can be used to automatically refcount ANativeWindowBuffer's. - void incStrong(const void* /*id*/) const { - common.incRef(const_cast(&common)); - } - void decStrong(const void* /*id*/) const { - common.decRef(const_cast(&common)); - } -#endif - - struct android_native_base_t common; - - int width; - int height; - int stride; - int format; - int usage; - - void* reserved[2]; - - buffer_handle_t handle; - - void* reserved_proc[8]; -} ANativeWindowBuffer_t; - -// Old typedef for backwards compatibility. -typedef ANativeWindowBuffer_t android_native_buffer_t; - -// --------------------------------------------------------------------------- - -/* attributes queriable with query() */ -enum { - NATIVE_WINDOW_WIDTH = 0, - NATIVE_WINDOW_HEIGHT = 1, - NATIVE_WINDOW_FORMAT = 2, - - /* The minimum number of buffers that must remain un-dequeued after a buffer - * has been queued. This value applies only if set_buffer_count was used to - * override the number of buffers and if a buffer has since been queued. - * Users of the set_buffer_count ANativeWindow method should query this - * value before calling set_buffer_count. If it is necessary to have N - * buffers simultaneously dequeued as part of the steady-state operation, - * and this query returns M then N+M buffers should be requested via - * native_window_set_buffer_count. - * - * Note that this value does NOT apply until a single buffer has been - * queued. In particular this means that it is possible to: - * - * 1. Query M = min undequeued buffers - * 2. Set the buffer count to N + M - * 3. Dequeue all N + M buffers - * 4. Cancel M buffers - * 5. Queue, dequeue, queue, dequeue, ad infinitum - */ - NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3, - - /* Check whether queueBuffer operations on the ANativeWindow send the buffer - * to the window compositor. The query sets the returned 'value' argument - * to 1 if the ANativeWindow DOES send queued buffers directly to the window - * compositor and 0 if the buffers do not go directly to the window - * compositor. - * - * This can be used to determine whether protected buffer content should be - * sent to the ANativeWindow. Note, however, that a result of 1 does NOT - * indicate that queued buffers will be protected from applications or users - * capturing their contents. If that behavior is desired then some other - * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in - * conjunction with this query. - */ - NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, - - /* Get the concrete type of a ANativeWindow. See below for the list of - * possible return values. - * - * This query should not be used outside the Android framework and will - * likely be removed in the near future. - */ - NATIVE_WINDOW_CONCRETE_TYPE = 5, - - - /* - * Default width and height of ANativeWindow buffers, these are the - * dimensions of the window buffers irrespective of the - * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window - * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. - */ - NATIVE_WINDOW_DEFAULT_WIDTH = 6, - NATIVE_WINDOW_DEFAULT_HEIGHT = 7, - - /* - * transformation that will most-likely be applied to buffers. This is only - * a hint, the actual transformation applied might be different. - * - * INTENDED USE: - * - * The transform hint can be used by a producer, for instance the GLES - * driver, to pre-rotate the rendering such that the final transformation - * in the composer is identity. This can be very useful when used in - * conjunction with the h/w composer HAL, in situations where it - * cannot handle arbitrary rotations. - * - * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) - * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. - * - * 2. The GL driver overrides the width and height of the ANW to - * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying - * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions - * according to NATIVE_WINDOW_TRANSFORM_HINT and calling - * native_window_set_buffers_dimensions(). - * - * 3. The GL driver dequeues a buffer of the new pre-rotated size. - * - * 4. The GL driver renders to the buffer such that the image is - * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT - * to the rendering. - * - * 5. The GL driver calls native_window_set_transform to apply - * inverse transformation to the buffer it just rendered. - * In order to do this, the GL driver needs - * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is - * done easily: - * - * int hintTransform, inverseTransform; - * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); - * inverseTransform = hintTransform; - * if (hintTransform & HAL_TRANSFORM_ROT_90) - * inverseTransform ^= HAL_TRANSFORM_ROT_180; - * - * - * 6. The GL driver queues the pre-transformed buffer. - * - * 7. The composer combines the buffer transform with the display - * transform. If the buffer transform happens to cancel out the - * display transform then no rotation is needed. - * - */ - NATIVE_WINDOW_TRANSFORM_HINT = 8, - - /* - * Boolean that indicates whether the consumer is running more than - * one buffer behind the producer. - */ - NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, - - /* - * The consumer gralloc usage bits currently set by the consumer. - * The values are defined in hardware/libhardware/include/gralloc.h. - */ - NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, - - /** - * Transformation that will by applied to buffers by the hwcomposer. - * This must not be set or checked by producer endpoints, and will - * disable the transform hint set in SurfaceFlinger (see - * NATIVE_WINDOW_TRANSFORM_HINT). - * - * INTENDED USE: - * Temporary - Please do not use this. This is intended only to be used - * by the camera's LEGACY mode. - * - * In situations where a SurfaceFlinger client wishes to set a transform - * that is not visible to the producer, and will always be applied in the - * hardware composer, the client can set this flag with - * native_window_set_buffers_sticky_transform. This can be used to rotate - * and flip buffers consumed by hardware composer without actually changing - * the aspect ratio of the buffers produced. - */ - NATIVE_WINDOW_STICKY_TRANSFORM = 11, - - /** - * The default data space for the buffers as set by the consumer. - * The values are defined in graphics.h. - */ - NATIVE_WINDOW_DEFAULT_DATASPACE = 12, - - /* - * Returns the age of the contents of the most recently dequeued buffer as - * the number of frames that have elapsed since it was last queued. For - * example, if the window is double-buffered, the age of any given buffer in - * steady state will be 2. If the dequeued buffer has never been queued, its - * age will be 0. - */ - NATIVE_WINDOW_BUFFER_AGE = 13, -}; - -/* Valid operations for the (*perform)() hook. - * - * Values marked as 'deprecated' are supported, but have been superceded by - * other functionality. - * - * Values marked as 'private' should be considered private to the framework. - * HAL implementation code with access to an ANativeWindow should not use these, - * as it may not interact properly with the framework's use of the - * ANativeWindow. - */ -enum { - NATIVE_WINDOW_SET_USAGE = 0, - NATIVE_WINDOW_CONNECT = 1, /* deprecated */ - NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ - NATIVE_WINDOW_SET_CROP = 3, /* private */ - NATIVE_WINDOW_SET_BUFFER_COUNT = 4, - NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ - NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, - NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, - NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, - NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, - NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ - NATIVE_WINDOW_LOCK = 11, /* private */ - NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ - NATIVE_WINDOW_API_CONNECT = 13, /* private */ - NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ - NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ - NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ - NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */ - NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, - NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19, - NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */ -}; - -/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ -enum { - /* Buffers will be queued by EGL via eglSwapBuffers after being filled using - * OpenGL ES. - */ - NATIVE_WINDOW_API_EGL = 1, - - /* Buffers will be queued after being filled using the CPU - */ - NATIVE_WINDOW_API_CPU = 2, - - /* Buffers will be queued by Stagefright after being filled by a video - * decoder. The video decoder can either be a software or hardware decoder. - */ - NATIVE_WINDOW_API_MEDIA = 3, - - /* Buffers will be queued by the the camera HAL. - */ - NATIVE_WINDOW_API_CAMERA = 4, -}; - -/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ -enum { - /* flip source image horizontally */ - NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , - /* flip source image vertically */ - NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, - /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ - NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, - /* rotate source image 180 degrees */ - NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, - /* rotate source image 270 degrees clock-wise */ - NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, - /* transforms source by the inverse transform of the screen it is displayed onto. This - * transform is applied last */ - NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 -}; - -/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ -enum { - /* the window content is not updated (frozen) until a buffer of - * the window size is received (enqueued) - */ - NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, - /* the buffer is scaled in both dimensions to match the window size */ - NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, - /* the buffer is scaled uniformly such that the smaller dimension - * of the buffer matches the window size (cropping in the process) - */ - NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, - /* the window is clipped to the size of the buffer's crop rectangle; pixels - * outside the crop rectangle are treated as if they are completely - * transparent. - */ - NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, -}; - -/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ -enum { - NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ - NATIVE_WINDOW_SURFACE = 1, /* Surface */ -}; - -/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP - * - * Special timestamp value to indicate that timestamps should be auto-generated - * by the native window when queueBuffer is called. This is equal to INT64_MIN, - * defined directly to avoid problems with C99/C++ inclusion of stdint.h. - */ -static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); - -struct ANativeWindow -{ -#ifdef __cplusplus - ANativeWindow() - : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) - { - common.magic = ANDROID_NATIVE_WINDOW_MAGIC; - common.version = sizeof(ANativeWindow); - memset(common.reserved, 0, sizeof(common.reserved)); - } - - /* Implement the methods that sp expects so that it - can be used to automatically refcount ANativeWindow's. */ - void incStrong(const void* /*id*/) const { - common.incRef(const_cast(&common)); - } - void decStrong(const void* /*id*/) const { - common.decRef(const_cast(&common)); - } -#endif - - struct android_native_base_t common; - - /* flags describing some attributes of this surface or its updater */ - const uint32_t flags; - - /* min swap interval supported by this updated */ - const int minSwapInterval; - - /* max swap interval supported by this updated */ - const int maxSwapInterval; - - /* horizontal and vertical resolution in DPI */ - const float xdpi; - const float ydpi; - - /* Some storage reserved for the OEM's driver. */ - intptr_t oem[4]; - - /* - * Set the swap interval for this surface. - * - * Returns 0 on success or -errno on error. - */ - int (*setSwapInterval)(struct ANativeWindow* window, - int interval); - - /* - * Hook called by EGL to acquire a buffer. After this call, the buffer - * is not locked, so its content cannot be modified. This call may block if - * no buffers are available. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * Returns 0 on success or -errno on error. - * - * XXX: This function is deprecated. It will continue to work for some - * time for binary compatibility, but the new dequeueBuffer function that - * outputs a fence file descriptor should be used in its place. - */ - int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, - struct ANativeWindowBuffer** buffer); - - /* - * hook called by EGL to lock a buffer. This MUST be called before modifying - * the content of a buffer. The buffer must have been acquired with - * dequeueBuffer first. - * - * Returns 0 on success or -errno on error. - * - * XXX: This function is deprecated. It will continue to work for some - * time for binary compatibility, but it is essentially a no-op, and calls - * to it should be removed. - */ - int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer); - - /* - * Hook called by EGL when modifications to the render buffer are done. - * This unlocks and post the buffer. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * Buffers MUST be queued in the same order than they were dequeued. - * - * Returns 0 on success or -errno on error. - * - * XXX: This function is deprecated. It will continue to work for some - * time for binary compatibility, but the new queueBuffer function that - * takes a fence file descriptor should be used in its place (pass a value - * of -1 for the fence file descriptor if there is no valid one to pass). - */ - int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer); - - /* - * hook used to retrieve information about the native window. - * - * Returns 0 on success or -errno on error. - */ - int (*query)(const struct ANativeWindow* window, - int what, int* value); - - /* - * hook used to perform various operations on the surface. - * (*perform)() is a generic mechanism to add functionality to - * ANativeWindow while keeping backward binary compatibility. - * - * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions - * defined below. - * - * (*perform)() returns -ENOENT if the 'what' parameter is not supported - * by the surface's implementation. - * - * See above for a list of valid operations, such as - * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT - */ - int (*perform)(struct ANativeWindow* window, - int operation, ... ); - - /* - * Hook used to cancel a buffer that has been dequeued. - * No synchronization is performed between dequeue() and cancel(), so - * either external synchronization is needed, or these functions must be - * called from the same thread. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * XXX: This function is deprecated. It will continue to work for some - * time for binary compatibility, but the new cancelBuffer function that - * takes a fence file descriptor should be used in its place (pass a value - * of -1 for the fence file descriptor if there is no valid one to pass). - */ - int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer); - - /* - * Hook called by EGL to acquire a buffer. This call may block if no - * buffers are available. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * The libsync fence file descriptor returned in the int pointed to by the - * fenceFd argument will refer to the fence that must signal before the - * dequeued buffer may be written to. A value of -1 indicates that the - * caller may access the buffer immediately without waiting on a fence. If - * a valid file descriptor is returned (i.e. any value except -1) then the - * caller is responsible for closing the file descriptor. - * - * Returns 0 on success or -errno on error. - */ - int (*dequeueBuffer)(struct ANativeWindow* window, - struct ANativeWindowBuffer** buffer, int* fenceFd); - - /* - * Hook called by EGL when modifications to the render buffer are done. - * This unlocks and post the buffer. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * The fenceFd argument specifies a libsync fence file descriptor for a - * fence that must signal before the buffer can be accessed. If the buffer - * can be accessed immediately then a value of -1 should be used. The - * caller must not use the file descriptor after it is passed to - * queueBuffer, and the ANativeWindow implementation is responsible for - * closing it. - * - * Returns 0 on success or -errno on error. - */ - int (*queueBuffer)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer, int fenceFd); - - /* - * Hook used to cancel a buffer that has been dequeued. - * No synchronization is performed between dequeue() and cancel(), so - * either external synchronization is needed, or these functions must be - * called from the same thread. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * The fenceFd argument specifies a libsync fence file decsriptor for a - * fence that must signal before the buffer can be accessed. If the buffer - * can be accessed immediately then a value of -1 should be used. - * - * Note that if the client has not waited on the fence that was returned - * from dequeueBuffer, that same fence should be passed to cancelBuffer to - * ensure that future uses of the buffer are preceded by a wait on that - * fence. The caller must not use the file descriptor after it is passed - * to cancelBuffer, and the ANativeWindow implementation is responsible for - * closing it. - * - * Returns 0 on success or -errno on error. - */ - int (*cancelBuffer)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer, int fenceFd); -}; - - /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). - * android_native_window_t is deprecated. - */ -typedef struct ANativeWindow ANativeWindow; -typedef struct ANativeWindow android_native_window_t __deprecated; - -/* - * native_window_set_usage(..., usage) - * Sets the intended usage flags for the next buffers - * acquired with (*lockBuffer)() and on. - * By default (if this function is never called), a usage of - * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE - * is assumed. - * Calling this function will usually cause following buffers to be - * reallocated. - */ - -static inline int native_window_set_usage( - struct ANativeWindow* window, int usage) -{ - return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); -} - -/* deprecated. Always returns 0. Don't call. */ -static inline int native_window_connect( - struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; - -static inline int native_window_connect( - struct ANativeWindow* window __UNUSED, int api __UNUSED) { - return 0; -} - -/* deprecated. Always returns 0. Don't call. */ -static inline int native_window_disconnect( - struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; - -static inline int native_window_disconnect( - struct ANativeWindow* window __UNUSED, int api __UNUSED) { - return 0; -} - -/* - * native_window_set_crop(..., crop) - * Sets which region of the next queued buffers needs to be considered. - * Depending on the scaling mode, a buffer's crop region is scaled and/or - * cropped to match the surface's size. This function sets the crop in - * pre-transformed buffer pixel coordinates. - * - * The specified crop region applies to all buffers queued after it is called. - * - * If 'crop' is NULL, subsequently queued buffers won't be cropped. - * - * An error is returned if for instance the crop region is invalid, out of the - * buffer's bound or if the window is invalid. - */ -static inline int native_window_set_crop( - struct ANativeWindow* window, - android_native_rect_t const * crop) -{ - return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); -} - -/* - * native_window_set_post_transform_crop(..., crop) - * Sets which region of the next queued buffers needs to be considered. - * Depending on the scaling mode, a buffer's crop region is scaled and/or - * cropped to match the surface's size. This function sets the crop in - * post-transformed pixel coordinates. - * - * The specified crop region applies to all buffers queued after it is called. - * - * If 'crop' is NULL, subsequently queued buffers won't be cropped. - * - * An error is returned if for instance the crop region is invalid, out of the - * buffer's bound or if the window is invalid. - */ -static inline int native_window_set_post_transform_crop( - struct ANativeWindow* window, - android_native_rect_t const * crop) -{ - return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop); -} - -/* - * native_window_set_active_rect(..., active_rect) - * - * This function is deprecated and will be removed soon. For now it simply - * sets the post-transform crop for compatibility while multi-project commits - * get checked. - */ -static inline int native_window_set_active_rect( - struct ANativeWindow* window, - android_native_rect_t const * active_rect) __deprecated; - -static inline int native_window_set_active_rect( - struct ANativeWindow* window, - android_native_rect_t const * active_rect) -{ - return native_window_set_post_transform_crop(window, active_rect); -} - -/* - * native_window_set_buffer_count(..., count) - * Sets the number of buffers associated with this native window. - */ -static inline int native_window_set_buffer_count( - struct ANativeWindow* window, - size_t bufferCount) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); -} - -/* - * native_window_set_buffers_geometry(..., int w, int h, int format) - * All buffers dequeued after this call will have the dimensions and format - * specified. A successful call to this function has the same effect as calling - * native_window_set_buffers_size and native_window_set_buffers_format. - * - * XXX: This function is deprecated. The native_window_set_buffers_dimensions - * and native_window_set_buffers_format functions should be used instead. - */ -static inline int native_window_set_buffers_geometry( - struct ANativeWindow* window, - int w, int h, int format) __deprecated; - -static inline int native_window_set_buffers_geometry( - struct ANativeWindow* window, - int w, int h, int format) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, - w, h, format); -} - -/* - * native_window_set_buffers_dimensions(..., int w, int h) - * All buffers dequeued after this call will have the dimensions specified. - * In particular, all buffers will have a fixed-size, independent from the - * native-window size. They will be scaled according to the scaling mode - * (see native_window_set_scaling_mode) upon window composition. - * - * If w and h are 0, the normal behavior is restored. That is, dequeued buffers - * following this call will be sized to match the window's size. - * - * Calling this function will reset the window crop to a NULL value, which - * disables cropping of the buffers. - */ -static inline int native_window_set_buffers_dimensions( - struct ANativeWindow* window, - int w, int h) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, - w, h); -} - -/* - * native_window_set_buffers_user_dimensions(..., int w, int h) - * - * Sets the user buffer size for the window, which overrides the - * window's size. All buffers dequeued after this call will have the - * dimensions specified unless overridden by - * native_window_set_buffers_dimensions. All buffers will have a - * fixed-size, independent from the native-window size. They will be - * scaled according to the scaling mode (see - * native_window_set_scaling_mode) upon window composition. - * - * If w and h are 0, the normal behavior is restored. That is, the - * default buffer size will match the windows's size. - * - * Calling this function will reset the window crop to a NULL value, which - * disables cropping of the buffers. - */ -static inline int native_window_set_buffers_user_dimensions( - struct ANativeWindow* window, - int w, int h) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, - w, h); -} - -/* - * native_window_set_buffers_format(..., int format) - * All buffers dequeued after this call will have the format specified. - * - * If the specified format is 0, the default buffer format will be used. - */ -static inline int native_window_set_buffers_format( - struct ANativeWindow* window, - int format) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); -} - -/* - * native_window_set_buffers_data_space(..., int dataSpace) - * All buffers queued after this call will be associated with the dataSpace - * parameter specified. - * - * dataSpace specifies additional information about the buffer that's dependent - * on the buffer format and the endpoints. For example, it can be used to convey - * the color space of the image data in the buffer, or it can be used to - * indicate that the buffers contain depth measurement data instead of color - * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been - * overridden by the consumer. - */ -static inline int native_window_set_buffers_data_space( - struct ANativeWindow* window, - android_dataspace_t dataSpace) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, - dataSpace); -} - -/* - * native_window_set_buffers_transform(..., int transform) - * All buffers queued after this call will be displayed transformed according - * to the transform parameter specified. - */ -static inline int native_window_set_buffers_transform( - struct ANativeWindow* window, - int transform) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, - transform); -} - -/* - * native_window_set_buffers_sticky_transform(..., int transform) - * All buffers queued after this call will be displayed transformed according - * to the transform parameter specified applied on top of the regular buffer - * transform. Setting this transform will disable the transform hint. - * - * Temporary - This is only intended to be used by the LEGACY camera mode, do - * not use this for anything else. - */ -static inline int native_window_set_buffers_sticky_transform( - struct ANativeWindow* window, - int transform) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, - transform); -} - -/* - * native_window_set_buffers_timestamp(..., int64_t timestamp) - * All buffers queued after this call will be associated with the timestamp - * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO - * (the default), timestamps will be generated automatically when queueBuffer is - * called. The timestamp is measured in nanoseconds, and is normally monotonically - * increasing. The timestamp should be unaffected by time-of-day adjustments, - * and for a camera should be strictly monotonic but for a media player may be - * reset when the position is set. - */ -static inline int native_window_set_buffers_timestamp( - struct ANativeWindow* window, - int64_t timestamp) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, - timestamp); -} - -/* - * native_window_set_scaling_mode(..., int mode) - * All buffers queued after this call will be associated with the scaling mode - * specified. - */ -static inline int native_window_set_scaling_mode( - struct ANativeWindow* window, - int mode) -{ - return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, - mode); -} - -/* - * native_window_api_connect(..., int api) - * connects an API to this window. only one API can be connected at a time. - * Returns -EINVAL if for some reason the window cannot be connected, which - * can happen if it's connected to some other API. - */ -static inline int native_window_api_connect( - struct ANativeWindow* window, int api) -{ - return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); -} - -/* - * native_window_api_disconnect(..., int api) - * disconnect the API from this window. - * An error is returned if for instance the window wasn't connected in the - * first place. - */ -static inline int native_window_api_disconnect( - struct ANativeWindow* window, int api) -{ - return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); -} - -/* - * native_window_dequeue_buffer_and_wait(...) - * Dequeue a buffer and wait on the fence associated with that buffer. The - * buffer may safely be accessed immediately upon this function returning. An - * error is returned if either of the dequeue or the wait operations fail. - */ -static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, - struct ANativeWindowBuffer** anb) { - return anw->dequeueBuffer_DEPRECATED(anw, anb); -} - -/* - * native_window_set_sideband_stream(..., native_handle_t*) - * Attach a sideband buffer stream to a native window. - */ -static inline int native_window_set_sideband_stream( - struct ANativeWindow* window, - native_handle_t* sidebandHandle) -{ - return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, - sidebandHandle); -} - -/* - * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) - * Set the surface damage (i.e., the region of the surface that has changed - * since the previous frame). The damage set by this call will be reset (to the - * default of full-surface damage) after calling queue, so this must be called - * prior to every frame with damage that does not cover the whole surface if the - * caller desires downstream consumers to use this optimization. - * - * The damage region is specified as an array of rectangles, with the important - * caveat that the origin of the surface is considered to be the bottom-left - * corner, as in OpenGL ES. - * - * If numRects is set to 0, rects may be NULL, and the surface damage will be - * set to the full surface (the same as if this function had not been called for - * this frame). - */ -static inline int native_window_set_surface_damage( - struct ANativeWindow* window, - const android_native_rect_t* rects, size_t numRects) -{ - return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, - rects, numRects); -} - -__END_DECLS - -#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ diff --git a/third_party/android_system_core/include/utils/AndroidThreads.h b/third_party/android_system_core/include/utils/AndroidThreads.h deleted file mode 100644 index aad1e82cb7..0000000000 --- a/third_party/android_system_core/include/utils/AndroidThreads.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_UTILS_ANDROID_THREADS_H -#define _LIBS_UTILS_ANDROID_THREADS_H - -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include - -// --------------------------------------------------------------------------- -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -// Create and run a new thread. -extern int androidCreateThread(android_thread_func_t, void *); - -// Create thread with lots of parameters -extern int androidCreateThreadEtc(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -// Get some sort of unique identifier for the current thread. -extern android_thread_id_t androidGetThreadId(); - -// Low-level thread creation -- never creates threads that can -// interact with the Java VM. -extern int androidCreateRawThreadEtc(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -// set the same of the running thread -extern void androidSetThreadName(const char* name); - -// Used by the Java Runtime to control how threads are created, so that -// they can be proper and lovely Java threads. -typedef int (*android_create_thread_fn)(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -extern void androidSetCreateThreadFunc(android_create_thread_fn func); - -// ------------------------------------------------------------------ -// Extra functions working with raw pids. - -#ifdef HAVE_ANDROID_OS -// Change the priority AND scheduling group of a particular thread. The priority -// should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION -// if the priority set failed, else another value if just the group set failed; -// in either case errno is set. Thread ID zero means current thread. -extern int androidSetThreadPriority(pid_t tid, int prio); - -// Get the current priority of a particular thread. Returns one of the -// ANDROID_PRIORITY constants or a negative result in case of error. -extern int androidGetThreadPriority(pid_t tid); -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -// ---------------------------------------------------------------------------- -// C++ API -#ifdef __cplusplus -namespace android { -// ---------------------------------------------------------------------------- - -// Create and run a new thread. -inline bool createThread(thread_func_t f, void *a) { - return androidCreateThread(f, a) ? true : false; -} - -// Create thread with lots of parameters -inline bool createThreadEtc(thread_func_t entryFunction, - void *userData, - const char* threadName = "android:unnamed_thread", - int32_t threadPriority = PRIORITY_DEFAULT, - size_t threadStackSize = 0, - thread_id_t *threadId = 0) -{ - return androidCreateThreadEtc(entryFunction, userData, threadName, - threadPriority, threadStackSize, threadId) ? true : false; -} - -// Get some sort of unique identifier for the current thread. -inline thread_id_t getThreadId() { - return androidGetThreadId(); -} - -// ---------------------------------------------------------------------------- -}; // namespace android -#endif // __cplusplus -// ---------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_ANDROID_THREADS_H diff --git a/third_party/android_system_core/include/utils/Atomic.h b/third_party/android_system_core/include/utils/Atomic.h deleted file mode 100644 index 7eb476c94e..0000000000 --- a/third_party/android_system_core/include/utils/Atomic.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2005 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_UTILS_ATOMIC_H -#define ANDROID_UTILS_ATOMIC_H - -#include - -#endif // ANDROID_UTILS_ATOMIC_H diff --git a/third_party/android_system_core/include/utils/BasicHashtable.h b/third_party/android_system_core/include/utils/BasicHashtable.h deleted file mode 100644 index c235d62526..0000000000 --- a/third_party/android_system_core/include/utils/BasicHashtable.h +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright (C) 2011 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_BASIC_HASHTABLE_H -#define ANDROID_BASIC_HASHTABLE_H - -#include -#include -#include -#include - -namespace android { - -/* Implementation type. Nothing to see here. */ -class BasicHashtableImpl { -protected: - struct Bucket { - // The collision flag indicates that the bucket is part of a collision chain - // such that at least two entries both hash to this bucket. When true, we - // may need to seek further along the chain to find the entry. - static const uint32_t COLLISION = 0x80000000UL; - - // The present flag indicates that the bucket contains an initialized entry value. - static const uint32_t PRESENT = 0x40000000UL; - - // Mask for 30 bits worth of the hash code that are stored within the bucket to - // speed up lookups and rehashing by eliminating the need to recalculate the - // hash code of the entry's key. - static const uint32_t HASH_MASK = 0x3fffffffUL; - - // Combined value that stores the collision and present flags as well as - // a 30 bit hash code. - uint32_t cookie; - - // Storage for the entry begins here. - char entry[0]; - }; - - BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor, - size_t minimumInitialCapacity, float loadFactor); - BasicHashtableImpl(const BasicHashtableImpl& other); - virtual ~BasicHashtableImpl(); - - void dispose(); - - inline void edit() { - if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) { - clone(); - } - } - - void setTo(const BasicHashtableImpl& other); - void clear(); - - ssize_t next(ssize_t index) const; - ssize_t find(ssize_t index, hash_t hash, const void* __restrict__ key) const; - size_t add(hash_t hash, const void* __restrict__ entry); - void removeAt(size_t index); - void rehash(size_t minimumCapacity, float loadFactor); - - const size_t mBucketSize; // number of bytes per bucket including the entry - const bool mHasTrivialDestructor; // true if the entry type does not require destruction - size_t mCapacity; // number of buckets that can be filled before exceeding load factor - float mLoadFactor; // load factor - size_t mSize; // number of elements actually in the table - size_t mFilledBuckets; // number of buckets for which collision or present is true - size_t mBucketCount; // number of slots in the mBuckets array - void* mBuckets; // array of buckets, as a SharedBuffer - - inline const Bucket& bucketAt(const void* __restrict__ buckets, size_t index) const { - return *reinterpret_cast( - static_cast(buckets) + index * mBucketSize); - } - - inline Bucket& bucketAt(void* __restrict__ buckets, size_t index) const { - return *reinterpret_cast(static_cast(buckets) + index * mBucketSize); - } - - virtual bool compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const = 0; - virtual void initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const = 0; - virtual void destroyBucketEntry(Bucket& bucket) const = 0; - -private: - void clone(); - - // Allocates a bucket array as a SharedBuffer. - void* allocateBuckets(size_t count) const; - - // Releases a bucket array's associated SharedBuffer. - void releaseBuckets(void* __restrict__ buckets, size_t count) const; - - // Destroys the contents of buckets (invokes destroyBucketEntry for each - // populated bucket if needed). - void destroyBuckets(void* __restrict__ buckets, size_t count) const; - - // Copies the content of buckets (copies the cookie and invokes copyBucketEntry - // for each populated bucket if needed). - void copyBuckets(const void* __restrict__ fromBuckets, - void* __restrict__ toBuckets, size_t count) const; - - // Determines the appropriate size of a bucket array to store a certain minimum - // number of entries and returns its effective capacity. - static void determineCapacity(size_t minimumCapacity, float loadFactor, - size_t* __restrict__ outBucketCount, size_t* __restrict__ outCapacity); - - // Trim a hash code to 30 bits to match what we store in the bucket's cookie. - inline static hash_t trimHash(hash_t hash) { - return (hash & Bucket::HASH_MASK) ^ (hash >> 30); - } - - // Returns the index of the first bucket that is in the collision chain - // for the specified hash code, given the total number of buckets. - // (Primary hash) - inline static size_t chainStart(hash_t hash, size_t count) { - return hash % count; - } - - // Returns the increment to add to a bucket index to seek to the next bucket - // in the collision chain for the specified hash code, given the total number of buckets. - // (Secondary hash) - inline static size_t chainIncrement(hash_t hash, size_t count) { - return ((hash >> 7) | (hash << 25)) % (count - 1) + 1; - } - - // Returns the index of the next bucket that is in the collision chain - // that is defined by the specified increment, given the total number of buckets. - inline static size_t chainSeek(size_t index, size_t increment, size_t count) { - return (index + increment) % count; - } -}; - -/* - * A BasicHashtable stores entries that are indexed by hash code in place - * within an array. The basic operations are finding entries by key, - * adding new entries and removing existing entries. - * - * This class provides a very limited set of operations with simple semantics. - * It is intended to be used as a building block to construct more complex - * and interesting data structures such as HashMap. Think very hard before - * adding anything extra to BasicHashtable, it probably belongs at a - * higher level of abstraction. - * - * TKey: The key type. - * TEntry: The entry type which is what is actually stored in the array. - * - * TKey must support the following contract: - * bool operator==(const TKey& other) const; // return true if equal - * bool operator!=(const TKey& other) const; // return true if unequal - * - * TEntry must support the following contract: - * const TKey& getKey() const; // get the key from the entry - * - * This class supports storing entries with duplicate keys. Of course, it can't - * tell them apart during removal so only the first entry will be removed. - * We do this because it means that operations like add() can't fail. - */ -template -class BasicHashtable : private BasicHashtableImpl { -public: - /* Creates a hashtable with the specified minimum initial capacity. - * The underlying array will be created when the first entry is added. - * - * minimumInitialCapacity: The minimum initial capacity for the hashtable. - * Default is 0. - * loadFactor: The desired load factor for the hashtable, between 0 and 1. - * Default is 0.75. - */ - BasicHashtable(size_t minimumInitialCapacity = 0, float loadFactor = 0.75f); - - /* Copies a hashtable. - * The underlying storage is shared copy-on-write. - */ - BasicHashtable(const BasicHashtable& other); - - /* Clears and destroys the hashtable. - */ - virtual ~BasicHashtable(); - - /* Making this hashtable a copy of the other hashtable. - * The underlying storage is shared copy-on-write. - * - * other: The hashtable to copy. - */ - inline BasicHashtable& operator =(const BasicHashtable & other) { - setTo(other); - return *this; - } - - /* Returns the number of entries in the hashtable. - */ - inline size_t size() const { - return mSize; - } - - /* Returns the capacity of the hashtable, which is the number of elements that can - * added to the hashtable without requiring it to be grown. - */ - inline size_t capacity() const { - return mCapacity; - } - - /* Returns the number of buckets that the hashtable has, which is the size of its - * underlying array. - */ - inline size_t bucketCount() const { - return mBucketCount; - } - - /* Returns the load factor of the hashtable. */ - inline float loadFactor() const { - return mLoadFactor; - }; - - /* Returns a const reference to the entry at the specified index. - * - * index: The index of the entry to retrieve. Must be a valid index within - * the bounds of the hashtable. - */ - inline const TEntry& entryAt(size_t index) const { - return entryFor(bucketAt(mBuckets, index)); - } - - /* Returns a non-const reference to the entry at the specified index. - * - * index: The index of the entry to edit. Must be a valid index within - * the bounds of the hashtable. - */ - inline TEntry& editEntryAt(size_t index) { - edit(); - return entryFor(bucketAt(mBuckets, index)); - } - - /* Clears the hashtable. - * All entries in the hashtable are destroyed immediately. - * If you need to do something special with the entries in the hashtable then iterate - * over them and do what you need before clearing the hashtable. - */ - inline void clear() { - BasicHashtableImpl::clear(); - } - - /* Returns the index of the next entry in the hashtable given the index of a previous entry. - * If the given index is -1, then returns the index of the first entry in the hashtable, - * if there is one, or -1 otherwise. - * If the given index is not -1, then returns the index of the next entry in the hashtable, - * in strictly increasing order, or -1 if there are none left. - * - * index: The index of the previous entry that was iterated, or -1 to begin - * iteration at the beginning of the hashtable. - */ - inline ssize_t next(ssize_t index) const { - return BasicHashtableImpl::next(index); - } - - /* Finds the index of an entry with the specified key. - * If the given index is -1, then returns the index of the first matching entry, - * otherwise returns the index of the next matching entry. - * If the hashtable contains multiple entries with keys that match the requested - * key, then the sequence of entries returned is arbitrary. - * Returns -1 if no entry was found. - * - * index: The index of the previous entry with the specified key, or -1 to - * find the first matching entry. - * hash: The hashcode of the key. - * key: The key. - */ - inline ssize_t find(ssize_t index, hash_t hash, const TKey& key) const { - return BasicHashtableImpl::find(index, hash, &key); - } - - /* Adds the entry to the hashtable. - * Returns the index of the newly added entry. - * If an entry with the same key already exists, then a duplicate entry is added. - * If the entry will not fit, then the hashtable's capacity is increased and - * its contents are rehashed. See rehash(). - * - * hash: The hashcode of the key. - * entry: The entry to add. - */ - inline size_t add(hash_t hash, const TEntry& entry) { - return BasicHashtableImpl::add(hash, &entry); - } - - /* Removes the entry with the specified index from the hashtable. - * The entry is destroyed immediately. - * The index must be valid. - * - * The hashtable is not compacted after an item is removed, so it is legal - * to continue iterating over the hashtable using next() or find(). - * - * index: The index of the entry to remove. Must be a valid index within the - * bounds of the hashtable, and it must refer to an existing entry. - */ - inline void removeAt(size_t index) { - BasicHashtableImpl::removeAt(index); - } - - /* Rehashes the contents of the hashtable. - * Grows the hashtable to at least the specified minimum capacity or the - * current number of elements, whichever is larger. - * - * Rehashing causes all entries to be copied and the entry indices may change. - * Although the hash codes are cached by the hashtable, rehashing can be an - * expensive operation and should be avoided unless the hashtable's size - * needs to be changed. - * - * Rehashing is the only way to change the capacity or load factor of the - * hashtable once it has been created. It can be used to compact the - * hashtable by choosing a minimum capacity that is smaller than the current - * capacity (such as 0). - * - * minimumCapacity: The desired minimum capacity after rehashing. - * loadFactor: The desired load factor after rehashing. - */ - inline void rehash(size_t minimumCapacity, float loadFactor) { - BasicHashtableImpl::rehash(minimumCapacity, loadFactor); - } - - /* Determines whether there is room to add another entry without rehashing. - * When this returns true, a subsequent add() operation is guaranteed to - * complete without performing a rehash. - */ - inline bool hasMoreRoom() const { - return mCapacity > mFilledBuckets; - } - -protected: - static inline const TEntry& entryFor(const Bucket& bucket) { - return reinterpret_cast(bucket.entry); - } - - static inline TEntry& entryFor(Bucket& bucket) { - return reinterpret_cast(bucket.entry); - } - - virtual bool compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const; - virtual void initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const; - virtual void destroyBucketEntry(Bucket& bucket) const; - -private: - // For dumping the raw contents of a hashtable during testing. - friend class BasicHashtableTest; - inline uint32_t cookieAt(size_t index) const { - return bucketAt(mBuckets, index).cookie; - } -}; - -template -BasicHashtable::BasicHashtable(size_t minimumInitialCapacity, float loadFactor) : - BasicHashtableImpl(sizeof(TEntry), traits::has_trivial_dtor, - minimumInitialCapacity, loadFactor) { -} - -template -BasicHashtable::BasicHashtable(const BasicHashtable& other) : - BasicHashtableImpl(other) { -} - -template -BasicHashtable::~BasicHashtable() { - dispose(); -} - -template -bool BasicHashtable::compareBucketKey(const Bucket& bucket, - const void* __restrict__ key) const { - return entryFor(bucket).getKey() == *static_cast(key); -} - -template -void BasicHashtable::initializeBucketEntry(Bucket& bucket, - const void* __restrict__ entry) const { - if (!traits::has_trivial_copy) { - new (&entryFor(bucket)) TEntry(*(static_cast(entry))); - } else { - memcpy(&entryFor(bucket), entry, sizeof(TEntry)); - } -} - -template -void BasicHashtable::destroyBucketEntry(Bucket& bucket) const { - if (!traits::has_trivial_dtor) { - entryFor(bucket).~TEntry(); - } -} - -}; // namespace android - -#endif // ANDROID_BASIC_HASHTABLE_H diff --git a/third_party/android_system_core/include/utils/BitSet.h b/third_party/android_system_core/include/utils/BitSet.h deleted file mode 100644 index 8c612931de..0000000000 --- a/third_party/android_system_core/include/utils/BitSet.h +++ /dev/null @@ -1,294 +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 UTILS_BITSET_H -#define UTILS_BITSET_H - -#include -#include - -/* - * Contains some bit manipulation helpers. - */ - -namespace android { - -// A simple set of 32 bits that can be individually marked or cleared. -struct BitSet32 { - uint32_t value; - - inline BitSet32() : value(0UL) { } - explicit inline BitSet32(uint32_t value) : value(value) { } - - // Gets the value associated with a particular bit index. - static inline uint32_t valueForBit(uint32_t n) { return 0x80000000UL >> n; } - - // Clears the bit set. - inline void clear() { clear(value); } - - static inline void clear(uint32_t& value) { value = 0UL; } - - // Returns the number of marked bits in the set. - inline uint32_t count() const { return count(value); } - - static inline uint32_t count(uint32_t value) { return __builtin_popcountl(value); } - - // Returns true if the bit set does not contain any marked bits. - inline bool isEmpty() const { return isEmpty(value); } - - static inline bool isEmpty(uint32_t value) { return ! value; } - - // Returns true if the bit set does not contain any unmarked bits. - inline bool isFull() const { return isFull(value); } - - static inline bool isFull(uint32_t value) { return value == 0xffffffffUL; } - - // Returns true if the specified bit is marked. - inline bool hasBit(uint32_t n) const { return hasBit(value, n); } - - static inline bool hasBit(uint32_t value, uint32_t n) { return value & valueForBit(n); } - - // Marks the specified bit. - inline void markBit(uint32_t n) { markBit(value, n); } - - static inline void markBit (uint32_t& value, uint32_t n) { value |= valueForBit(n); } - - // Clears the specified bit. - inline void clearBit(uint32_t n) { clearBit(value, n); } - - static inline void clearBit(uint32_t& value, uint32_t n) { value &= ~ valueForBit(n); } - - // Finds the first marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } - - static uint32_t firstMarkedBit(uint32_t value) { return clz_checked(value); } - - // Finds the first unmarked bit in the set. - // Result is undefined if all bits are marked. - inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } - - static inline uint32_t firstUnmarkedBit(uint32_t value) { return clz_checked(~ value); } - - // Finds the last marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } - - static inline uint32_t lastMarkedBit(uint32_t value) { return 31 - ctz_checked(value); } - - // Finds the first marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } - - static inline uint32_t clearFirstMarkedBit(uint32_t& value) { - uint32_t n = firstMarkedBit(value); - clearBit(value, n); - return n; - } - - // Finds the first unmarked bit in the set and marks it. Returns the bit index. - // Result is undefined if all bits are marked. - inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } - - static inline uint32_t markFirstUnmarkedBit(uint32_t& value) { - uint32_t n = firstUnmarkedBit(value); - markBit(value, n); - return n; - } - - // Finds the last marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } - - static inline uint32_t clearLastMarkedBit(uint32_t& value) { - uint32_t n = lastMarkedBit(value); - clearBit(value, n); - return n; - } - - // Gets the index of the specified bit in the set, which is the number of - // marked bits that appear before the specified bit. - inline uint32_t getIndexOfBit(uint32_t n) const { - return getIndexOfBit(value, n); - } - - static inline uint32_t getIndexOfBit(uint32_t value, uint32_t n) { - return __builtin_popcountl(value & ~(0xffffffffUL >> n)); - } - - inline bool operator== (const BitSet32& other) const { return value == other.value; } - inline bool operator!= (const BitSet32& other) const { return value != other.value; } - inline BitSet32 operator& (const BitSet32& other) const { - return BitSet32(value & other.value); - } - inline BitSet32& operator&= (const BitSet32& other) { - value &= other.value; - return *this; - } - inline BitSet32 operator| (const BitSet32& other) const { - return BitSet32(value | other.value); - } - inline BitSet32& operator|= (const BitSet32& other) { - value |= other.value; - return *this; - } - -private: - // We use these helpers as the signature of __builtin_c{l,t}z has "unsigned int" for the - // input, which is only guaranteed to be 16b, not 32. The compiler should optimize this away. - static inline uint32_t clz_checked(uint32_t value) { - if (sizeof(unsigned int) == sizeof(uint32_t)) { - return __builtin_clz(value); - } else { - return __builtin_clzl(value); - } - } - - static inline uint32_t ctz_checked(uint32_t value) { - if (sizeof(unsigned int) == sizeof(uint32_t)) { - return __builtin_ctz(value); - } else { - return __builtin_ctzl(value); - } - } -}; - -ANDROID_BASIC_TYPES_TRAITS(BitSet32) - -// A simple set of 64 bits that can be individually marked or cleared. -struct BitSet64 { - uint64_t value; - - inline BitSet64() : value(0ULL) { } - explicit inline BitSet64(uint64_t value) : value(value) { } - - // Gets the value associated with a particular bit index. - static inline uint64_t valueForBit(uint32_t n) { return 0x8000000000000000ULL >> n; } - - // Clears the bit set. - inline void clear() { clear(value); } - - static inline void clear(uint64_t& value) { value = 0ULL; } - - // Returns the number of marked bits in the set. - inline uint32_t count() const { return count(value); } - - static inline uint32_t count(uint64_t value) { return __builtin_popcountll(value); } - - // Returns true if the bit set does not contain any marked bits. - inline bool isEmpty() const { return isEmpty(value); } - - static inline bool isEmpty(uint64_t value) { return ! value; } - - // Returns true if the bit set does not contain any unmarked bits. - inline bool isFull() const { return isFull(value); } - - static inline bool isFull(uint64_t value) { return value == 0xffffffffffffffffULL; } - - // Returns true if the specified bit is marked. - inline bool hasBit(uint32_t n) const { return hasBit(value, n); } - - static inline bool hasBit(uint64_t value, uint32_t n) { return value & valueForBit(n); } - - // Marks the specified bit. - inline void markBit(uint32_t n) { markBit(value, n); } - - static inline void markBit(uint64_t& value, uint32_t n) { value |= valueForBit(n); } - - // Clears the specified bit. - inline void clearBit(uint32_t n) { clearBit(value, n); } - - static inline void clearBit(uint64_t& value, uint32_t n) { value &= ~ valueForBit(n); } - - // Finds the first marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } - - static inline uint32_t firstMarkedBit(uint64_t value) { return __builtin_clzll(value); } - - // Finds the first unmarked bit in the set. - // Result is undefined if all bits are marked. - inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } - - static inline uint32_t firstUnmarkedBit(uint64_t value) { return __builtin_clzll(~ value); } - - // Finds the last marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } - - static inline uint32_t lastMarkedBit(uint64_t value) { return 63 - __builtin_ctzll(value); } - - // Finds the first marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } - - static inline uint32_t clearFirstMarkedBit(uint64_t& value) { - uint64_t n = firstMarkedBit(value); - clearBit(value, n); - return n; - } - - // Finds the first unmarked bit in the set and marks it. Returns the bit index. - // Result is undefined if all bits are marked. - inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } - - static inline uint32_t markFirstUnmarkedBit(uint64_t& value) { - uint64_t n = firstUnmarkedBit(value); - markBit(value, n); - return n; - } - - // Finds the last marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } - - static inline uint32_t clearLastMarkedBit(uint64_t& value) { - uint64_t n = lastMarkedBit(value); - clearBit(value, n); - return n; - } - - // Gets the index of the specified bit in the set, which is the number of - // marked bits that appear before the specified bit. - inline uint32_t getIndexOfBit(uint32_t n) const { return getIndexOfBit(value, n); } - - static inline uint32_t getIndexOfBit(uint64_t value, uint32_t n) { - return __builtin_popcountll(value & ~(0xffffffffffffffffULL >> n)); - } - - inline bool operator== (const BitSet64& other) const { return value == other.value; } - inline bool operator!= (const BitSet64& other) const { return value != other.value; } - inline BitSet64 operator& (const BitSet64& other) const { - return BitSet64(value & other.value); - } - inline BitSet64& operator&= (const BitSet64& other) { - value &= other.value; - return *this; - } - inline BitSet64 operator| (const BitSet64& other) const { - return BitSet64(value | other.value); - } - inline BitSet64& operator|= (const BitSet64& other) { - value |= other.value; - return *this; - } -}; - -ANDROID_BASIC_TYPES_TRAITS(BitSet64) - -} // namespace android - -#endif // UTILS_BITSET_H diff --git a/third_party/android_system_core/include/utils/BlobCache.h b/third_party/android_system_core/include/utils/BlobCache.h deleted file mode 100644 index 65dca9fb45..0000000000 --- a/third_party/android_system_core/include/utils/BlobCache.h +++ /dev/null @@ -1,249 +0,0 @@ -/* - ** Copyright 2011, 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_BLOB_CACHE_H -#define ANDROID_BLOB_CACHE_H - -#include - -#include -#include -#include -#include - -namespace android { - -// A BlobCache is an in-memory cache for binary key/value pairs. A BlobCache -// does NOT provide any thread-safety guarantees. -// -// The cache contents can be serialized to an in-memory buffer or mmap'd file -// and then reloaded in a subsequent execution of the program. This -// serialization is non-portable and the data should only be used by the device -// that generated it. -class BlobCache : public RefBase { - -public: - - // Create an empty blob cache. The blob cache will cache key/value pairs - // with key and value sizes less than or equal to maxKeySize and - // maxValueSize, respectively. The total combined size of ALL cache entries - // (key sizes plus value sizes) will not exceed maxTotalSize. - BlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize); - - // set inserts a new binary value into the cache and associates it with the - // given binary key. If the key or value are too large for the cache then - // the cache remains unchanged. This includes the case where a different - // value was previously associated with the given key - the old value will - // remain in the cache. If the given key and value are small enough to be - // put in the cache (based on the maxKeySize, maxValueSize, and maxTotalSize - // values specified to the BlobCache constructor), then the key/value pair - // will be in the cache after set returns. Note, however, that a subsequent - // call to set may evict old key/value pairs from the cache. - // - // Preconditions: - // key != NULL - // 0 < keySize - // value != NULL - // 0 < valueSize - void set(const void* key, size_t keySize, const void* value, - size_t valueSize); - - // get retrieves from the cache the binary value associated with a given - // binary key. If the key is present in the cache then the length of the - // binary value associated with that key is returned. If the value argument - // is non-NULL and the size of the cached value is less than valueSize bytes - // then the cached value is copied into the buffer pointed to by the value - // argument. If the key is not present in the cache then 0 is returned and - // the buffer pointed to by the value argument is not modified. - // - // Note that when calling get multiple times with the same key, the later - // calls may fail, returning 0, even if earlier calls succeeded. The return - // value must be checked for each call. - // - // Preconditions: - // key != NULL - // 0 < keySize - // 0 <= valueSize - size_t get(const void* key, size_t keySize, void* value, size_t valueSize); - - - // getFlattenedSize returns the number of bytes needed to store the entire - // serialized cache. - size_t getFlattenedSize() const; - - // flatten serializes the current contents of the cache into the memory - // pointed to by 'buffer'. The serialized cache contents can later be - // loaded into a BlobCache object using the unflatten method. The contents - // of the BlobCache object will not be modified. - // - // Preconditions: - // size >= this.getFlattenedSize() - status_t flatten(void* buffer, size_t size) const; - - // unflatten replaces the contents of the cache with the serialized cache - // contents in the memory pointed to by 'buffer'. The previous contents of - // the BlobCache will be evicted from the cache. If an error occurs while - // unflattening the serialized cache contents then the BlobCache will be - // left in an empty state. - // - status_t unflatten(void const* buffer, size_t size); - -private: - // Copying is disallowed. - BlobCache(const BlobCache&); - void operator=(const BlobCache&); - - // A random function helper to get around MinGW not having nrand48() - long int blob_random(); - - // clean evicts a randomly chosen set of entries from the cache such that - // the total size of all remaining entries is less than mMaxTotalSize/2. - void clean(); - - // isCleanable returns true if the cache is full enough for the clean method - // to have some effect, and false otherwise. - bool isCleanable() const; - - // A Blob is an immutable sized unstructured data blob. - class Blob : public RefBase { - public: - Blob(const void* data, size_t size, bool copyData); - ~Blob(); - - bool operator<(const Blob& rhs) const; - - const void* getData() const; - size_t getSize() const; - - private: - // Copying is not allowed. - Blob(const Blob&); - void operator=(const Blob&); - - // mData points to the buffer containing the blob data. - const void* mData; - - // mSize is the size of the blob data in bytes. - size_t mSize; - - // mOwnsData indicates whether or not this Blob object should free the - // memory pointed to by mData when the Blob gets destructed. - bool mOwnsData; - }; - - // A CacheEntry is a single key/value pair in the cache. - class CacheEntry { - public: - CacheEntry(); - CacheEntry(const sp& key, const sp& value); - CacheEntry(const CacheEntry& ce); - - bool operator<(const CacheEntry& rhs) const; - const CacheEntry& operator=(const CacheEntry&); - - sp getKey() const; - sp getValue() const; - - void setValue(const sp& value); - - private: - - // mKey is the key that identifies the cache entry. - sp mKey; - - // mValue is the cached data associated with the key. - sp mValue; - }; - - // A Header is the header for the entire BlobCache serialization format. No - // need to make this portable, so we simply write the struct out. - struct Header { - // mMagicNumber is the magic number that identifies the data as - // serialized BlobCache contents. It must always contain 'Blb$'. - uint32_t mMagicNumber; - - // mBlobCacheVersion is the serialization format version. - uint32_t mBlobCacheVersion; - - // mDeviceVersion is the device-specific version of the cache. This can - // be used to invalidate the cache. - uint32_t mDeviceVersion; - - // mNumEntries is number of cache entries following the header in the - // data. - size_t mNumEntries; - - // mBuildId is the build id of the device when the cache was created. - // When an update to the build happens (via an OTA or other update) this - // is used to invalidate the cache. - int mBuildIdLength; - char mBuildId[]; - }; - - // An EntryHeader is the header for a serialized cache entry. No need to - // make this portable, so we simply write the struct out. Each EntryHeader - // is followed imediately by the key data and then the value data. - // - // The beginning of each serialized EntryHeader is 4-byte aligned, so the - // number of bytes that a serialized cache entry will occupy is: - // - // ((sizeof(EntryHeader) + keySize + valueSize) + 3) & ~3 - // - struct EntryHeader { - // mKeySize is the size of the entry key in bytes. - size_t mKeySize; - - // mValueSize is the size of the entry value in bytes. - size_t mValueSize; - - // mData contains both the key and value data for the cache entry. The - // key comes first followed immediately by the value. - uint8_t mData[]; - }; - - // mMaxKeySize is the maximum key size that will be cached. Calls to - // BlobCache::set with a keySize parameter larger than mMaxKeySize will - // simply not add the key/value pair to the cache. - const size_t mMaxKeySize; - - // mMaxValueSize is the maximum value size that will be cached. Calls to - // BlobCache::set with a valueSize parameter larger than mMaxValueSize will - // simply not add the key/value pair to the cache. - const size_t mMaxValueSize; - - // mMaxTotalSize is the maximum size that all cache entries can occupy. This - // includes space for both keys and values. When a call to BlobCache::set - // would otherwise cause this limit to be exceeded, either the key/value - // pair passed to BlobCache::set will not be cached or other cache entries - // will be evicted from the cache to make room for the new entry. - const size_t mMaxTotalSize; - - // mTotalSize is the total combined size of all keys and values currently in - // the cache. - size_t mTotalSize; - - // mRandState is the pseudo-random number generator state. It is passed to - // nrand48 to generate random numbers when needed. - unsigned short mRandState[3]; - - // mCacheEntries stores all the cache entries that are resident in memory. - // Cache entries are added to it by the 'set' method. - SortedVector mCacheEntries; -}; - -} - -#endif // ANDROID_BLOB_CACHE_H diff --git a/third_party/android_system_core/include/utils/ByteOrder.h b/third_party/android_system_core/include/utils/ByteOrder.h deleted file mode 100644 index baa3a83ddd..0000000000 --- a/third_party/android_system_core/include/utils/ByteOrder.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2006 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 _LIBS_UTILS_BYTE_ORDER_H -#define _LIBS_UTILS_BYTE_ORDER_H - -#include -#include -#ifdef HAVE_WINSOCK -#include -#else -#include -#endif - -/* - * These macros are like the hton/ntoh byte swapping macros, - * except they allow you to swap to and from the "device" byte - * order. The device byte order is the endianness of the target - * device -- for the ARM CPUs we use today, this is little endian. - * - * Note that the byte swapping functions have not been optimized - * much; performance is currently not an issue for them since the - * intent is to allow us to avoid byte swapping on the device. - */ - -static inline uint32_t android_swap_long(uint32_t v) -{ - return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); -} - -static inline uint16_t android_swap_short(uint16_t v) -{ - return (v<<8) | (v>>8); -} - -#define DEVICE_BYTE_ORDER LITTLE_ENDIAN - -#if BYTE_ORDER == DEVICE_BYTE_ORDER - -#define dtohl(x) (x) -#define dtohs(x) (x) -#define htodl(x) (x) -#define htods(x) (x) - -#else - -#define dtohl(x) (android_swap_long(x)) -#define dtohs(x) (android_swap_short(x)) -#define htodl(x) (android_swap_long(x)) -#define htods(x) (android_swap_short(x)) - -#endif - -#if BYTE_ORDER == LITTLE_ENDIAN -#define fromlel(x) (x) -#define fromles(x) (x) -#define tolel(x) (x) -#define toles(x) (x) -#else -#define fromlel(x) (android_swap_long(x)) -#define fromles(x) (android_swap_short(x)) -#define tolel(x) (android_swap_long(x)) -#define toles(x) (android_swap_short(x)) -#endif - -#endif // _LIBS_UTILS_BYTE_ORDER_H diff --git a/third_party/android_system_core/include/utils/CallStack.h b/third_party/android_system_core/include/utils/CallStack.h deleted file mode 100644 index 27e89f4622..0000000000 --- a/third_party/android_system_core/include/utils/CallStack.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2007 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_CALLSTACK_H -#define ANDROID_CALLSTACK_H - -#include -#include -#include -#include - -#include -#include - -namespace android { - -class Printer; - -// Collect/print the call stack (function, file, line) traces for a single thread. -class CallStack { -public: - // Create an empty call stack. No-op. - CallStack(); - // Create a callstack with the current thread's stack trace. - // Immediately dump it to logcat using the given logtag. - CallStack(const char* logtag, int32_t ignoreDepth=1); - ~CallStack(); - - // Reset the stack frames (same as creating an empty call stack). - void clear() { mFrameLines.clear(); } - - // Immediately collect the stack traces for the specified thread. - // The default is to dump the stack of the current call. - void update(int32_t ignoreDepth=1, pid_t tid=BACKTRACE_CURRENT_THREAD); - - // Dump a stack trace to the log using the supplied logtag. - void log(const char* logtag, - android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0) const; - - // Dump a stack trace to the specified file descriptor. - void dump(int fd, int indent = 0, const char* prefix = 0) const; - - // Return a string (possibly very long) containing the complete stack trace. - String8 toString(const char* prefix = 0) const; - - // Dump a serialized representation of the stack trace to the specified printer. - void print(Printer& printer) const; - - // Get the count of stack frames that are in this call stack. - size_t size() const { return mFrameLines.size(); } - -private: - Vector mFrameLines; -}; - -}; // namespace android - -#endif // ANDROID_CALLSTACK_H diff --git a/third_party/android_system_core/include/utils/Compat.h b/third_party/android_system_core/include/utils/Compat.h deleted file mode 100644 index 7d96310272..0000000000 --- a/third_party/android_system_core/include/utils/Compat.h +++ /dev/null @@ -1,78 +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 __LIB_UTILS_COMPAT_H -#define __LIB_UTILS_COMPAT_H - -#include - -#if defined(__APPLE__) - -/* Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */ - -typedef off_t off64_t; - -static inline off64_t lseek64(int fd, off64_t offset, int whence) { - return lseek(fd, offset, whence); -} - -static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) { - return pread(fd, buf, nbytes, offset); -} - -#endif /* __APPLE__ */ - -#if defined(_WIN32) -#define O_CLOEXEC O_NOINHERIT -#define O_NOFOLLOW 0 -#define DEFFILEMODE 0666 -#endif /* _WIN32 */ - -#if defined(_WIN32) -#define ZD "%ld" -#define ZD_TYPE long -#else -#define ZD "%zd" -#define ZD_TYPE ssize_t -#endif - -/* - * Needed for cases where something should be constexpr if possible, but not - * being constexpr is fine if in pre-C++11 code (such as a const static float - * member variable). - */ -#if __cplusplus >= 201103L -#define CONSTEXPR constexpr -#else -#define CONSTEXPR -#endif - -/* - * TEMP_FAILURE_RETRY is defined by some, but not all, versions of - * . (Alas, it is not as standard as we'd hoped!) So, if it's - * not already defined, then define it here. - */ -#ifndef TEMP_FAILURE_RETRY -/* Used to retry syscalls that can return EINTR. */ -#define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ - do { \ - _rc = (exp); \ - } while (_rc == -1 && errno == EINTR); \ - _rc; }) -#endif - -#endif /* __LIB_UTILS_COMPAT_H */ diff --git a/third_party/android_system_core/include/utils/Condition.h b/third_party/android_system_core/include/utils/Condition.h deleted file mode 100644 index 5a7251982a..0000000000 --- a/third_party/android_system_core/include/utils/Condition.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_UTILS_CONDITION_H -#define _LIBS_UTILS_CONDITION_H - -#include -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -/* - * Condition variable class. The implementation is system-dependent. - * - * Condition variables are paired up with mutexes. Lock the mutex, - * call wait(), then either re-wait() if things aren't quite what you want, - * or unlock the mutex and continue. All threads calling wait() must - * use the same mutex for a given Condition. - */ -class Condition { -public: - enum { - PRIVATE = 0, - SHARED = 1 - }; - - enum WakeUpType { - WAKE_UP_ONE = 0, - WAKE_UP_ALL = 1 - }; - - Condition(); - Condition(int type); - ~Condition(); - // Wait on the condition variable. Lock the mutex before calling. - status_t wait(Mutex& mutex); - // same with relative timeout - status_t waitRelative(Mutex& mutex, nsecs_t reltime); - // Signal the condition variable, allowing exactly one thread to continue. - void signal(); - // Signal the condition variable, allowing one or all threads to continue. - void signal(WakeUpType type) { - if (type == WAKE_UP_ONE) { - signal(); - } else { - broadcast(); - } - } - // Signal the condition variable, allowing all threads to continue. - void broadcast(); - -private: -#if !defined(_WIN32) - pthread_cond_t mCond; -#else - void* mState; -#endif -}; - -// --------------------------------------------------------------------------- - -#if !defined(_WIN32) - -inline Condition::Condition() { - pthread_cond_init(&mCond, NULL); -} -inline Condition::Condition(int type) { - if (type == SHARED) { - pthread_condattr_t attr; - pthread_condattr_init(&attr); - pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_cond_init(&mCond, &attr); - pthread_condattr_destroy(&attr); - } else { - pthread_cond_init(&mCond, NULL); - } -} -inline Condition::~Condition() { - pthread_cond_destroy(&mCond); -} -inline status_t Condition::wait(Mutex& mutex) { - return -pthread_cond_wait(&mCond, &mutex.mMutex); -} -inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) { -#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE) - struct timespec ts; - ts.tv_sec = reltime/1000000000; - ts.tv_nsec = reltime%1000000000; - return -pthread_cond_timedwait_relative_np(&mCond, &mutex.mMutex, &ts); -#else // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE - struct timespec ts; -#if defined(__linux__) - clock_gettime(CLOCK_REALTIME, &ts); -#else // __APPLE__ - // we don't support the clocks here. - struct timeval t; - gettimeofday(&t, NULL); - ts.tv_sec = t.tv_sec; - ts.tv_nsec= t.tv_usec*1000; -#endif - ts.tv_sec += reltime/1000000000; - ts.tv_nsec+= reltime%1000000000; - if (ts.tv_nsec >= 1000000000) { - ts.tv_nsec -= 1000000000; - ts.tv_sec += 1; - } - return -pthread_cond_timedwait(&mCond, &mutex.mMutex, &ts); -#endif // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE -} -inline void Condition::signal() { - /* - * POSIX says pthread_cond_signal wakes up "one or more" waiting threads. - * However bionic follows the glibc guarantee which wakes up "exactly one" - * waiting thread. - * - * man 3 pthread_cond_signal - * pthread_cond_signal restarts one of the threads that are waiting on - * the condition variable cond. If no threads are waiting on cond, - * nothing happens. If several threads are waiting on cond, exactly one - * is restarted, but it is not specified which. - */ - pthread_cond_signal(&mCond); -} -inline void Condition::broadcast() { - pthread_cond_broadcast(&mCond); -} - -#endif // !defined(_WIN32) - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_CONDITON_H diff --git a/third_party/android_system_core/include/utils/Debug.h b/third_party/android_system_core/include/utils/Debug.h deleted file mode 100644 index 08893bdaaf..0000000000 --- a/third_party/android_system_core/include/utils/Debug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2005 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_UTILS_DEBUG_H -#define ANDROID_UTILS_DEBUG_H - -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -#ifdef __cplusplus -template struct CompileTimeAssert; -template<> struct CompileTimeAssert {}; -#define COMPILE_TIME_ASSERT(_exp) \ - template class CompileTimeAssert< (_exp) >; -#endif -#define COMPILE_TIME_ASSERT_FUNCTION_SCOPE(_exp) \ - CompileTimeAssert<( _exp )>(); - -// --------------------------------------------------------------------------- - -#ifdef __cplusplus -template struct CompileTimeIfElse; -template -struct CompileTimeIfElse { typedef LHS TYPE; }; -template -struct CompileTimeIfElse { typedef RHS TYPE; }; -#endif - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_UTILS_DEBUG_H diff --git a/third_party/android_system_core/include/utils/Endian.h b/third_party/android_system_core/include/utils/Endian.h deleted file mode 100644 index 591cae0d34..0000000000 --- a/third_party/android_system_core/include/utils/Endian.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// Android endian-ness defines. -// -#ifndef _LIBS_UTILS_ENDIAN_H -#define _LIBS_UTILS_ENDIAN_H - -#if defined(__APPLE__) || defined(_WIN32) - -#define __BIG_ENDIAN 0x1000 -#define __LITTLE_ENDIAN 0x0001 -#define __BYTE_ORDER __LITTLE_ENDIAN - -#else - -#include - -#endif - -#endif /*_LIBS_UTILS_ENDIAN_H*/ diff --git a/third_party/android_system_core/include/utils/Errors.h b/third_party/android_system_core/include/utils/Errors.h deleted file mode 100644 index 46173db4a3..0000000000 --- a/third_party/android_system_core/include/utils/Errors.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2007 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_ERRORS_H -#define ANDROID_ERRORS_H - -#include -#include - -namespace android { - -// use this type to return error codes -#ifdef HAVE_MS_C_RUNTIME -typedef int status_t; -#else -typedef int32_t status_t; -#endif - -/* the MS C runtime lacks a few error codes */ - -/* - * Error codes. - * All error codes are negative values. - */ - -// Win32 #defines NO_ERROR as well. It has the same value, so there's no -// real conflict, though it's a bit awkward. -#ifdef _WIN32 -# undef NO_ERROR -#endif - -enum { - OK = 0, // Everything's swell. - NO_ERROR = 0, // No errors. - - UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value - - NO_MEMORY = -ENOMEM, - INVALID_OPERATION = -ENOSYS, - BAD_VALUE = -EINVAL, - BAD_TYPE = (UNKNOWN_ERROR + 1), - NAME_NOT_FOUND = -ENOENT, - PERMISSION_DENIED = -EPERM, - NO_INIT = -ENODEV, - ALREADY_EXISTS = -EEXIST, - DEAD_OBJECT = -EPIPE, - FAILED_TRANSACTION = (UNKNOWN_ERROR + 2), - JPARKS_BROKE_IT = -EPIPE, -#if !defined(HAVE_MS_C_RUNTIME) - BAD_INDEX = -EOVERFLOW, - NOT_ENOUGH_DATA = -ENODATA, - WOULD_BLOCK = -EWOULDBLOCK, - TIMED_OUT = -ETIMEDOUT, - UNKNOWN_TRANSACTION = -EBADMSG, -#else - BAD_INDEX = -E2BIG, - NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3), - WOULD_BLOCK = (UNKNOWN_ERROR + 4), - TIMED_OUT = (UNKNOWN_ERROR + 5), - UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6), -#endif - FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7), -}; - -// Restore define; enumeration is in "android" namespace, so the value defined -// there won't work for Win32 code in a different namespace. -#ifdef _WIN32 -# define NO_ERROR 0L -#endif - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_ERRORS_H diff --git a/third_party/android_system_core/include/utils/FileMap.h b/third_party/android_system_core/include/utils/FileMap.h deleted file mode 100644 index f70fc927e4..0000000000 --- a/third_party/android_system_core/include/utils/FileMap.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -// -// Encapsulate a shared file mapping. -// -#ifndef __LIBS_FILE_MAP_H -#define __LIBS_FILE_MAP_H - -#include - -#include - -#if defined(__MINGW32__) -// Ensure that we always pull in winsock2.h before windows.h -#ifdef HAVE_WINSOCK -#include -#endif -#include -#endif - -namespace android { - -/* - * This represents a memory-mapped file. It might be the entire file or - * only part of it. This requires a little bookkeeping because the mapping - * needs to be aligned on page boundaries, and in some cases we'd like to - * have multiple references to the mapped area without creating additional - * maps. - * - * This always uses MAP_SHARED. - * - * TODO: we should be able to create a new FileMap that is a subset of - * an existing FileMap and shares the underlying mapped pages. Requires - * completing the refcounting stuff and possibly introducing the notion - * of a FileMap hierarchy. - */ -class FileMap { -public: - FileMap(void); - - /* - * Create a new mapping on an open file. - * - * Closing the file descriptor does not unmap the pages, so we don't - * claim ownership of the fd. - * - * Returns "false" on failure. - */ - bool create(const char* origFileName, int fd, - off64_t offset, size_t length, bool readOnly); - - ~FileMap(void); - - /* - * Return the name of the file this map came from, if known. - */ - const char* getFileName(void) const { return mFileName; } - - /* - * Get a pointer to the piece of the file we requested. - */ - void* getDataPtr(void) const { return mDataPtr; } - - /* - * Get the length we requested. - */ - size_t getDataLength(void) const { return mDataLength; } - - /* - * Get the data offset used to create this map. - */ - off64_t getDataOffset(void) const { return mDataOffset; } - - /* - * This maps directly to madvise() values, but allows us to avoid - * including everywhere. - */ - enum MapAdvice { - NORMAL, RANDOM, SEQUENTIAL, WILLNEED, DONTNEED - }; - - /* - * Apply an madvise() call to the entire file. - * - * Returns 0 on success, -1 on failure. - */ - int advise(MapAdvice advice); - -protected: - -private: - // these are not implemented - FileMap(const FileMap& src); - const FileMap& operator=(const FileMap& src); - - char* mFileName; // original file name, if known - void* mBasePtr; // base of mmap area; page aligned - size_t mBaseLength; // length, measured from "mBasePtr" - off64_t mDataOffset; // offset used when map was created - void* mDataPtr; // start of requested data, offset from base - size_t mDataLength; // length, measured from "mDataPtr" -#if defined(__MINGW32__) - HANDLE mFileHandle; // Win32 file handle - HANDLE mFileMapping; // Win32 file mapping handle -#endif - - static long mPageSize; -}; - -}; // namespace android - -#endif // __LIBS_FILE_MAP_H diff --git a/third_party/android_system_core/include/utils/Flattenable.h b/third_party/android_system_core/include/utils/Flattenable.h deleted file mode 100644 index 882a8b2499..0000000000 --- a/third_party/android_system_core/include/utils/Flattenable.h +++ /dev/null @@ -1,198 +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_UTILS_FLATTENABLE_H -#define ANDROID_UTILS_FLATTENABLE_H - - -#include -#include -#include -#include - -namespace android { - - -class FlattenableUtils { -public: - template - static size_t align(size_t size) { - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); - return (size + (N-1)) & ~(N-1); - } - - template - static size_t align(void const*& buffer) { - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); - intptr_t b = intptr_t(buffer); - buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1)); - return size_t(intptr_t(buffer) - b); - } - - template - static size_t align(void*& buffer) { - return align( const_cast(buffer) ); - } - - static void advance(void*& buffer, size_t& size, size_t offset) { - buffer = reinterpret_cast( intptr_t(buffer) + offset ); - size -= offset; - } - - static void advance(void const*& buffer, size_t& size, size_t offset) { - buffer = reinterpret_cast( intptr_t(buffer) + offset ); - size -= offset; - } - - // write a POD structure - template - static void write(void*& buffer, size_t& size, const T& value) { - *static_cast(buffer) = value; - advance(buffer, size, sizeof(T)); - } - - // read a POD structure - template - static void read(void const*& buffer, size_t& size, T& value) { - value = *static_cast(buffer); - advance(buffer, size, sizeof(T)); - } -}; - - -/* - * The Flattenable protocol allows an object to serialize itself out - * to a byte-buffer and an array of file descriptors. - * Flattenable objects must implement this protocol. - */ - -template -class Flattenable { -public: - // size in bytes of the flattened object - inline size_t getFlattenedSize() const; - - // number of file descriptors to flatten - inline size_t getFdCount() const; - - // flattens the object into buffer. - // size should be at least of getFlattenedSize() - // file descriptors are written in the fds[] array but ownership is - // not transfered (ie: they must be dupped by the caller of - // flatten() if needed). - inline status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; - - // unflattens the object from buffer. - // size should be equal to the value of getFlattenedSize() when the - // object was flattened. - // unflattened file descriptors are found in the fds[] array and - // don't need to be dupped(). ie: the caller of unflatten doesn't - // keep ownership. If a fd is not retained by unflatten() it must be - // explicitly closed. - inline status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); -}; - -template -inline size_t Flattenable::getFlattenedSize() const { - return static_cast(this)->T::getFlattenedSize(); -} -template -inline size_t Flattenable::getFdCount() const { - return static_cast(this)->T::getFdCount(); -} -template -inline status_t Flattenable::flatten( - void*& buffer, size_t& size, int*& fds, size_t& count) const { - return static_cast(this)->T::flatten(buffer, size, fds, count); -} -template -inline status_t Flattenable::unflatten( - void const*& buffer, size_t& size, int const*& fds, size_t& count) { - return static_cast(this)->T::unflatten(buffer, size, fds, count); -} - -/* - * LightFlattenable is a protocol allowing object to serialize themselves out - * to a byte-buffer. Because it doesn't handle file-descriptors, - * LightFlattenable is usually more size efficient than Flattenable. - * LightFlattenable objects must implement this protocol. - */ -template -class LightFlattenable { -public: - // returns whether this object always flatten into the same size. - // for efficiency, this should always be inline. - inline bool isFixedSize() const; - - // returns size in bytes of the flattened object. must be a constant. - inline size_t getFlattenedSize() const; - - // flattens the object into buffer. - inline status_t flatten(void* buffer, size_t size) const; - - // unflattens the object from buffer of given size. - inline status_t unflatten(void const* buffer, size_t size); -}; - -template -inline bool LightFlattenable::isFixedSize() const { - return static_cast(this)->T::isFixedSize(); -} -template -inline size_t LightFlattenable::getFlattenedSize() const { - return static_cast(this)->T::getFlattenedSize(); -} -template -inline status_t LightFlattenable::flatten(void* buffer, size_t size) const { - return static_cast(this)->T::flatten(buffer, size); -} -template -inline status_t LightFlattenable::unflatten(void const* buffer, size_t size) { - return static_cast(this)->T::unflatten(buffer, size); -} - -/* - * LightFlattenablePod is an implementation of the LightFlattenable protocol - * for POD (plain-old-data) objects. - * Simply derive from LightFlattenablePod to make Foo flattenable; no - * need to implement any methods; obviously Foo must be a POD structure. - */ -template -class LightFlattenablePod : public LightFlattenable { -public: - inline bool isFixedSize() const { - return true; - } - - inline size_t getFlattenedSize() const { - return sizeof(T); - } - inline status_t flatten(void* buffer, size_t size) const { - if (size < sizeof(T)) return NO_MEMORY; - *reinterpret_cast(buffer) = *static_cast(this); - return NO_ERROR; - } - inline status_t unflatten(void const* buffer, size_t) { - *static_cast(this) = *reinterpret_cast(buffer); - return NO_ERROR; - } -}; - - -}; // namespace android - - -#endif /* ANDROID_UTILS_FLATTENABLE_H */ diff --git a/third_party/android_system_core/include/utils/Functor.h b/third_party/android_system_core/include/utils/Functor.h deleted file mode 100644 index 09ea614b61..0000000000 --- a/third_party/android_system_core/include/utils/Functor.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2011 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_FUNCTOR_H -#define ANDROID_FUNCTOR_H - -#include - -namespace android { - -class Functor { -public: - Functor() {} - virtual ~Functor() {} - virtual status_t operator ()(int /*what*/, void* /*data*/) { return NO_ERROR; } -}; - -}; // namespace android - -#endif // ANDROID_FUNCTOR_H diff --git a/third_party/android_system_core/include/utils/JenkinsHash.h b/third_party/android_system_core/include/utils/JenkinsHash.h deleted file mode 100644 index 7da5dbd6a9..0000000000 --- a/third_party/android_system_core/include/utils/JenkinsHash.h +++ /dev/null @@ -1,48 +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. - */ - -/* Implementation of Jenkins one-at-a-time hash function. These choices are - * optimized for code size and portability, rather than raw speed. But speed - * should still be quite good. - **/ - -#ifndef ANDROID_JENKINS_HASH_H -#define ANDROID_JENKINS_HASH_H - -#include - -namespace android { - -/* The Jenkins hash of a sequence of 32 bit words A, B, C is: - * Whiten(Mix(Mix(Mix(0, A), B), C)) */ - -inline uint32_t JenkinsHashMix(uint32_t hash, uint32_t data) { - hash += data; - hash += (hash << 10); - hash ^= (hash >> 6); - return hash; -} - -hash_t JenkinsHashWhiten(uint32_t hash); - -/* Helpful utility functions for hashing data in 32 bit chunks */ -uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size); - -uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size); - -} - -#endif // ANDROID_JENKINS_HASH_H diff --git a/third_party/android_system_core/include/utils/KeyedVector.h b/third_party/android_system_core/include/utils/KeyedVector.h deleted file mode 100644 index c4faae0b76..0000000000 --- a/third_party/android_system_core/include/utils/KeyedVector.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2005 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_KEYED_VECTOR_H -#define ANDROID_KEYED_VECTOR_H - -#include -#include -#include - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class KeyedVector -{ -public: - typedef KEY key_type; - typedef VALUE value_type; - - inline KeyedVector(); - - /* - * empty the vector - */ - - inline void clear() { mVector.clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return mVector.size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return mVector.isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return mVector.capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return mVector.setCapacity(size); } - - // returns true if the arguments is known to be identical to this vector - inline bool isIdenticalTo(const KeyedVector& rhs) const; - - /*! - * accessors - */ - const VALUE& valueFor(const KEY& key) const; - const VALUE& valueAt(size_t index) const; - const KEY& keyAt(size_t index) const; - ssize_t indexOfKey(const KEY& key) const; - const VALUE& operator[] (size_t index) const; - - /*! - * modifying the array - */ - - VALUE& editValueFor(const KEY& key); - VALUE& editValueAt(size_t index); - - /*! - * add/insert/replace items - */ - - ssize_t add(const KEY& key, const VALUE& item); - ssize_t replaceValueFor(const KEY& key, const VALUE& item); - ssize_t replaceValueAt(size_t index, const VALUE& item); - - /*! - * remove items - */ - - ssize_t removeItem(const KEY& key); - ssize_t removeItemsAt(size_t index, size_t count = 1); - -private: - SortedVector< key_value_pair_t > mVector; -}; - -// KeyedVector can be trivially moved using memcpy() because its -// underlying SortedVector can be trivially moved. -template struct trait_trivial_move > { - enum { value = trait_trivial_move > >::value }; -}; - - -// --------------------------------------------------------------------------- - -/** - * Variation of KeyedVector that holds a default value to return when - * valueFor() is called with a key that doesn't exist. - */ -template -class DefaultKeyedVector : public KeyedVector -{ -public: - inline DefaultKeyedVector(const VALUE& defValue = VALUE()); - const VALUE& valueFor(const KEY& key) const; - -private: - VALUE mDefault; -}; - -// --------------------------------------------------------------------------- - -template inline -KeyedVector::KeyedVector() -{ -} - -template inline -bool KeyedVector::isIdenticalTo(const KeyedVector& rhs) const { - return mVector.array() == rhs.mVector.array(); -} - -template inline -ssize_t KeyedVector::indexOfKey(const KEY& key) const { - return mVector.indexOf( key_value_pair_t(key) ); -} - -template inline -const VALUE& KeyedVector::valueFor(const KEY& key) const { - ssize_t i = this->indexOfKey(key); - LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); - return mVector.itemAt(i).value; -} - -template inline -const VALUE& KeyedVector::valueAt(size_t index) const { - return mVector.itemAt(index).value; -} - -template inline -const VALUE& KeyedVector::operator[] (size_t index) const { - return valueAt(index); -} - -template inline -const KEY& KeyedVector::keyAt(size_t index) const { - return mVector.itemAt(index).key; -} - -template inline -VALUE& KeyedVector::editValueFor(const KEY& key) { - ssize_t i = this->indexOfKey(key); - LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); - return mVector.editItemAt(i).value; -} - -template inline -VALUE& KeyedVector::editValueAt(size_t index) { - return mVector.editItemAt(index).value; -} - -template inline -ssize_t KeyedVector::add(const KEY& key, const VALUE& value) { - return mVector.add( key_value_pair_t(key, value) ); -} - -template inline -ssize_t KeyedVector::replaceValueFor(const KEY& key, const VALUE& value) { - key_value_pair_t pair(key, value); - mVector.remove(pair); - return mVector.add(pair); -} - -template inline -ssize_t KeyedVector::replaceValueAt(size_t index, const VALUE& item) { - if (index inline -ssize_t KeyedVector::removeItem(const KEY& key) { - return mVector.remove(key_value_pair_t(key)); -} - -template inline -ssize_t KeyedVector::removeItemsAt(size_t index, size_t count) { - return mVector.removeItemsAt(index, count); -} - -// --------------------------------------------------------------------------- - -template inline -DefaultKeyedVector::DefaultKeyedVector(const VALUE& defValue) - : mDefault(defValue) -{ -} - -template inline -const VALUE& DefaultKeyedVector::valueFor(const KEY& key) const { - ssize_t i = this->indexOfKey(key); - return i >= 0 ? KeyedVector::valueAt(i) : mDefault; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_KEYED_VECTOR_H diff --git a/third_party/android_system_core/include/utils/LinearTransform.h b/third_party/android_system_core/include/utils/LinearTransform.h deleted file mode 100644 index 04cb355c7f..0000000000 --- a/third_party/android_system_core/include/utils/LinearTransform.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2011 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 _LIBS_UTILS_LINEAR_TRANSFORM_H -#define _LIBS_UTILS_LINEAR_TRANSFORM_H - -#include - -namespace android { - -// LinearTransform defines a structure which hold the definition of a -// transformation from single dimensional coordinate system A into coordinate -// system B (and back again). Values in A and in B are 64 bit, the linear -// scale factor is expressed as a rational number using two 32 bit values. -// -// Specifically, let -// f(a) = b -// F(b) = f^-1(b) = a -// then -// -// f(a) = (((a - a_zero) * a_to_b_numer) / a_to_b_denom) + b_zero; -// -// and -// -// F(b) = (((b - b_zero) * a_to_b_denom) / a_to_b_numer) + a_zero; -// -struct LinearTransform { - int64_t a_zero; - int64_t b_zero; - int32_t a_to_b_numer; - uint32_t a_to_b_denom; - - // Transform from A->B - // Returns true on success, or false in the case of a singularity or an - // overflow. - bool doForwardTransform(int64_t a_in, int64_t* b_out) const; - - // Transform from B->A - // Returns true on success, or false in the case of a singularity or an - // overflow. - bool doReverseTransform(int64_t b_in, int64_t* a_out) const; - - // Helpers which will reduce the fraction N/D using Euclid's method. - template static void reduce(T* N, T* D); - static void reduce(int32_t* N, uint32_t* D); -}; - - -} - -#endif // _LIBS_UTILS_LINEAR_TRANSFORM_H diff --git a/third_party/android_system_core/include/utils/List.h b/third_party/android_system_core/include/utils/List.h deleted file mode 100644 index 403cd7f1e5..0000000000 --- a/third_party/android_system_core/include/utils/List.h +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// Templated list class. Normally we'd use STL, but we don't have that. -// This class mimics STL's interfaces. -// -// Objects are copied into the list with the '=' operator or with copy- -// construction, so if the compiler's auto-generated versions won't work for -// you, define your own. -// -// The only class you want to use from here is "List". -// -#ifndef _LIBS_UTILS_LIST_H -#define _LIBS_UTILS_LIST_H - -#include -#include - -namespace android { - -/* - * Doubly-linked list. Instantiate with "List myList". - * - * Objects added to the list are copied using the assignment operator, - * so this must be defined. - */ -template -class List -{ -protected: - /* - * One element in the list. - */ - class _Node { - public: - explicit _Node(const T& val) : mVal(val) {} - ~_Node() {} - inline T& getRef() { return mVal; } - inline const T& getRef() const { return mVal; } - inline _Node* getPrev() const { return mpPrev; } - inline _Node* getNext() const { return mpNext; } - inline void setVal(const T& val) { mVal = val; } - inline void setPrev(_Node* ptr) { mpPrev = ptr; } - inline void setNext(_Node* ptr) { mpNext = ptr; } - private: - friend class List; - friend class _ListIterator; - T mVal; - _Node* mpPrev; - _Node* mpNext; - }; - - /* - * Iterator for walking through the list. - */ - - template - struct CONST_ITERATOR { - typedef _Node const * NodePtr; - typedef const TYPE Type; - }; - - template - struct NON_CONST_ITERATOR { - typedef _Node* NodePtr; - typedef TYPE Type; - }; - - template< - typename U, - template class Constness - > - class _ListIterator { - typedef _ListIterator _Iter; - typedef typename Constness::NodePtr _NodePtr; - typedef typename Constness::Type _Type; - - explicit _ListIterator(_NodePtr ptr) : mpNode(ptr) {} - - public: - _ListIterator() {} - _ListIterator(const _Iter& rhs) : mpNode(rhs.mpNode) {} - ~_ListIterator() {} - - // this will handle conversions from iterator to const_iterator - // (and also all convertible iterators) - // Here, in this implementation, the iterators can be converted - // if the nodes can be converted - template explicit - _ListIterator(const V& rhs) : mpNode(rhs.mpNode) {} - - - /* - * Dereference operator. Used to get at the juicy insides. - */ - _Type& operator*() const { return mpNode->getRef(); } - _Type* operator->() const { return &(mpNode->getRef()); } - - /* - * Iterator comparison. - */ - inline bool operator==(const _Iter& right) const { - return mpNode == right.mpNode; } - - inline bool operator!=(const _Iter& right) const { - return mpNode != right.mpNode; } - - /* - * handle comparisons between iterator and const_iterator - */ - template - inline bool operator==(const OTHER& right) const { - return mpNode == right.mpNode; } - - template - inline bool operator!=(const OTHER& right) const { - return mpNode != right.mpNode; } - - /* - * Incr/decr, used to move through the list. - */ - inline _Iter& operator++() { // pre-increment - mpNode = mpNode->getNext(); - return *this; - } - const _Iter operator++(int) { // post-increment - _Iter tmp(*this); - mpNode = mpNode->getNext(); - return tmp; - } - inline _Iter& operator--() { // pre-increment - mpNode = mpNode->getPrev(); - return *this; - } - const _Iter operator--(int) { // post-increment - _Iter tmp(*this); - mpNode = mpNode->getPrev(); - return tmp; - } - - inline _NodePtr getNode() const { return mpNode; } - - _NodePtr mpNode; /* should be private, but older gcc fails */ - private: - friend class List; - }; - -public: - List() { - prep(); - } - List(const List& src) { // copy-constructor - prep(); - insert(begin(), src.begin(), src.end()); - } - virtual ~List() { - clear(); - delete[] (unsigned char*) mpMiddle; - } - - typedef _ListIterator iterator; - typedef _ListIterator const_iterator; - - List& operator=(const List& right); - - /* returns true if the list is empty */ - inline bool empty() const { return mpMiddle->getNext() == mpMiddle; } - - /* return #of elements in list */ - size_t size() const { - return size_t(distance(begin(), end())); - } - - /* - * Return the first element or one past the last element. The - * _Node* we're returning is converted to an "iterator" by a - * constructor in _ListIterator. - */ - inline iterator begin() { - return iterator(mpMiddle->getNext()); - } - inline const_iterator begin() const { - return const_iterator(const_cast<_Node const*>(mpMiddle->getNext())); - } - inline iterator end() { - return iterator(mpMiddle); - } - inline const_iterator end() const { - return const_iterator(const_cast<_Node const*>(mpMiddle)); - } - - /* add the object to the head or tail of the list */ - void push_front(const T& val) { insert(begin(), val); } - void push_back(const T& val) { insert(end(), val); } - - /* insert before the current node; returns iterator at new node */ - iterator insert(iterator posn, const T& val) - { - _Node* newNode = new _Node(val); // alloc & copy-construct - newNode->setNext(posn.getNode()); - newNode->setPrev(posn.getNode()->getPrev()); - posn.getNode()->getPrev()->setNext(newNode); - posn.getNode()->setPrev(newNode); - return iterator(newNode); - } - - /* insert a range of elements before the current node */ - void insert(iterator posn, const_iterator first, const_iterator last) { - for ( ; first != last; ++first) - insert(posn, *first); - } - - /* remove one entry; returns iterator at next node */ - iterator erase(iterator posn) { - _Node* pNext = posn.getNode()->getNext(); - _Node* pPrev = posn.getNode()->getPrev(); - pPrev->setNext(pNext); - pNext->setPrev(pPrev); - delete posn.getNode(); - return iterator(pNext); - } - - /* remove a range of elements */ - iterator erase(iterator first, iterator last) { - while (first != last) - erase(first++); // don't erase than incr later! - return iterator(last); - } - - /* remove all contents of the list */ - void clear() { - _Node* pCurrent = mpMiddle->getNext(); - _Node* pNext; - - while (pCurrent != mpMiddle) { - pNext = pCurrent->getNext(); - delete pCurrent; - pCurrent = pNext; - } - mpMiddle->setPrev(mpMiddle); - mpMiddle->setNext(mpMiddle); - } - - /* - * Measure the distance between two iterators. On exist, "first" - * will be equal to "last". The iterators must refer to the same - * list. - * - * FIXME: This is actually a generic iterator function. It should be a - * template function at the top-level with specializations for things like - * vector<>, which can just do pointer math). Here we limit it to - * _ListIterator of the same type but different constness. - */ - template< - typename U, - template class CL, - template class CR - > - ptrdiff_t distance( - _ListIterator first, _ListIterator last) const - { - ptrdiff_t count = 0; - while (first != last) { - ++first; - ++count; - } - return count; - } - -private: - /* - * I want a _Node but don't need it to hold valid data. More - * to the point, I don't want T's constructor to fire, since it - * might have side-effects or require arguments. So, we do this - * slightly uncouth storage alloc. - */ - void prep() { - mpMiddle = (_Node*) new unsigned char[sizeof(_Node)]; - mpMiddle->setPrev(mpMiddle); - mpMiddle->setNext(mpMiddle); - } - - /* - * This node plays the role of "pointer to head" and "pointer to tail". - * It sits in the middle of a circular list of nodes. The iterator - * runs around the circle until it encounters this one. - */ - _Node* mpMiddle; -}; - -/* - * Assignment operator. - * - * The simplest way to do this would be to clear out the target list and - * fill it with the source. However, we can speed things along by - * re-using existing elements. - */ -template -List& List::operator=(const List& right) -{ - if (this == &right) - return *this; // self-assignment - iterator firstDst = begin(); - iterator lastDst = end(); - const_iterator firstSrc = right.begin(); - const_iterator lastSrc = right.end(); - while (firstSrc != lastSrc && firstDst != lastDst) - *firstDst++ = *firstSrc++; - if (firstSrc == lastSrc) // ran out of elements in source? - erase(firstDst, lastDst); // yes, erase any extras - else - insert(lastDst, firstSrc, lastSrc); // copy remaining over - return *this; -} - -}; // namespace android - -#endif // _LIBS_UTILS_LIST_H diff --git a/third_party/android_system_core/include/utils/Log.h b/third_party/android_system_core/include/utils/Log.h deleted file mode 100644 index 4259c86d1a..0000000000 --- a/third_party/android_system_core/include/utils/Log.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// C/C++ logging functions. See the logging documentation for API details. -// -// We'd like these to be available from C code (in case we import some from -// somewhere), so this has a C interface. -// -// The output will be correct when the log file is shared between multiple -// threads and/or multiple processes so long as the operating system -// supports O_APPEND. These calls have mutex-protected data structures -// and so are NOT reentrant. Do not use LOG in a signal handler. -// -#ifndef _LIBS_UTILS_LOG_H -#define _LIBS_UTILS_LOG_H - -#include -#include - -#ifdef __cplusplus - -namespace android { - -/* - * A very simple utility that yells in the log when an operation takes too long. - */ -class LogIfSlow { -public: - LogIfSlow(const char* tag, android_LogPriority priority, - int timeoutMillis, const char* message); - ~LogIfSlow(); - -private: - const char* const mTag; - const android_LogPriority mPriority; - const int mTimeoutMillis; - const char* const mMessage; - const int64_t mStart; -}; - -/* - * Writes the specified debug log message if this block takes longer than the - * specified number of milliseconds to run. Includes the time actually taken. - * - * { - * ALOGD_IF_SLOW(50, "Excessive delay doing something."); - * doSomething(); - * } - */ -#define ALOGD_IF_SLOW(timeoutMillis, message) \ - android::LogIfSlow _logIfSlow(LOG_TAG, ANDROID_LOG_DEBUG, timeoutMillis, message); - -} // namespace android - -#endif // __cplusplus - -#endif // _LIBS_UTILS_LOG_H diff --git a/third_party/android_system_core/include/utils/Looper.h b/third_party/android_system_core/include/utils/Looper.h deleted file mode 100644 index da2d5f2b5b..0000000000 --- a/third_party/android_system_core/include/utils/Looper.h +++ /dev/null @@ -1,487 +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 UTILS_LOOPER_H -#define UTILS_LOOPER_H - -#include -#include -#include -#include - -#include - -namespace android { - -/* - * NOTE: Since Looper is used to implement the NDK ALooper, the Looper - * enums and the signature of Looper_callbackFunc need to align with - * that implementation. - */ - -/** - * For callback-based event loops, this is the prototype of the function - * that is called when a file descriptor event occurs. - * It is given the file descriptor it is associated with, - * a bitmask of the poll events that were triggered (typically EVENT_INPUT), - * and the data pointer that was originally supplied. - * - * Implementations should return 1 to continue receiving callbacks, or 0 - * to have this file descriptor and callback unregistered from the looper. - */ -typedef int (*Looper_callbackFunc)(int fd, int events, void* data); - -/** - * A message that can be posted to a Looper. - */ -struct Message { - Message() : what(0) { } - Message(int what) : what(what) { } - - /* The message type. (interpretation is left up to the handler) */ - int what; -}; - - -/** - * Interface for a Looper message handler. - * - * The Looper holds a strong reference to the message handler whenever it has - * a message to deliver to it. Make sure to call Looper::removeMessages - * to remove any pending messages destined for the handler so that the handler - * can be destroyed. - */ -class MessageHandler : public virtual RefBase { -protected: - virtual ~MessageHandler() { } - -public: - /** - * Handles a message. - */ - virtual void handleMessage(const Message& message) = 0; -}; - - -/** - * A simple proxy that holds a weak reference to a message handler. - */ -class WeakMessageHandler : public MessageHandler { -protected: - virtual ~WeakMessageHandler(); - -public: - WeakMessageHandler(const wp& handler); - virtual void handleMessage(const Message& message); - -private: - wp mHandler; -}; - - -/** - * A looper callback. - */ -class LooperCallback : public virtual RefBase { -protected: - virtual ~LooperCallback() { } - -public: - /** - * Handles a poll event for the given file descriptor. - * It is given the file descriptor it is associated with, - * a bitmask of the poll events that were triggered (typically EVENT_INPUT), - * and the data pointer that was originally supplied. - * - * Implementations should return 1 to continue receiving callbacks, or 0 - * to have this file descriptor and callback unregistered from the looper. - */ - virtual int handleEvent(int fd, int events, void* data) = 0; -}; - -/** - * Wraps a Looper_callbackFunc function pointer. - */ -class SimpleLooperCallback : public LooperCallback { -protected: - virtual ~SimpleLooperCallback(); - -public: - SimpleLooperCallback(Looper_callbackFunc callback); - virtual int handleEvent(int fd, int events, void* data); - -private: - Looper_callbackFunc mCallback; -}; - -/** - * A polling loop that supports monitoring file descriptor events, optionally - * using callbacks. The implementation uses epoll() internally. - * - * A looper can be associated with a thread although there is no requirement that it must be. - */ -class Looper : public RefBase { -protected: - virtual ~Looper(); - -public: - enum { - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * The poll was awoken using wake() before the timeout expired - * and no callbacks were executed and no other file descriptors were ready. - */ - POLL_WAKE = -1, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * One or more callbacks were executed. - */ - POLL_CALLBACK = -2, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * The timeout expired. - */ - POLL_TIMEOUT = -3, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * An error occurred. - */ - POLL_ERROR = -4, - }; - - /** - * Flags for file descriptor events that a looper can monitor. - * - * These flag bits can be combined to monitor multiple events at once. - */ - enum { - /** - * The file descriptor is available for read operations. - */ - EVENT_INPUT = 1 << 0, - - /** - * The file descriptor is available for write operations. - */ - EVENT_OUTPUT = 1 << 1, - - /** - * The file descriptor has encountered an error condition. - * - * The looper always sends notifications about errors; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_ERROR = 1 << 2, - - /** - * The file descriptor was hung up. - * For example, indicates that the remote end of a pipe or socket was closed. - * - * The looper always sends notifications about hangups; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_HANGUP = 1 << 3, - - /** - * The file descriptor is invalid. - * For example, the file descriptor was closed prematurely. - * - * The looper always sends notifications about invalid file descriptors; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_INVALID = 1 << 4, - }; - - enum { - /** - * Option for Looper_prepare: this looper will accept calls to - * Looper_addFd() that do not have a callback (that is provide NULL - * for the callback). In this case the caller of Looper_pollOnce() - * or Looper_pollAll() MUST check the return from these functions to - * discover when data is available on such fds and process it. - */ - PREPARE_ALLOW_NON_CALLBACKS = 1<<0 - }; - - /** - * Creates a looper. - * - * If allowNonCallbaks is true, the looper will allow file descriptors to be - * registered without associated callbacks. This assumes that the caller of - * pollOnce() is prepared to handle callback-less events itself. - */ - Looper(bool allowNonCallbacks); - - /** - * Returns whether this looper instance allows the registration of file descriptors - * using identifiers instead of callbacks. - */ - bool getAllowNonCallbacks() const; - - /** - * Waits for events to be available, with optional timeout in milliseconds. - * Invokes callbacks for all file descriptors on which an event occurred. - * - * If the timeout is zero, returns immediately without blocking. - * If the timeout is negative, waits indefinitely until an event appears. - * - * Returns POLL_WAKE if the poll was awoken using wake() before - * the timeout expired and no callbacks were invoked and no other file - * descriptors were ready. - * - * Returns POLL_CALLBACK if one or more callbacks were invoked. - * - * Returns POLL_TIMEOUT if there was no data before the given - * timeout expired. - * - * Returns POLL_ERROR if an error occurred. - * - * Returns a value >= 0 containing an identifier if its file descriptor has data - * and it has no callback function (requiring the caller here to handle it). - * In this (and only this) case outFd, outEvents and outData will contain the poll - * events and data associated with the fd, otherwise they will be set to NULL. - * - * This method does not return until it has finished invoking the appropriate callbacks - * for all file descriptors that were signalled. - */ - int pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData); - inline int pollOnce(int timeoutMillis) { - return pollOnce(timeoutMillis, NULL, NULL, NULL); - } - - /** - * Like pollOnce(), but performs all pending callbacks until all - * data has been consumed or a file descriptor is available with no callback. - * This function will never return POLL_CALLBACK. - */ - int pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData); - inline int pollAll(int timeoutMillis) { - return pollAll(timeoutMillis, NULL, NULL, NULL); - } - - /** - * Wakes the poll asynchronously. - * - * This method can be called on any thread. - * This method returns immediately. - */ - void wake(); - - /** - * Adds a new file descriptor to be polled by the looper. - * If the same file descriptor was previously added, it is replaced. - * - * "fd" is the file descriptor to be added. - * "ident" is an identifier for this event, which is returned from pollOnce(). - * The identifier must be >= 0, or POLL_CALLBACK if providing a non-NULL callback. - * "events" are the poll events to wake up on. Typically this is EVENT_INPUT. - * "callback" is the function to call when there is an event on the file descriptor. - * "data" is a private data pointer to supply to the callback. - * - * There are two main uses of this function: - * - * (1) If "callback" is non-NULL, then this function will be called when there is - * data on the file descriptor. It should execute any events it has pending, - * appropriately reading from the file descriptor. The 'ident' is ignored in this case. - * - * (2) If "callback" is NULL, the 'ident' will be returned by Looper_pollOnce - * when its file descriptor has data available, requiring the caller to take - * care of processing it. - * - * Returns 1 if the file descriptor was added, 0 if the arguments were invalid. - * - * This method can be called on any thread. - * This method may block briefly if it needs to wake the poll. - * - * The callback may either be specified as a bare function pointer or as a smart - * pointer callback object. The smart pointer should be preferred because it is - * easier to avoid races when the callback is removed from a different thread. - * See removeFd() for details. - */ - int addFd(int fd, int ident, int events, Looper_callbackFunc callback, void* data); - int addFd(int fd, int ident, int events, const sp& callback, void* data); - - /** - * Removes a previously added file descriptor from the looper. - * - * When this method returns, it is safe to close the file descriptor since the looper - * will no longer have a reference to it. However, it is possible for the callback to - * already be running or for it to run one last time if the file descriptor was already - * signalled. Calling code is responsible for ensuring that this case is safely handled. - * For example, if the callback takes care of removing itself during its own execution either - * by returning 0 or by calling this method, then it can be guaranteed to not be invoked - * again at any later time unless registered anew. - * - * A simple way to avoid this problem is to use the version of addFd() that takes - * a sp instead of a bare function pointer. The LooperCallback will - * be released at the appropriate time by the Looper. - * - * Returns 1 if the file descriptor was removed, 0 if none was previously registered. - * - * This method can be called on any thread. - * This method may block briefly if it needs to wake the poll. - */ - int removeFd(int fd); - - /** - * Enqueues a message to be processed by the specified handler. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessage(const sp& handler, const Message& message); - - /** - * Enqueues a message to be processed by the specified handler after all pending messages - * after the specified delay. - * - * The time delay is specified in uptime nanoseconds. - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessageDelayed(nsecs_t uptimeDelay, const sp& handler, - const Message& message); - - /** - * Enqueues a message to be processed by the specified handler after all pending messages - * at the specified time. - * - * The time is specified in uptime nanoseconds. - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessageAtTime(nsecs_t uptime, const sp& handler, - const Message& message); - - /** - * Removes all messages for the specified handler from the queue. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void removeMessages(const sp& handler); - - /** - * Removes all messages of a particular type for the specified handler from the queue. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void removeMessages(const sp& handler, int what); - - /** - * Returns whether this looper's thread is currently polling for more work to do. - * This is a good signal that the loop is still alive rather than being stuck - * handling a callback. Note that this method is intrinsically racy, since the - * state of the loop can change before you get the result back. - */ - bool isPolling() const; - - /** - * Prepares a looper associated with the calling thread, and returns it. - * If the thread already has a looper, it is returned. Otherwise, a new - * one is created, associated with the thread, and returned. - * - * The opts may be PREPARE_ALLOW_NON_CALLBACKS or 0. - */ - static sp prepare(int opts); - - /** - * Sets the given looper to be associated with the calling thread. - * If another looper is already associated with the thread, it is replaced. - * - * If "looper" is NULL, removes the currently associated looper. - */ - static void setForThread(const sp& looper); - - /** - * Returns the looper associated with the calling thread, or NULL if - * there is not one. - */ - static sp getForThread(); - -private: - struct Request { - int fd; - int ident; - int events; - int seq; - sp callback; - void* data; - - void initEventItem(struct epoll_event* eventItem) const; - }; - - struct Response { - int events; - Request request; - }; - - struct MessageEnvelope { - MessageEnvelope() : uptime(0) { } - - MessageEnvelope(nsecs_t uptime, const sp handler, - const Message& message) : uptime(uptime), handler(handler), message(message) { - } - - nsecs_t uptime; - sp handler; - Message message; - }; - - const bool mAllowNonCallbacks; // immutable - - int mWakeEventFd; // immutable - Mutex mLock; - - Vector mMessageEnvelopes; // guarded by mLock - bool mSendingMessage; // guarded by mLock - - // Whether we are currently waiting for work. Not protected by a lock, - // any use of it is racy anyway. - volatile bool mPolling; - - int mEpollFd; // guarded by mLock but only modified on the looper thread - bool mEpollRebuildRequired; // guarded by mLock - - // Locked list of file descriptor monitoring requests. - KeyedVector mRequests; // guarded by mLock - int mNextRequestSeq; - - // This state is only used privately by pollOnce and does not require a lock since - // it runs on a single thread. - Vector mResponses; - size_t mResponseIndex; - nsecs_t mNextMessageUptime; // set to LLONG_MAX when none - - int pollInner(int timeoutMillis); - int removeFd(int fd, int seq); - void awoken(); - void pushResponse(int events, const Request& request); - void rebuildEpollLocked(); - void scheduleEpollRebuildLocked(); - - static void initTLSKey(); - static void threadDestructor(void *st); - static void initEpollEvent(struct epoll_event* eventItem); -}; - -} // namespace android - -#endif // UTILS_LOOPER_H diff --git a/third_party/android_system_core/include/utils/LruCache.h b/third_party/android_system_core/include/utils/LruCache.h deleted file mode 100644 index cd9d7f94a0..0000000000 --- a/third_party/android_system_core/include/utils/LruCache.h +++ /dev/null @@ -1,250 +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_UTILS_LRU_CACHE_H -#define ANDROID_UTILS_LRU_CACHE_H - -#include -#include - -namespace android { - -/** - * GenerationCache callback used when an item is removed - */ -template -class OnEntryRemoved { -public: - virtual ~OnEntryRemoved() { }; - virtual void operator()(EntryKey& key, EntryValue& value) = 0; -}; // class OnEntryRemoved - -template -class LruCache { -public: - explicit LruCache(uint32_t maxCapacity); - - enum Capacity { - kUnlimitedCapacity, - }; - - void setOnEntryRemovedListener(OnEntryRemoved* listener); - size_t size() const; - const TValue& get(const TKey& key); - bool put(const TKey& key, const TValue& value); - bool remove(const TKey& key); - bool removeOldest(); - void clear(); - const TValue& peekOldestValue(); - - class Iterator { - public: - Iterator(const LruCache& cache): mCache(cache), mIndex(-1) { - } - - bool next() { - mIndex = mCache.mTable->next(mIndex); - return (ssize_t)mIndex != -1; - } - - size_t index() const { - return mIndex; - } - - const TValue& value() const { - return mCache.mTable->entryAt(mIndex).value; - } - - const TKey& key() const { - return mCache.mTable->entryAt(mIndex).key; - } - private: - const LruCache& mCache; - size_t mIndex; - }; - -private: - LruCache(const LruCache& that); // disallow copy constructor - - struct Entry { - TKey key; - TValue value; - Entry* parent; - Entry* child; - - Entry(TKey key_, TValue value_) : key(key_), value(value_), parent(NULL), child(NULL) { - } - const TKey& getKey() const { return key; } - }; - - void attachToCache(Entry& entry); - void detachFromCache(Entry& entry); - void rehash(size_t newCapacity); - - UniquePtr > mTable; - OnEntryRemoved* mListener; - Entry* mOldest; - Entry* mYoungest; - uint32_t mMaxCapacity; - TValue mNullValue; -}; - -// Implementation is here, because it's fully templated -template -LruCache::LruCache(uint32_t maxCapacity) - : mTable(new BasicHashtable) - , mListener(NULL) - , mOldest(NULL) - , mYoungest(NULL) - , mMaxCapacity(maxCapacity) - , mNullValue(NULL) { -}; - -template -void LruCache::setOnEntryRemovedListener(OnEntryRemoved* listener) { - mListener = listener; -} - -template -size_t LruCache::size() const { - return mTable->size(); -} - -template -const TValue& LruCache::get(const TKey& key) { - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index == -1) { - return mNullValue; - } - Entry& entry = mTable->editEntryAt(index); - detachFromCache(entry); - attachToCache(entry); - return entry.value; -} - -template -bool LruCache::put(const TKey& key, const TValue& value) { - if (mMaxCapacity != kUnlimitedCapacity && size() >= mMaxCapacity) { - removeOldest(); - } - - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index >= 0) { - return false; - } - if (!mTable->hasMoreRoom()) { - rehash(mTable->capacity() * 2); - } - - // Would it be better to initialize a blank entry and assign key, value? - Entry initEntry(key, value); - index = mTable->add(hash, initEntry); - Entry& entry = mTable->editEntryAt(index); - attachToCache(entry); - return true; -} - -template -bool LruCache::remove(const TKey& key) { - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index < 0) { - return false; - } - Entry& entry = mTable->editEntryAt(index); - if (mListener) { - (*mListener)(entry.key, entry.value); - } - detachFromCache(entry); - mTable->removeAt(index); - return true; -} - -template -bool LruCache::removeOldest() { - if (mOldest != NULL) { - return remove(mOldest->key); - // TODO: should probably abort if false - } - return false; -} - -template -const TValue& LruCache::peekOldestValue() { - if (mOldest) { - return mOldest->value; - } - return mNullValue; -} - -template -void LruCache::clear() { - if (mListener) { - for (Entry* p = mOldest; p != NULL; p = p->child) { - (*mListener)(p->key, p->value); - } - } - mYoungest = NULL; - mOldest = NULL; - mTable->clear(); -} - -template -void LruCache::attachToCache(Entry& entry) { - if (mYoungest == NULL) { - mYoungest = mOldest = &entry; - } else { - entry.parent = mYoungest; - mYoungest->child = &entry; - mYoungest = &entry; - } -} - -template -void LruCache::detachFromCache(Entry& entry) { - if (entry.parent != NULL) { - entry.parent->child = entry.child; - } else { - mOldest = entry.child; - } - if (entry.child != NULL) { - entry.child->parent = entry.parent; - } else { - mYoungest = entry.parent; - } - - entry.parent = NULL; - entry.child = NULL; -} - -template -void LruCache::rehash(size_t newCapacity) { - UniquePtr > oldTable(mTable.release()); - Entry* oldest = mOldest; - - mOldest = NULL; - mYoungest = NULL; - mTable.reset(new BasicHashtable(newCapacity)); - for (Entry* p = oldest; p != NULL; p = p->child) { - put(p->key, p->value); - } -} - -} - -#endif // ANDROID_UTILS_LRU_CACHE_H diff --git a/third_party/android_system_core/include/utils/Mutex.h b/third_party/android_system_core/include/utils/Mutex.h deleted file mode 100644 index 757519b086..0000000000 --- a/third_party/android_system_core/include/utils/Mutex.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_UTILS_MUTEX_H -#define _LIBS_UTILS_MUTEX_H - -#include -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -class Condition; - -/* - * Simple mutex class. The implementation is system-dependent. - * - * The mutex must be unlocked by the thread that locked it. They are not - * recursive, i.e. the same thread can't lock it multiple times. - */ -class Mutex { -public: - enum { - PRIVATE = 0, - SHARED = 1 - }; - - Mutex(); - Mutex(const char* name); - Mutex(int type, const char* name = NULL); - ~Mutex(); - - // lock or unlock the mutex - status_t lock(); - void unlock(); - - // lock if possible; returns 0 on success, error otherwise - status_t tryLock(); - -#if HAVE_ANDROID_OS - // lock the mutex, but don't wait longer than timeoutMilliseconds. - // Returns 0 on success, TIMED_OUT for failure due to timeout expiration. - // - // OSX doesn't have pthread_mutex_timedlock() or equivalent. To keep - // capabilities consistent across host OSes, this method is only available - // when building Android binaries. - status_t timedLock(nsecs_t timeoutMilliseconds); -#endif - - // Manages the mutex automatically. It'll be locked when Autolock is - // constructed and released when Autolock goes out of scope. - class Autolock { - public: - inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); } - inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); } - inline ~Autolock() { mLock.unlock(); } - private: - Mutex& mLock; - }; - -private: - friend class Condition; - - // A mutex cannot be copied - Mutex(const Mutex&); - Mutex& operator = (const Mutex&); - -#if !defined(_WIN32) - pthread_mutex_t mMutex; -#else - void _init(); - void* mState; -#endif -}; - -// --------------------------------------------------------------------------- - -#if !defined(_WIN32) - -inline Mutex::Mutex() { - pthread_mutex_init(&mMutex, NULL); -} -inline Mutex::Mutex(__attribute__((unused)) const char* name) { - pthread_mutex_init(&mMutex, NULL); -} -inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) { - if (type == SHARED) { - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_mutex_init(&mMutex, &attr); - pthread_mutexattr_destroy(&attr); - } else { - pthread_mutex_init(&mMutex, NULL); - } -} -inline Mutex::~Mutex() { - pthread_mutex_destroy(&mMutex); -} -inline status_t Mutex::lock() { - return -pthread_mutex_lock(&mMutex); -} -inline void Mutex::unlock() { - pthread_mutex_unlock(&mMutex); -} -inline status_t Mutex::tryLock() { - return -pthread_mutex_trylock(&mMutex); -} -#if HAVE_ANDROID_OS -inline status_t Mutex::timedLock(nsecs_t timeoutNs) { - const struct timespec ts = { - /* .tv_sec = */ static_cast(timeoutNs / 1000000000), - /* .tv_nsec = */ static_cast(timeoutNs % 1000000000), - }; - return -pthread_mutex_timedlock(&mMutex, &ts); -} -#endif - -#endif // !defined(_WIN32) - -// --------------------------------------------------------------------------- - -/* - * Automatic mutex. Declare one of these at the top of a function. - * When the function returns, it will go out of scope, and release the - * mutex. - */ - -typedef Mutex::Autolock AutoMutex; - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_MUTEX_H diff --git a/third_party/android_system_core/include/utils/NativeHandle.h b/third_party/android_system_core/include/utils/NativeHandle.h deleted file mode 100644 index b82516879a..0000000000 --- a/third_party/android_system_core/include/utils/NativeHandle.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2014 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_NATIVE_HANDLE_H -#define ANDROID_NATIVE_HANDLE_H - -#include -#include - -typedef struct native_handle native_handle_t; - -namespace android { - -class NativeHandle: public LightRefBase { -public: - // Create a refcounted wrapper around a native_handle_t, and declare - // whether the wrapper owns the handle (so that it should clean up the - // handle upon destruction) or not. - // If handle is NULL, no NativeHandle will be created. - static sp create(native_handle_t* handle, bool ownsHandle); - - const native_handle_t* handle() const { - return mHandle; - } - -private: - // for access to the destructor - friend class LightRefBase; - - NativeHandle(native_handle_t* handle, bool ownsHandle); - virtual ~NativeHandle(); - - native_handle_t* mHandle; - bool mOwnsHandle; - - // non-copyable - NativeHandle(const NativeHandle&); - NativeHandle& operator=(const NativeHandle&); -}; - -} // namespace android - -#endif // ANDROID_NATIVE_HANDLE_H diff --git a/third_party/android_system_core/include/utils/Printer.h b/third_party/android_system_core/include/utils/Printer.h deleted file mode 100644 index bb6628767c..0000000000 --- a/third_party/android_system_core/include/utils/Printer.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2013 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_PRINTER_H -#define ANDROID_PRINTER_H - -#include - -namespace android { - -// Interface for printing to an arbitrary data stream -class Printer { -public: - // Print a new line specified by 'string'. \n is appended automatically. - // -- Assumes that the string has no new line in it. - virtual void printLine(const char* string = "") = 0; - - // Print a new line specified by the format string. \n is appended automatically. - // -- Assumes that the resulting string has no new line in it. - virtual void printFormatLine(const char* format, ...) __attribute__((format (printf, 2, 3))); - -protected: - Printer(); - virtual ~Printer(); -}; // class Printer - -// Print to logcat -class LogPrinter : public Printer { -public: - // Create a printer using the specified logcat and log priority - // - Unless ignoreBlankLines is false, print blank lines to logcat - // (Note that the default ALOG behavior is to ignore blank lines) - LogPrinter(const char* logtag, - android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0, - bool ignoreBlankLines = false); - - // Print the specified line to logcat. No \n at the end is necessary. - virtual void printLine(const char* string); - -private: - void printRaw(const char* string); - - const char* mLogTag; - android_LogPriority mPriority; - const char* mPrefix; - bool mIgnoreBlankLines; -}; // class LogPrinter - -// Print to a file descriptor -class FdPrinter : public Printer { -public: - // Create a printer using the specified file descriptor. - // - Each line will be prefixed with 'indent' number of blank spaces. - // - In addition, each line will be prefixed with the 'prefix' string. - FdPrinter(int fd, unsigned int indent = 0, const char* prefix = 0); - - // Print the specified line to the file descriptor. \n is appended automatically. - virtual void printLine(const char* string); - -private: - enum { - MAX_FORMAT_STRING = 20, - }; - - int mFd; - unsigned int mIndent; - const char* mPrefix; - char mFormatString[MAX_FORMAT_STRING]; -}; // class FdPrinter - -class String8; - -// Print to a String8 -class String8Printer : public Printer { -public: - // Create a printer using the specified String8 as the target. - // - In addition, each line will be prefixed with the 'prefix' string. - // - target's memory lifetime must be a superset of this String8Printer. - String8Printer(String8* target, const char* prefix = 0); - - // Append the specified line to the String8. \n is appended automatically. - virtual void printLine(const char* string); - -private: - String8* mTarget; - const char* mPrefix; -}; // class String8Printer - -// Print to an existing Printer by adding a prefix to each line -class PrefixPrinter : public Printer { -public: - // Create a printer using the specified printer as the target. - PrefixPrinter(Printer& printer, const char* prefix); - - // Print the line (prefixed with prefix) using the printer. - virtual void printLine(const char* string); - -private: - Printer& mPrinter; - const char* mPrefix; -}; - -}; // namespace android - -#endif // ANDROID_PRINTER_H diff --git a/third_party/android_system_core/include/utils/ProcessCallStack.h b/third_party/android_system_core/include/utils/ProcessCallStack.h deleted file mode 100644 index 32458b8b14..0000000000 --- a/third_party/android_system_core/include/utils/ProcessCallStack.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013 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_PROCESS_CALLSTACK_H -#define ANDROID_PROCESS_CALLSTACK_H - -#include -#include -#include -#include - -#include -#include - -namespace android { - -class Printer; - -// Collect/print the call stack (function, file, line) traces for all threads in a process. -class ProcessCallStack { -public: - // Create an empty call stack. No-op. - ProcessCallStack(); - // Copy the existing process callstack (no other side effects). - ProcessCallStack(const ProcessCallStack& rhs); - ~ProcessCallStack(); - - // Immediately collect the stack traces for all threads. - void update(); - - // Print all stack traces to the log using the supplied logtag. - void log(const char* logtag, android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0) const; - - // Dump all stack traces to the specified file descriptor. - void dump(int fd, int indent = 0, const char* prefix = 0) const; - - // Return a string (possibly very long) containing all the stack traces. - String8 toString(const char* prefix = 0) const; - - // Dump a serialized representation of all the stack traces to the specified printer. - void print(Printer& printer) const; - - // Get the number of threads whose stack traces were collected. - size_t size() const; - -private: - void printInternal(Printer& printer, Printer& csPrinter) const; - - // Reset the process's stack frames and metadata. - void clear(); - - struct ThreadInfo { - CallStack callStack; - String8 threadName; - }; - - // tid -> ThreadInfo - KeyedVector mThreadMap; - // Time that update() was last called - struct tm mTimeUpdated; -}; - -}; // namespace android - -#endif // ANDROID_PROCESS_CALLSTACK_H diff --git a/third_party/android_system_core/include/utils/PropertyMap.h b/third_party/android_system_core/include/utils/PropertyMap.h deleted file mode 100644 index a9e674f9af..0000000000 --- a/third_party/android_system_core/include/utils/PropertyMap.h +++ /dev/null @@ -1,106 +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 _UTILS_PROPERTY_MAP_H -#define _UTILS_PROPERTY_MAP_H - -#include -#include -#include -#include - -namespace android { - -/* - * Provides a mechanism for passing around string-based property key / value pairs - * and loading them from property files. - * - * The property files have the following simple structure: - * - * # Comment - * key = value - * - * Keys and values are any sequence of printable ASCII characters. - * The '=' separates the key from the value. - * The key and value may not contain whitespace. - * - * The '\' character is reserved for escape sequences and is not currently supported. - * The '"" character is reserved for quoting and is not currently supported. - * Files that contain the '\' or '"' character will fail to parse. - * - * The file must not contain duplicate keys. - * - * TODO Support escape sequences and quoted values when needed. - */ -class PropertyMap { -public: - /* Creates an empty property map. */ - PropertyMap(); - ~PropertyMap(); - - /* Clears the property map. */ - void clear(); - - /* Adds a property. - * Replaces the property with the same key if it is already present. - */ - void addProperty(const String8& key, const String8& value); - - /* Returns true if the property map contains the specified key. */ - bool hasProperty(const String8& key) const; - - /* Gets the value of a property and parses it. - * Returns true and sets outValue if the key was found and its value was parsed successfully. - * Otherwise returns false and does not modify outValue. (Also logs a warning.) - */ - bool tryGetProperty(const String8& key, String8& outValue) const; - bool tryGetProperty(const String8& key, bool& outValue) const; - bool tryGetProperty(const String8& key, int32_t& outValue) const; - bool tryGetProperty(const String8& key, float& outValue) const; - - /* Adds all values from the specified property map. */ - void addAll(const PropertyMap* map); - - /* Gets the underlying property map. */ - inline const KeyedVector& getProperties() const { return mProperties; } - - /* Loads a property map from a file. */ - static status_t load(const String8& filename, PropertyMap** outMap); - -private: - class Parser { - PropertyMap* mMap; - Tokenizer* mTokenizer; - - public: - Parser(PropertyMap* map, Tokenizer* tokenizer); - ~Parser(); - status_t parse(); - - private: - status_t parseType(); - status_t parseKey(); - status_t parseKeyProperty(); - status_t parseModifier(const String8& token, int32_t* outMetaState); - status_t parseCharacterLiteral(char16_t* outCharacter); - }; - - KeyedVector mProperties; -}; - -} // namespace android - -#endif // _UTILS_PROPERTY_MAP_H diff --git a/third_party/android_system_core/include/utils/RWLock.h b/third_party/android_system_core/include/utils/RWLock.h deleted file mode 100644 index e743b1c8ce..0000000000 --- a/third_party/android_system_core/include/utils/RWLock.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_UTILS_RWLOCK_H -#define _LIBS_UTILS_RWLOCK_H - -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -#if !defined(_WIN32) - -/* - * Simple mutex class. The implementation is system-dependent. - * - * The mutex must be unlocked by the thread that locked it. They are not - * recursive, i.e. the same thread can't lock it multiple times. - */ -class RWLock { -public: - enum { - PRIVATE = 0, - SHARED = 1 - }; - - RWLock(); - RWLock(const char* name); - RWLock(int type, const char* name = NULL); - ~RWLock(); - - status_t readLock(); - status_t tryReadLock(); - status_t writeLock(); - status_t tryWriteLock(); - void unlock(); - - class AutoRLock { - public: - inline AutoRLock(RWLock& rwlock) : mLock(rwlock) { mLock.readLock(); } - inline ~AutoRLock() { mLock.unlock(); } - private: - RWLock& mLock; - }; - - class AutoWLock { - public: - inline AutoWLock(RWLock& rwlock) : mLock(rwlock) { mLock.writeLock(); } - inline ~AutoWLock() { mLock.unlock(); } - private: - RWLock& mLock; - }; - -private: - // A RWLock cannot be copied - RWLock(const RWLock&); - RWLock& operator = (const RWLock&); - - pthread_rwlock_t mRWLock; -}; - -inline RWLock::RWLock() { - pthread_rwlock_init(&mRWLock, NULL); -} -inline RWLock::RWLock(__attribute__((unused)) const char* name) { - pthread_rwlock_init(&mRWLock, NULL); -} -inline RWLock::RWLock(int type, __attribute__((unused)) const char* name) { - if (type == SHARED) { - pthread_rwlockattr_t attr; - pthread_rwlockattr_init(&attr); - pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_rwlock_init(&mRWLock, &attr); - pthread_rwlockattr_destroy(&attr); - } else { - pthread_rwlock_init(&mRWLock, NULL); - } -} -inline RWLock::~RWLock() { - pthread_rwlock_destroy(&mRWLock); -} -inline status_t RWLock::readLock() { - return -pthread_rwlock_rdlock(&mRWLock); -} -inline status_t RWLock::tryReadLock() { - return -pthread_rwlock_tryrdlock(&mRWLock); -} -inline status_t RWLock::writeLock() { - return -pthread_rwlock_wrlock(&mRWLock); -} -inline status_t RWLock::tryWriteLock() { - return -pthread_rwlock_trywrlock(&mRWLock); -} -inline void RWLock::unlock() { - pthread_rwlock_unlock(&mRWLock); -} - -#endif // !defined(_WIN32) - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_RWLOCK_H diff --git a/third_party/android_system_core/include/utils/RefBase.h b/third_party/android_system_core/include/utils/RefBase.h deleted file mode 100644 index eac6a78402..0000000000 --- a/third_party/android_system_core/include/utils/RefBase.h +++ /dev/null @@ -1,555 +0,0 @@ -/* - * Copyright (C) 2005 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_REF_BASE_H -#define ANDROID_REF_BASE_H - -#include - -#include -#include -#include -#include - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -class TextOutput; -TextOutput& printWeakPointer(TextOutput& to, const void* val); - -// --------------------------------------------------------------------------- - -#define COMPARE_WEAK(_op_) \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -inline bool operator _op_ (const T* o) const { \ - return m_ptr _op_ o; \ -} \ -template \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const U* o) const { \ - return m_ptr _op_ o; \ -} - -// --------------------------------------------------------------------------- - -class ReferenceRenamer { -protected: - // destructor is purposedly not virtual so we avoid code overhead from - // subclasses; we have to make it protected to guarantee that it - // cannot be called from this base class (and to make strict compilers - // happy). - ~ReferenceRenamer() { } -public: - virtual void operator()(size_t i) const = 0; -}; - -// --------------------------------------------------------------------------- - -class RefBase -{ -public: - void incStrong(const void* id) const; - void decStrong(const void* id) const; - - void forceIncStrong(const void* id) const; - - //! DEBUGGING ONLY: Get current strong ref count. - int32_t getStrongCount() const; - - class weakref_type - { - public: - RefBase* refBase() const; - - void incWeak(const void* id); - void decWeak(const void* id); - - // acquires a strong reference if there is already one. - bool attemptIncStrong(const void* id); - - // acquires a weak reference if there is already one. - // This is not always safe. see ProcessState.cpp and BpBinder.cpp - // for proper use. - bool attemptIncWeak(const void* id); - - //! DEBUGGING ONLY: Get current weak ref count. - int32_t getWeakCount() const; - - //! DEBUGGING ONLY: Print references held on object. - void printRefs() const; - - //! DEBUGGING ONLY: Enable tracking for this object. - // enable -- enable/disable tracking - // retain -- when tracking is enable, if true, then we save a stack trace - // for each reference and dereference; when retain == false, we - // match up references and dereferences and keep only the - // outstanding ones. - - void trackMe(bool enable, bool retain); - }; - - weakref_type* createWeak(const void* id) const; - - weakref_type* getWeakRefs() const; - - //! DEBUGGING ONLY: Print references held on object. - inline void printRefs() const { getWeakRefs()->printRefs(); } - - //! DEBUGGING ONLY: Enable tracking of object. - inline void trackMe(bool enable, bool retain) - { - getWeakRefs()->trackMe(enable, retain); - } - - typedef RefBase basetype; - -protected: - RefBase(); - virtual ~RefBase(); - - //! Flags for extendObjectLifetime() - enum { - OBJECT_LIFETIME_STRONG = 0x0000, - OBJECT_LIFETIME_WEAK = 0x0001, - OBJECT_LIFETIME_MASK = 0x0001 - }; - - void extendObjectLifetime(int32_t mode); - - //! Flags for onIncStrongAttempted() - enum { - FIRST_INC_STRONG = 0x0001 - }; - - virtual void onFirstRef(); - virtual void onLastStrongRef(const void* id); - virtual bool onIncStrongAttempted(uint32_t flags, const void* id); - virtual void onLastWeakRef(const void* id); - -private: - friend class weakref_type; - class weakref_impl; - - RefBase(const RefBase& o); - RefBase& operator=(const RefBase& o); - -private: - friend class ReferenceMover; - - static void renameRefs(size_t n, const ReferenceRenamer& renamer); - - static void renameRefId(weakref_type* ref, - const void* old_id, const void* new_id); - - static void renameRefId(RefBase* ref, - const void* old_id, const void* new_id); - - weakref_impl* const mRefs; -}; - -// --------------------------------------------------------------------------- - -template -class LightRefBase -{ -public: - inline LightRefBase() : mCount(0) { } - inline void incStrong(__attribute__((unused)) const void* id) const { - android_atomic_inc(&mCount); - } - inline void decStrong(__attribute__((unused)) const void* id) const { - if (android_atomic_dec(&mCount) == 1) { - delete static_cast(this); - } - } - //! DEBUGGING ONLY: Get current strong ref count. - inline int32_t getStrongCount() const { - return mCount; - } - - typedef LightRefBase basetype; - -protected: - inline ~LightRefBase() { } - -private: - friend class ReferenceMover; - inline static void renameRefs(size_t n, const ReferenceRenamer& renamer) { } - inline static void renameRefId(T* ref, - const void* old_id, const void* new_id) { } - -private: - mutable volatile int32_t mCount; -}; - -// This is a wrapper around LightRefBase that simply enforces a virtual -// destructor to eliminate the template requirement of LightRefBase -class VirtualLightRefBase : public LightRefBase { -public: - virtual ~VirtualLightRefBase() {} -}; - -// --------------------------------------------------------------------------- - -template -class wp -{ -public: - typedef typename RefBase::weakref_type weakref_type; - - inline wp() : m_ptr(0) { } - - wp(T* other); - wp(const wp& other); - wp(const sp& other); - template wp(U* other); - template wp(const sp& other); - template wp(const wp& other); - - ~wp(); - - // Assignment - - wp& operator = (T* other); - wp& operator = (const wp& other); - wp& operator = (const sp& other); - - template wp& operator = (U* other); - template wp& operator = (const wp& other); - template wp& operator = (const sp& other); - - void set_object_and_refs(T* other, weakref_type* refs); - - // promotion to sp - - sp promote() const; - - // Reset - - void clear(); - - // Accessors - - inline weakref_type* get_refs() const { return m_refs; } - - inline T* unsafe_get() const { return m_ptr; } - - // Operators - - COMPARE_WEAK(==) - COMPARE_WEAK(!=) - COMPARE_WEAK(>) - COMPARE_WEAK(<) - COMPARE_WEAK(<=) - COMPARE_WEAK(>=) - - inline bool operator == (const wp& o) const { - return (m_ptr == o.m_ptr) && (m_refs == o.m_refs); - } - template - inline bool operator == (const wp& o) const { - return m_ptr == o.m_ptr; - } - - inline bool operator > (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); - } - template - inline bool operator > (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); - } - - inline bool operator < (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); - } - template - inline bool operator < (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); - } - inline bool operator != (const wp& o) const { return m_refs != o.m_refs; } - template inline bool operator != (const wp& o) const { return !operator == (o); } - inline bool operator <= (const wp& o) const { return !operator > (o); } - template inline bool operator <= (const wp& o) const { return !operator > (o); } - inline bool operator >= (const wp& o) const { return !operator < (o); } - template inline bool operator >= (const wp& o) const { return !operator < (o); } - -private: - template friend class sp; - template friend class wp; - - T* m_ptr; - weakref_type* m_refs; -}; - -template -TextOutput& operator<<(TextOutput& to, const wp& val); - -#undef COMPARE_WEAK - -// --------------------------------------------------------------------------- -// No user serviceable parts below here. - -template -wp::wp(T* other) - : m_ptr(other) -{ - if (other) m_refs = other->createWeak(this); -} - -template -wp::wp(const wp& other) - : m_ptr(other.m_ptr), m_refs(other.m_refs) -{ - if (m_ptr) m_refs->incWeak(this); -} - -template -wp::wp(const sp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = m_ptr->createWeak(this); - } -} - -template template -wp::wp(U* other) - : m_ptr(other) -{ - if (other) m_refs = other->createWeak(this); -} - -template template -wp::wp(const wp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = other.m_refs; - m_refs->incWeak(this); - } -} - -template template -wp::wp(const sp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = m_ptr->createWeak(this); - } -} - -template -wp::~wp() -{ - if (m_ptr) m_refs->decWeak(this); -} - -template -wp& wp::operator = (T* other) -{ - weakref_type* newRefs = - other ? other->createWeak(this) : 0; - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = newRefs; - return *this; -} - -template -wp& wp::operator = (const wp& other) -{ - weakref_type* otherRefs(other.m_refs); - T* otherPtr(other.m_ptr); - if (otherPtr) otherRefs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = otherRefs; - return *this; -} - -template -wp& wp::operator = (const sp& other) -{ - weakref_type* newRefs = - other != NULL ? other->createWeak(this) : 0; - T* otherPtr(other.m_ptr); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = newRefs; - return *this; -} - -template template -wp& wp::operator = (U* other) -{ - weakref_type* newRefs = - other ? other->createWeak(this) : 0; - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = newRefs; - return *this; -} - -template template -wp& wp::operator = (const wp& other) -{ - weakref_type* otherRefs(other.m_refs); - U* otherPtr(other.m_ptr); - if (otherPtr) otherRefs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = otherRefs; - return *this; -} - -template template -wp& wp::operator = (const sp& other) -{ - weakref_type* newRefs = - other != NULL ? other->createWeak(this) : 0; - U* otherPtr(other.m_ptr); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = newRefs; - return *this; -} - -template -void wp::set_object_and_refs(T* other, weakref_type* refs) -{ - if (other) refs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = refs; -} - -template -sp wp::promote() const -{ - sp result; - if (m_ptr && m_refs->attemptIncStrong(&result)) { - result.set_pointer(m_ptr); - } - return result; -} - -template -void wp::clear() -{ - if (m_ptr) { - m_refs->decWeak(this); - m_ptr = 0; - } -} - -template -inline TextOutput& operator<<(TextOutput& to, const wp& val) -{ - return printWeakPointer(to, val.unsafe_get()); -} - -// --------------------------------------------------------------------------- - -// this class just serves as a namespace so TYPE::moveReferences can stay -// private. -class ReferenceMover { -public: - // it would be nice if we could make sure no extra code is generated - // for sp or wp when TYPE is a descendant of RefBase: - // Using a sp override doesn't work; it's a bit like we wanted - // a template template... - - template static inline - void move_references(sp* d, sp const* s, size_t n) { - - class Renamer : public ReferenceRenamer { - sp* d; - sp const* s; - virtual void operator()(size_t i) const { - // The id are known to be the sp<>'s this pointer - TYPE::renameRefId(d[i].get(), &s[i], &d[i]); - } - public: - Renamer(sp* d, sp const* s) : d(d), s(s) { } - virtual ~Renamer() { } - }; - - memmove(d, s, n*sizeof(sp)); - TYPE::renameRefs(n, Renamer(d, s)); - } - - - template static inline - void move_references(wp* d, wp const* s, size_t n) { - - class Renamer : public ReferenceRenamer { - wp* d; - wp const* s; - virtual void operator()(size_t i) const { - // The id are known to be the wp<>'s this pointer - TYPE::renameRefId(d[i].get_refs(), &s[i], &d[i]); - } - public: - Renamer(wp* d, wp const* s) : d(d), s(s) { } - virtual ~Renamer() { } - }; - - memmove(d, s, n*sizeof(wp)); - TYPE::renameRefs(n, Renamer(d, s)); - } -}; - -// specialization for moving sp<> and wp<> types. -// these are used by the [Sorted|Keyed]Vector<> implementations -// sp<> and wp<> need to be handled specially, because they do not -// have trivial copy operation in the general case (see RefBase.cpp -// when DEBUG ops are enabled), but can be implemented very -// efficiently in most cases. - -template inline -void move_forward_type(sp* d, sp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_backward_type(sp* d, sp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_forward_type(wp* d, wp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_backward_type(wp* d, wp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_REF_BASE_H diff --git a/third_party/android_system_core/include/utils/SharedBuffer.h b/third_party/android_system_core/include/utils/SharedBuffer.h deleted file mode 100644 index b6709537e6..0000000000 --- a/third_party/android_system_core/include/utils/SharedBuffer.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2005 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_SHARED_BUFFER_H -#define ANDROID_SHARED_BUFFER_H - -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class SharedBuffer -{ -public: - - /* flags to use with release() */ - enum { - eKeepStorage = 0x00000001 - }; - - /*! allocate a buffer of size 'size' and acquire() it. - * call release() to free it. - */ - static SharedBuffer* alloc(size_t size); - - /*! free the memory associated with the SharedBuffer. - * Fails if there are any users associated with this SharedBuffer. - * In other words, the buffer must have been release by all its - * users. - */ - static ssize_t dealloc(const SharedBuffer* released); - - //! access the data for read - inline const void* data() const; - - //! access the data for read/write - inline void* data(); - - //! get size of the buffer - inline size_t size() const; - - //! get back a SharedBuffer object from its data - static inline SharedBuffer* bufferFromData(void* data); - - //! get back a SharedBuffer object from its data - static inline const SharedBuffer* bufferFromData(const void* data); - - //! get the size of a SharedBuffer object from its data - static inline size_t sizeFromData(const void* data); - - //! edit the buffer (get a writtable, or non-const, version of it) - SharedBuffer* edit() const; - - //! edit the buffer, resizing if needed - SharedBuffer* editResize(size_t size) const; - - //! like edit() but fails if a copy is required - SharedBuffer* attemptEdit() const; - - //! resize and edit the buffer, loose it's content. - SharedBuffer* reset(size_t size) const; - - //! acquire/release a reference on this buffer - void acquire() const; - - /*! release a reference on this buffer, with the option of not - * freeing the memory associated with it if it was the last reference - * returns the previous reference count - */ - int32_t release(uint32_t flags = 0) const; - - //! returns wether or not we're the only owner - inline bool onlyOwner() const; - - -private: - inline SharedBuffer() { } - inline ~SharedBuffer() { } - SharedBuffer(const SharedBuffer&); - SharedBuffer& operator = (const SharedBuffer&); - - // 16 bytes. must be sized to preserve correct alignment. - mutable int32_t mRefs; - size_t mSize; - uint32_t mReserved[2]; -}; - -// --------------------------------------------------------------------------- - -const void* SharedBuffer::data() const { - return this + 1; -} - -void* SharedBuffer::data() { - return this + 1; -} - -size_t SharedBuffer::size() const { - return mSize; -} - -SharedBuffer* SharedBuffer::bufferFromData(void* data) { - return data ? static_cast(data)-1 : 0; -} - -const SharedBuffer* SharedBuffer::bufferFromData(const void* data) { - return data ? static_cast(data)-1 : 0; -} - -size_t SharedBuffer::sizeFromData(const void* data) { - return data ? bufferFromData(data)->mSize : 0; -} - -bool SharedBuffer::onlyOwner() const { - return (mRefs == 1); -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_H diff --git a/third_party/android_system_core/include/utils/Singleton.h b/third_party/android_system_core/include/utils/Singleton.h deleted file mode 100644 index ffc03cb5d6..0000000000 --- a/third_party/android_system_core/include/utils/Singleton.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2007 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_UTILS_SINGLETON_H -#define ANDROID_UTILS_SINGLETON_H - -#include -#include -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -template -class ANDROID_API Singleton -{ -public: - static TYPE& getInstance() { - Mutex::Autolock _l(sLock); - TYPE* instance = sInstance; - if (instance == 0) { - instance = new TYPE(); - sInstance = instance; - } - return *instance; - } - - static bool hasInstance() { - Mutex::Autolock _l(sLock); - return sInstance != 0; - } - -protected: - ~Singleton() { }; - Singleton() { }; - -private: - Singleton(const Singleton&); - Singleton& operator = (const Singleton&); - static Mutex sLock; - static TYPE* sInstance; -}; - -/* - * use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file - * (eg: .cpp) to create the static instance of Singleton<>'s attributes, - * and avoid to have a copy of them in each compilation units Singleton - * is used. - * NOTE: we use a version of Mutex ctor that takes a parameter, because - * for some unknown reason using the default ctor doesn't emit the variable! - */ - -#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \ - template<> ::android::Mutex \ - (::android::Singleton< TYPE >::sLock)(::android::Mutex::PRIVATE); \ - template<> TYPE* ::android::Singleton< TYPE >::sInstance(0); \ - template class ::android::Singleton< TYPE >; - - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_UTILS_SINGLETON_H - diff --git a/third_party/android_system_core/include/utils/SortedVector.h b/third_party/android_system_core/include/utils/SortedVector.h deleted file mode 100644 index 2d3e82a7c0..0000000000 --- a/third_party/android_system_core/include/utils/SortedVector.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (C) 2005 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_SORTED_VECTOR_H -#define ANDROID_SORTED_VECTOR_H - -#include -#include -#include - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class SortedVector : private SortedVectorImpl -{ - friend class Vector; - -public: - typedef TYPE value_type; - - /*! - * Constructors and destructors - */ - - SortedVector(); - SortedVector(const SortedVector& rhs); - virtual ~SortedVector(); - - /*! copy operator */ - const SortedVector& operator = (const SortedVector& rhs) const; - SortedVector& operator = (const SortedVector& rhs); - - /* - * empty the vector - */ - - inline void clear() { VectorImpl::clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return VectorImpl::size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return VectorImpl::isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return VectorImpl::capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); } - - /*! - * C-style array access - */ - - //! read-only C-style access - inline const TYPE* array() const; - - //! read-write C-style access. BE VERY CAREFUL when modifying the array - //! you must keep it sorted! You usually don't use this function. - TYPE* editArray(); - - //! finds the index of an item - ssize_t indexOf(const TYPE& item) const; - - //! finds where this item should be inserted - size_t orderOf(const TYPE& item) const; - - - /*! - * accessors - */ - - //! read-only access to an item at a given index - inline const TYPE& operator [] (size_t index) const; - //! alternate name for operator [] - inline const TYPE& itemAt(size_t index) const; - //! stack-usage of the vector. returns the top of the stack (last element) - const TYPE& top() const; - - /*! - * modifying the array - */ - - //! add an item in the right place (and replace the one that is there) - ssize_t add(const TYPE& item); - - //! editItemAt() MUST NOT change the order of this item - TYPE& editItemAt(size_t index) { - return *( static_cast(VectorImpl::editItemLocation(index)) ); - } - - //! merges a vector into this one - ssize_t merge(const Vector& vector); - ssize_t merge(const SortedVector& vector); - - //! removes an item - ssize_t remove(const TYPE&); - - //! remove several items - inline ssize_t removeItemsAt(size_t index, size_t count = 1); - //! remove one item - inline ssize_t removeAt(size_t index) { return removeItemsAt(index); } - -protected: - virtual void do_construct(void* storage, size_t num) const; - virtual void do_destroy(void* storage, size_t num) const; - virtual void do_copy(void* dest, const void* from, size_t num) const; - virtual void do_splat(void* dest, const void* item, size_t num) const; - virtual void do_move_forward(void* dest, const void* from, size_t num) const; - virtual void do_move_backward(void* dest, const void* from, size_t num) const; - virtual int do_compare(const void* lhs, const void* rhs) const; -}; - -// SortedVector can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -template struct trait_trivial_move > { enum { value = true }; }; - -// --------------------------------------------------------------------------- -// No user serviceable parts from here... -// --------------------------------------------------------------------------- - -template inline -SortedVector::SortedVector() - : SortedVectorImpl(sizeof(TYPE), - ((traits::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0) - |(traits::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0) - |(traits::has_trivial_copy ? HAS_TRIVIAL_COPY : 0)) - ) -{ -} - -template inline -SortedVector::SortedVector(const SortedVector& rhs) - : SortedVectorImpl(rhs) { -} - -template inline -SortedVector::~SortedVector() { - finish_vector(); -} - -template inline -SortedVector& SortedVector::operator = (const SortedVector& rhs) { - SortedVectorImpl::operator = (rhs); - return *this; -} - -template inline -const SortedVector& SortedVector::operator = (const SortedVector& rhs) const { - SortedVectorImpl::operator = (rhs); - return *this; -} - -template inline -const TYPE* SortedVector::array() const { - return static_cast(arrayImpl()); -} - -template inline -TYPE* SortedVector::editArray() { - return static_cast(editArrayImpl()); -} - - -template inline -const TYPE& SortedVector::operator[](size_t index) const { - LOG_FATAL_IF(index>=size(), - "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__, - int(index), int(size())); - return *(array() + index); -} - -template inline -const TYPE& SortedVector::itemAt(size_t index) const { - return operator[](index); -} - -template inline -const TYPE& SortedVector::top() const { - return *(array() + size() - 1); -} - -template inline -ssize_t SortedVector::add(const TYPE& item) { - return SortedVectorImpl::add(&item); -} - -template inline -ssize_t SortedVector::indexOf(const TYPE& item) const { - return SortedVectorImpl::indexOf(&item); -} - -template inline -size_t SortedVector::orderOf(const TYPE& item) const { - return SortedVectorImpl::orderOf(&item); -} - -template inline -ssize_t SortedVector::merge(const Vector& vector) { - return SortedVectorImpl::merge(reinterpret_cast(vector)); -} - -template inline -ssize_t SortedVector::merge(const SortedVector& vector) { - return SortedVectorImpl::merge(reinterpret_cast(vector)); -} - -template inline -ssize_t SortedVector::remove(const TYPE& item) { - return SortedVectorImpl::remove(&item); -} - -template inline -ssize_t SortedVector::removeItemsAt(size_t index, size_t count) { - return VectorImpl::removeItemsAt(index, count); -} - -// --------------------------------------------------------------------------- - -template -void SortedVector::do_construct(void* storage, size_t num) const { - construct_type( reinterpret_cast(storage), num ); -} - -template -void SortedVector::do_destroy(void* storage, size_t num) const { - destroy_type( reinterpret_cast(storage), num ); -} - -template -void SortedVector::do_copy(void* dest, const void* from, size_t num) const { - copy_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void SortedVector::do_splat(void* dest, const void* item, size_t num) const { - splat_type( reinterpret_cast(dest), reinterpret_cast(item), num ); -} - -template -void SortedVector::do_move_forward(void* dest, const void* from, size_t num) const { - move_forward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void SortedVector::do_move_backward(void* dest, const void* from, size_t num) const { - move_backward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -int SortedVector::do_compare(const void* lhs, const void* rhs) const { - return compare_type( *reinterpret_cast(lhs), *reinterpret_cast(rhs) ); -} - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_SORTED_VECTOR_H diff --git a/third_party/android_system_core/include/utils/StopWatch.h b/third_party/android_system_core/include/utils/StopWatch.h deleted file mode 100644 index 693dd3ccfc..0000000000 --- a/third_party/android_system_core/include/utils/StopWatch.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2005 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_STOPWATCH_H -#define ANDROID_STOPWATCH_H - -#include -#include - -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class StopWatch -{ -public: - StopWatch( const char *name, - int clock = SYSTEM_TIME_MONOTONIC, - uint32_t flags = 0); - ~StopWatch(); - - const char* name() const; - nsecs_t lap(); - nsecs_t elapsedTime() const; - - void reset(); - -private: - const char* mName; - int mClock; - uint32_t mFlags; - - struct lap_t { - nsecs_t soFar; - nsecs_t thisLap; - }; - - nsecs_t mStartTime; - lap_t mLaps[8]; - int mNumLaps; -}; - - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STOPWATCH_H diff --git a/third_party/android_system_core/include/utils/String16.h b/third_party/android_system_core/include/utils/String16.h deleted file mode 100644 index d131bfc6a7..0000000000 --- a/third_party/android_system_core/include/utils/String16.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2005 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_STRING16_H -#define ANDROID_STRING16_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- - -extern "C" { - -} - -// --------------------------------------------------------------------------- - -namespace android { - -// --------------------------------------------------------------------------- - -class String8; -class TextOutput; - -//! This is a string holding UTF-16 characters. -class String16 -{ -public: - /* use String16(StaticLinkage) if you're statically linking against - * libutils and declaring an empty static String16, e.g.: - * - * static String16 sAStaticEmptyString(String16::kEmptyString); - * static String16 sAnotherStaticEmptyString(sAStaticEmptyString); - */ - enum StaticLinkage { kEmptyString }; - - String16(); - explicit String16(StaticLinkage); - String16(const String16& o); - String16(const String16& o, - size_t len, - size_t begin=0); - explicit String16(const char16_t* o); - explicit String16(const char16_t* o, size_t len); - explicit String16(const String8& o); - explicit String16(const char* o); - explicit String16(const char* o, size_t len); - - ~String16(); - - inline const char16_t* string() const; - inline size_t size() const; - - inline const SharedBuffer* sharedBuffer() const; - - void setTo(const String16& other); - status_t setTo(const char16_t* other); - status_t setTo(const char16_t* other, size_t len); - status_t setTo(const String16& other, - size_t len, - size_t begin=0); - - status_t append(const String16& other); - status_t append(const char16_t* other, size_t len); - - inline String16& operator=(const String16& other); - - inline String16& operator+=(const String16& other); - inline String16 operator+(const String16& other) const; - - status_t insert(size_t pos, const char16_t* chrs); - status_t insert(size_t pos, - const char16_t* chrs, size_t len); - - ssize_t findFirst(char16_t c) const; - ssize_t findLast(char16_t c) const; - - bool startsWith(const String16& prefix) const; - bool startsWith(const char16_t* prefix) const; - - status_t makeLower(); - - status_t replaceAll(char16_t replaceThis, - char16_t withThis); - - status_t remove(size_t len, size_t begin=0); - - inline int compare(const String16& other) const; - - inline bool operator<(const String16& other) const; - inline bool operator<=(const String16& other) const; - inline bool operator==(const String16& other) const; - inline bool operator!=(const String16& other) const; - inline bool operator>=(const String16& other) const; - inline bool operator>(const String16& other) const; - - inline bool operator<(const char16_t* other) const; - inline bool operator<=(const char16_t* other) const; - inline bool operator==(const char16_t* other) const; - inline bool operator!=(const char16_t* other) const; - inline bool operator>=(const char16_t* other) const; - inline bool operator>(const char16_t* other) const; - - inline operator const char16_t*() const; - -private: - const char16_t* mString; -}; - -// String16 can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -ANDROID_TRIVIAL_MOVE_TRAIT(String16) - -// --------------------------------------------------------------------------- -// No user servicable parts below. - -inline int compare_type(const String16& lhs, const String16& rhs) -{ - return lhs.compare(rhs); -} - -inline int strictly_order_type(const String16& lhs, const String16& rhs) -{ - return compare_type(lhs, rhs) < 0; -} - -inline const char16_t* String16::string() const -{ - return mString; -} - -inline size_t String16::size() const -{ - return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1; -} - -inline const SharedBuffer* String16::sharedBuffer() const -{ - return SharedBuffer::bufferFromData(mString); -} - -inline String16& String16::operator=(const String16& other) -{ - setTo(other); - return *this; -} - -inline String16& String16::operator+=(const String16& other) -{ - append(other); - return *this; -} - -inline String16 String16::operator+(const String16& other) const -{ - String16 tmp(*this); - tmp += other; - return tmp; -} - -inline int String16::compare(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()); -} - -inline bool String16::operator<(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) < 0; -} - -inline bool String16::operator<=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) <= 0; -} - -inline bool String16::operator==(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) == 0; -} - -inline bool String16::operator!=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) != 0; -} - -inline bool String16::operator>=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) >= 0; -} - -inline bool String16::operator>(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) > 0; -} - -inline bool String16::operator<(const char16_t* other) const -{ - return strcmp16(mString, other) < 0; -} - -inline bool String16::operator<=(const char16_t* other) const -{ - return strcmp16(mString, other) <= 0; -} - -inline bool String16::operator==(const char16_t* other) const -{ - return strcmp16(mString, other) == 0; -} - -inline bool String16::operator!=(const char16_t* other) const -{ - return strcmp16(mString, other) != 0; -} - -inline bool String16::operator>=(const char16_t* other) const -{ - return strcmp16(mString, other) >= 0; -} - -inline bool String16::operator>(const char16_t* other) const -{ - return strcmp16(mString, other) > 0; -} - -inline String16::operator const char16_t*() const -{ - return mString; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRING16_H diff --git a/third_party/android_system_core/include/utils/String8.h b/third_party/android_system_core/include/utils/String8.h deleted file mode 100644 index ecfcf10be7..0000000000 --- a/third_party/android_system_core/include/utils/String8.h +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (C) 2005 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_STRING8_H -#define ANDROID_STRING8_H - -#include -#include -#include -#include - -#include // for strcmp -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class String16; -class TextOutput; - -//! This is a string holding UTF-8 characters. Does not allow the value more -// than 0x10FFFF, which is not valid unicode codepoint. -class String8 -{ -public: - /* use String8(StaticLinkage) if you're statically linking against - * libutils and declaring an empty static String8, e.g.: - * - * static String8 sAStaticEmptyString(String8::kEmptyString); - * static String8 sAnotherStaticEmptyString(sAStaticEmptyString); - */ - enum StaticLinkage { kEmptyString }; - - String8(); - explicit String8(StaticLinkage); - String8(const String8& o); - explicit String8(const char* o); - explicit String8(const char* o, size_t numChars); - - explicit String8(const String16& o); - explicit String8(const char16_t* o); - explicit String8(const char16_t* o, size_t numChars); - explicit String8(const char32_t* o); - explicit String8(const char32_t* o, size_t numChars); - ~String8(); - - static inline const String8 empty(); - - static String8 format(const char* fmt, ...) __attribute__((format (printf, 1, 2))); - static String8 formatV(const char* fmt, va_list args); - - inline const char* string() const; - inline size_t size() const; - inline size_t length() const; - inline size_t bytes() const; - inline bool isEmpty() const; - - inline const SharedBuffer* sharedBuffer() const; - - void clear(); - - void setTo(const String8& other); - status_t setTo(const char* other); - status_t setTo(const char* other, size_t numChars); - status_t setTo(const char16_t* other, size_t numChars); - status_t setTo(const char32_t* other, - size_t length); - - status_t append(const String8& other); - status_t append(const char* other); - status_t append(const char* other, size_t numChars); - - status_t appendFormat(const char* fmt, ...) - __attribute__((format (printf, 2, 3))); - status_t appendFormatV(const char* fmt, va_list args); - - // Note that this function takes O(N) time to calculate the value. - // No cache value is stored. - size_t getUtf32Length() const; - int32_t getUtf32At(size_t index, - size_t *next_index) const; - void getUtf32(char32_t* dst) const; - - inline String8& operator=(const String8& other); - inline String8& operator=(const char* other); - - inline String8& operator+=(const String8& other); - inline String8 operator+(const String8& other) const; - - inline String8& operator+=(const char* other); - inline String8 operator+(const char* other) const; - - inline int compare(const String8& other) const; - - inline bool operator<(const String8& other) const; - inline bool operator<=(const String8& other) const; - inline bool operator==(const String8& other) const; - inline bool operator!=(const String8& other) const; - inline bool operator>=(const String8& other) const; - inline bool operator>(const String8& other) const; - - inline bool operator<(const char* other) const; - inline bool operator<=(const char* other) const; - inline bool operator==(const char* other) const; - inline bool operator!=(const char* other) const; - inline bool operator>=(const char* other) const; - inline bool operator>(const char* other) const; - - inline operator const char*() const; - - char* lockBuffer(size_t size); - void unlockBuffer(); - status_t unlockBuffer(size_t size); - - // return the index of the first byte of other in this at or after - // start, or -1 if not found - ssize_t find(const char* other, size_t start = 0) const; - - // return true if this string contains the specified substring - inline bool contains(const char* other) const; - - // removes all occurrence of the specified substring - // returns true if any were found and removed - bool removeAll(const char* other); - - void toLower(); - void toLower(size_t start, size_t numChars); - void toUpper(); - void toUpper(size_t start, size_t numChars); - - - /* - * These methods operate on the string as if it were a path name. - */ - - /* - * Set the filename field to a specific value. - * - * Normalizes the filename, removing a trailing '/' if present. - */ - void setPathName(const char* name); - void setPathName(const char* name, size_t numChars); - - /* - * Get just the filename component. - * - * "/tmp/foo/bar.c" --> "bar.c" - */ - String8 getPathLeaf(void) const; - - /* - * Remove the last (file name) component, leaving just the directory - * name. - * - * "/tmp/foo/bar.c" --> "/tmp/foo" - * "/tmp" --> "" // ????? shouldn't this be "/" ???? XXX - * "bar.c" --> "" - */ - String8 getPathDir(void) const; - - /* - * Retrieve the front (root dir) component. Optionally also return the - * remaining components. - * - * "/tmp/foo/bar.c" --> "tmp" (remain = "foo/bar.c") - * "/tmp" --> "tmp" (remain = "") - * "bar.c" --> "bar.c" (remain = "") - */ - String8 walkPath(String8* outRemains = NULL) const; - - /* - * Return the filename extension. This is the last '.' and any number - * of characters that follow it. The '.' is included in case we - * decide to expand our definition of what constitutes an extension. - * - * "/tmp/foo/bar.c" --> ".c" - * "/tmp" --> "" - * "/tmp/foo.bar/baz" --> "" - * "foo.jpeg" --> ".jpeg" - * "foo." --> "" - */ - String8 getPathExtension(void) const; - - /* - * Return the path without the extension. Rules for what constitutes - * an extension are described in the comment for getPathExtension(). - * - * "/tmp/foo/bar.c" --> "/tmp/foo/bar" - */ - String8 getBasePath(void) const; - - /* - * Add a component to the pathname. We guarantee that there is - * exactly one path separator between the old path and the new. - * If there is no existing name, we just copy the new name in. - * - * If leaf is a fully qualified path (i.e. starts with '/', it - * replaces whatever was there before. - */ - String8& appendPath(const char* leaf); - String8& appendPath(const String8& leaf) { return appendPath(leaf.string()); } - - /* - * Like appendPath(), but does not affect this string. Returns a new one instead. - */ - String8 appendPathCopy(const char* leaf) const - { String8 p(*this); p.appendPath(leaf); return p; } - String8 appendPathCopy(const String8& leaf) const { return appendPathCopy(leaf.string()); } - - /* - * Converts all separators in this string to /, the default path separator. - * - * If the default OS separator is backslash, this converts all - * backslashes to slashes, in-place. Otherwise it does nothing. - * Returns self. - */ - String8& convertToResPath(); - -private: - status_t real_append(const char* other, size_t numChars); - char* find_extension(void) const; - - const char* mString; -}; - -// String8 can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -ANDROID_TRIVIAL_MOVE_TRAIT(String8) - -// --------------------------------------------------------------------------- -// No user servicable parts below. - -inline int compare_type(const String8& lhs, const String8& rhs) -{ - return lhs.compare(rhs); -} - -inline int strictly_order_type(const String8& lhs, const String8& rhs) -{ - return compare_type(lhs, rhs) < 0; -} - -inline const String8 String8::empty() { - return String8(); -} - -inline const char* String8::string() const -{ - return mString; -} - -inline size_t String8::length() const -{ - return SharedBuffer::sizeFromData(mString)-1; -} - -inline size_t String8::size() const -{ - return length(); -} - -inline bool String8::isEmpty() const -{ - return length() == 0; -} - -inline size_t String8::bytes() const -{ - return SharedBuffer::sizeFromData(mString)-1; -} - -inline const SharedBuffer* String8::sharedBuffer() const -{ - return SharedBuffer::bufferFromData(mString); -} - -inline bool String8::contains(const char* other) const -{ - return find(other) >= 0; -} - -inline String8& String8::operator=(const String8& other) -{ - setTo(other); - return *this; -} - -inline String8& String8::operator=(const char* other) -{ - setTo(other); - return *this; -} - -inline String8& String8::operator+=(const String8& other) -{ - append(other); - return *this; -} - -inline String8 String8::operator+(const String8& other) const -{ - String8 tmp(*this); - tmp += other; - return tmp; -} - -inline String8& String8::operator+=(const char* other) -{ - append(other); - return *this; -} - -inline String8 String8::operator+(const char* other) const -{ - String8 tmp(*this); - tmp += other; - return tmp; -} - -inline int String8::compare(const String8& other) const -{ - return strcmp(mString, other.mString); -} - -inline bool String8::operator<(const String8& other) const -{ - return strcmp(mString, other.mString) < 0; -} - -inline bool String8::operator<=(const String8& other) const -{ - return strcmp(mString, other.mString) <= 0; -} - -inline bool String8::operator==(const String8& other) const -{ - return strcmp(mString, other.mString) == 0; -} - -inline bool String8::operator!=(const String8& other) const -{ - return strcmp(mString, other.mString) != 0; -} - -inline bool String8::operator>=(const String8& other) const -{ - return strcmp(mString, other.mString) >= 0; -} - -inline bool String8::operator>(const String8& other) const -{ - return strcmp(mString, other.mString) > 0; -} - -inline bool String8::operator<(const char* other) const -{ - return strcmp(mString, other) < 0; -} - -inline bool String8::operator<=(const char* other) const -{ - return strcmp(mString, other) <= 0; -} - -inline bool String8::operator==(const char* other) const -{ - return strcmp(mString, other) == 0; -} - -inline bool String8::operator!=(const char* other) const -{ - return strcmp(mString, other) != 0; -} - -inline bool String8::operator>=(const char* other) const -{ - return strcmp(mString, other) >= 0; -} - -inline bool String8::operator>(const char* other) const -{ - return strcmp(mString, other) > 0; -} - -inline String8::operator const char*() const -{ - return mString; -} - -} // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRING8_H diff --git a/third_party/android_system_core/include/utils/StrongPointer.h b/third_party/android_system_core/include/utils/StrongPointer.h deleted file mode 100644 index aba9577da4..0000000000 --- a/third_party/android_system_core/include/utils/StrongPointer.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2005 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_STRONG_POINTER_H -#define ANDROID_STRONG_POINTER_H - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -template class wp; - -// --------------------------------------------------------------------------- - -#define COMPARE(_op_) \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -inline bool operator _op_ (const T* o) const { \ - return m_ptr _op_ o; \ -} \ -template \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const U* o) const { \ - return m_ptr _op_ o; \ -} \ -inline bool operator _op_ (const wp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const wp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} - -// --------------------------------------------------------------------------- - -template -class sp { -public: - inline sp() : m_ptr(0) { } - - sp(T* other); - sp(const sp& other); - template sp(U* other); - template sp(const sp& other); - - ~sp(); - - // Assignment - - sp& operator = (T* other); - sp& operator = (const sp& other); - - template sp& operator = (const sp& other); - template sp& operator = (U* other); - - //! Special optimization for use by ProcessState (and nobody else). - void force_set(T* other); - - // Reset - - void clear(); - - // Accessors - - inline T& operator* () const { return *m_ptr; } - inline T* operator-> () const { return m_ptr; } - inline T* get() const { return m_ptr; } - - // Operators - - COMPARE(==) - COMPARE(!=) - COMPARE(>) - COMPARE(<) - COMPARE(<=) - COMPARE(>=) - -private: - template friend class sp; - template friend class wp; - void set_pointer(T* ptr); - T* m_ptr; -}; - -#undef COMPARE - -// --------------------------------------------------------------------------- -// No user serviceable parts below here. - -template -sp::sp(T* other) - : m_ptr(other) { - if (other) - other->incStrong(this); -} - -template -sp::sp(const sp& other) - : m_ptr(other.m_ptr) { - if (m_ptr) - m_ptr->incStrong(this); -} - -template template -sp::sp(U* other) - : m_ptr(other) { - if (other) - ((T*) other)->incStrong(this); -} - -template template -sp::sp(const sp& other) - : m_ptr(other.m_ptr) { - if (m_ptr) - m_ptr->incStrong(this); -} - -template -sp::~sp() { - if (m_ptr) - m_ptr->decStrong(this); -} - -template -sp& sp::operator =(const sp& other) { - T* otherPtr(other.m_ptr); - if (otherPtr) - otherPtr->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = otherPtr; - return *this; -} - -template -sp& sp::operator =(T* other) { - if (other) - other->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = other; - return *this; -} - -template template -sp& sp::operator =(const sp& other) { - T* otherPtr(other.m_ptr); - if (otherPtr) - otherPtr->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = otherPtr; - return *this; -} - -template template -sp& sp::operator =(U* other) { - if (other) - ((T*) other)->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = other; - return *this; -} - -template -void sp::force_set(T* other) { - other->forceIncStrong(this); - m_ptr = other; -} - -template -void sp::clear() { - if (m_ptr) { - m_ptr->decStrong(this); - m_ptr = 0; - } -} - -template -void sp::set_pointer(T* ptr) { - m_ptr = ptr; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRONG_POINTER_H diff --git a/third_party/android_system_core/include/utils/SystemClock.h b/third_party/android_system_core/include/utils/SystemClock.h deleted file mode 100644 index 01db340780..0000000000 --- a/third_party/android_system_core/include/utils/SystemClock.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2008 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_UTILS_SYSTEMCLOCK_H -#define ANDROID_UTILS_SYSTEMCLOCK_H - -#include -#include - -namespace android { - -int64_t uptimeMillis(); -int64_t elapsedRealtime(); -int64_t elapsedRealtimeNano(); - -}; // namespace android - -#endif // ANDROID_UTILS_SYSTEMCLOCK_H - diff --git a/third_party/android_system_core/include/utils/Thread.h b/third_party/android_system_core/include/utils/Thread.h deleted file mode 100644 index 28839fdedc..0000000000 --- a/third_party/android_system_core/include/utils/Thread.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_UTILS_THREAD_H -#define _LIBS_UTILS_THREAD_H - -#include -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include -#include -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -class Thread : virtual public RefBase -{ -public: - // Create a Thread object, but doesn't create or start the associated - // thread. See the run() method. - Thread(bool canCallJava = true); - virtual ~Thread(); - - // Start the thread in threadLoop() which needs to be implemented. - virtual status_t run( const char* name = 0, - int32_t priority = PRIORITY_DEFAULT, - size_t stack = 0); - - // Ask this object's thread to exit. This function is asynchronous, when the - // function returns the thread might still be running. Of course, this - // function can be called from a different thread. - virtual void requestExit(); - - // Good place to do one-time initializations - virtual status_t readyToRun(); - - // Call requestExit() and wait until this object's thread exits. - // BE VERY CAREFUL of deadlocks. In particular, it would be silly to call - // this function from this object's thread. Will return WOULD_BLOCK in - // that case. - status_t requestExitAndWait(); - - // Wait until this object's thread exits. Returns immediately if not yet running. - // Do not call from this object's thread; will return WOULD_BLOCK in that case. - status_t join(); - - // Indicates whether this thread is running or not. - bool isRunning() const; - -#ifdef HAVE_ANDROID_OS - // Return the thread's kernel ID, same as the thread itself calling gettid(), - // or -1 if the thread is not running. - pid_t getTid() const; -#endif - -protected: - // exitPending() returns true if requestExit() has been called. - bool exitPending() const; - -private: - // Derived class must implement threadLoop(). The thread starts its life - // here. There are two ways of using the Thread object: - // 1) loop: if threadLoop() returns true, it will be called again if - // requestExit() wasn't called. - // 2) once: if threadLoop() returns false, the thread will exit upon return. - virtual bool threadLoop() = 0; - -private: - Thread& operator=(const Thread&); - static int _threadLoop(void* user); - const bool mCanCallJava; - // always hold mLock when reading or writing - thread_id_t mThread; - mutable Mutex mLock; - Condition mThreadExitedCondition; - status_t mStatus; - // note that all accesses of mExitPending and mRunning need to hold mLock - volatile bool mExitPending; - volatile bool mRunning; - sp mHoldSelf; -#ifdef HAVE_ANDROID_OS - // legacy for debugging, not used by getTid() as it is set by the child thread - // and so is not initialized until the child reaches that point - pid_t mTid; -#endif -}; - - -}; // namespace android - -// --------------------------------------------------------------------------- -#endif // _LIBS_UTILS_THREAD_H -// --------------------------------------------------------------------------- diff --git a/third_party/android_system_core/include/utils/ThreadDefs.h b/third_party/android_system_core/include/utils/ThreadDefs.h deleted file mode 100644 index 9711c13792..0000000000 --- a/third_party/android_system_core/include/utils/ThreadDefs.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_UTILS_THREAD_DEFS_H -#define _LIBS_UTILS_THREAD_DEFS_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* android_thread_id_t; - -typedef int (*android_thread_func_t)(void*); - -#ifdef __cplusplus -} // extern "C" -#endif - -// --------------------------------------------------------------------------- -// C++ API -#ifdef __cplusplus -namespace android { -// --------------------------------------------------------------------------- - -typedef android_thread_id_t thread_id_t; -typedef android_thread_func_t thread_func_t; - -enum { - PRIORITY_LOWEST = ANDROID_PRIORITY_LOWEST, - PRIORITY_BACKGROUND = ANDROID_PRIORITY_BACKGROUND, - PRIORITY_NORMAL = ANDROID_PRIORITY_NORMAL, - PRIORITY_FOREGROUND = ANDROID_PRIORITY_FOREGROUND, - PRIORITY_DISPLAY = ANDROID_PRIORITY_DISPLAY, - PRIORITY_URGENT_DISPLAY = ANDROID_PRIORITY_URGENT_DISPLAY, - PRIORITY_AUDIO = ANDROID_PRIORITY_AUDIO, - PRIORITY_URGENT_AUDIO = ANDROID_PRIORITY_URGENT_AUDIO, - PRIORITY_HIGHEST = ANDROID_PRIORITY_HIGHEST, - PRIORITY_DEFAULT = ANDROID_PRIORITY_DEFAULT, - PRIORITY_MORE_FAVORABLE = ANDROID_PRIORITY_MORE_FAVORABLE, - PRIORITY_LESS_FAVORABLE = ANDROID_PRIORITY_LESS_FAVORABLE, -}; - -// --------------------------------------------------------------------------- -}; // namespace android -#endif // __cplusplus -// --------------------------------------------------------------------------- - - -#endif // _LIBS_UTILS_THREAD_DEFS_H diff --git a/third_party/android_system_core/include/utils/Timers.h b/third_party/android_system_core/include/utils/Timers.h deleted file mode 100644 index 54ec47489f..0000000000 --- a/third_party/android_system_core/include/utils/Timers.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// Timer functions. -// -#ifndef _LIBS_UTILS_TIMERS_H -#define _LIBS_UTILS_TIMERS_H - -#include -#include -#include - -#include - -// ------------------------------------------------------------------ -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int64_t nsecs_t; // nano-seconds - -static CONSTEXPR inline nsecs_t seconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000000000; -} - -static CONSTEXPR inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000000; -} - -static CONSTEXPR inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000; -} - -static CONSTEXPR inline nsecs_t nanoseconds_to_seconds(nsecs_t secs) -{ - return secs/1000000000; -} - -static CONSTEXPR inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs) -{ - return secs/1000000; -} - -static CONSTEXPR inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs) -{ - return secs/1000; -} - -static CONSTEXPR inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);} -static CONSTEXPR inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);} -static CONSTEXPR inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);} -static CONSTEXPR inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);} -static CONSTEXPR inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);} -static CONSTEXPR inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);} - -static CONSTEXPR inline nsecs_t seconds(nsecs_t v) { return s2ns(v); } -static CONSTEXPR inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); } -static CONSTEXPR inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); } - -enum { - SYSTEM_TIME_REALTIME = 0, // system-wide realtime clock - SYSTEM_TIME_MONOTONIC = 1, // monotonic time since unspecified starting point - SYSTEM_TIME_PROCESS = 2, // high-resolution per-process clock - SYSTEM_TIME_THREAD = 3, // high-resolution per-thread clock - SYSTEM_TIME_BOOTTIME = 4 // same as SYSTEM_TIME_MONOTONIC, but including CPU suspend time -}; - -// return the system-time according to the specified clock -#ifdef __cplusplus -nsecs_t systemTime(int clock = SYSTEM_TIME_MONOTONIC); -#else -nsecs_t systemTime(int clock); -#endif // def __cplusplus - -/** - * Returns the number of milliseconds to wait between the reference time and the timeout time. - * If the timeout is in the past relative to the reference time, returns 0. - * If the timeout is more than INT_MAX milliseconds in the future relative to the reference time, - * such as when timeoutTime == LLONG_MAX, returns -1 to indicate an infinite timeout delay. - * Otherwise, returns the difference between the reference time and timeout time - * rounded up to the next millisecond. - */ -int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _LIBS_UTILS_TIMERS_H diff --git a/third_party/android_system_core/include/utils/Tokenizer.h b/third_party/android_system_core/include/utils/Tokenizer.h deleted file mode 100644 index bb25f374cb..0000000000 --- a/third_party/android_system_core/include/utils/Tokenizer.h +++ /dev/null @@ -1,136 +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 _UTILS_TOKENIZER_H -#define _UTILS_TOKENIZER_H - -#include -#include -#include -#include - -namespace android { - -/** - * A simple tokenizer for loading and parsing ASCII text files line by line. - */ -class Tokenizer { - Tokenizer(const String8& filename, FileMap* fileMap, char* buffer, - bool ownBuffer, size_t length); - -public: - ~Tokenizer(); - - /** - * Opens a file and maps it into memory. - * - * Returns NO_ERROR and a tokenizer for the file, if successful. - * Otherwise returns an error and sets outTokenizer to NULL. - */ - static status_t open(const String8& filename, Tokenizer** outTokenizer); - - /** - * Prepares to tokenize the contents of a string. - * - * Returns NO_ERROR and a tokenizer for the string, if successful. - * Otherwise returns an error and sets outTokenizer to NULL. - */ - static status_t fromContents(const String8& filename, - const char* contents, Tokenizer** outTokenizer); - - /** - * Returns true if at the end of the file. - */ - inline bool isEof() const { return mCurrent == getEnd(); } - - /** - * Returns true if at the end of the line or end of the file. - */ - inline bool isEol() const { return isEof() || *mCurrent == '\n'; } - - /** - * Gets the name of the file. - */ - inline String8 getFilename() const { return mFilename; } - - /** - * Gets a 1-based line number index for the current position. - */ - inline int32_t getLineNumber() const { return mLineNumber; } - - /** - * Formats a location string consisting of the filename and current line number. - * Returns a string like "MyFile.txt:33". - */ - String8 getLocation() const; - - /** - * Gets the character at the current position. - * Returns null at end of file. - */ - inline char peekChar() const { return isEof() ? '\0' : *mCurrent; } - - /** - * Gets the remainder of the current line as a string, excluding the newline character. - */ - String8 peekRemainderOfLine() const; - - /** - * Gets the character at the current position and advances past it. - * Returns null at end of file. - */ - inline char nextChar() { return isEof() ? '\0' : *(mCurrent++); } - - /** - * Gets the next token on this line stopping at the specified delimiters - * or the end of the line whichever comes first and advances past it. - * Also stops at embedded nulls. - * Returns the token or an empty string if the current character is a delimiter - * or is at the end of the line. - */ - String8 nextToken(const char* delimiters); - - /** - * Advances to the next line. - * Does nothing if already at the end of the file. - */ - void nextLine(); - - /** - * Skips over the specified delimiters in the line. - * Also skips embedded nulls. - */ - void skipDelimiters(const char* delimiters); - -private: - Tokenizer(const Tokenizer& other); // not copyable - - String8 mFilename; - FileMap* mFileMap; - char* mBuffer; - bool mOwnBuffer; - size_t mLength; - - const char* mCurrent; - int32_t mLineNumber; - - inline const char* getEnd() const { return mBuffer + mLength; } - -}; - -} // namespace android - -#endif // _UTILS_TOKENIZER_H diff --git a/third_party/android_system_core/include/utils/Trace.h b/third_party/android_system_core/include/utils/Trace.h deleted file mode 100644 index 6ee343d79a..0000000000 --- a/third_party/android_system_core/include/utils/Trace.h +++ /dev/null @@ -1,69 +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_TRACE_H -#define ANDROID_TRACE_H - -#ifdef HAVE_ANDROID_OS - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// See for more ATRACE_* macros. - -// ATRACE_NAME traces the beginning and end of the current scope. To trace -// the correct start and end times this macro should be declared first in the -// scope body. -#define ATRACE_NAME(name) android::ScopedTrace ___tracer(ATRACE_TAG, name) -// ATRACE_CALL is an ATRACE_NAME that uses the current function name. -#define ATRACE_CALL() ATRACE_NAME(__FUNCTION__) - -namespace android { - -class ScopedTrace { -public: -inline ScopedTrace(uint64_t tag, const char* name) - : mTag(tag) { - atrace_begin(mTag,name); -} - -inline ~ScopedTrace() { - atrace_end(mTag); -} - -private: - uint64_t mTag; -}; - -}; // namespace android - -#else // HAVE_ANDROID_OS - -#define ATRACE_NAME(...) -#define ATRACE_CALL() - -#endif // HAVE_ANDROID_OS - -#endif // ANDROID_TRACE_H diff --git a/third_party/android_system_core/include/utils/TypeHelpers.h b/third_party/android_system_core/include/utils/TypeHelpers.h deleted file mode 100644 index 13c9081599..0000000000 --- a/third_party/android_system_core/include/utils/TypeHelpers.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) 2005 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_TYPE_HELPERS_H -#define ANDROID_TYPE_HELPERS_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -/* - * Types traits - */ - -template struct trait_trivial_ctor { enum { value = false }; }; -template struct trait_trivial_dtor { enum { value = false }; }; -template struct trait_trivial_copy { enum { value = false }; }; -template struct trait_trivial_move { enum { value = false }; }; -template struct trait_pointer { enum { value = false }; }; -template struct trait_pointer { enum { value = true }; }; - -template -struct traits { - enum { - // whether this type is a pointer - is_pointer = trait_pointer::value, - // whether this type's constructor is a no-op - has_trivial_ctor = is_pointer || trait_trivial_ctor::value, - // whether this type's destructor is a no-op - has_trivial_dtor = is_pointer || trait_trivial_dtor::value, - // whether this type type can be copy-constructed with memcpy - has_trivial_copy = is_pointer || trait_trivial_copy::value, - // whether this type can be moved with memmove - has_trivial_move = is_pointer || trait_trivial_move::value - }; -}; - -template -struct aggregate_traits { - enum { - is_pointer = false, - has_trivial_ctor = - traits::has_trivial_ctor && traits::has_trivial_ctor, - has_trivial_dtor = - traits::has_trivial_dtor && traits::has_trivial_dtor, - has_trivial_copy = - traits::has_trivial_copy && traits::has_trivial_copy, - has_trivial_move = - traits::has_trivial_move && traits::has_trivial_move - }; -}; - -#define ANDROID_TRIVIAL_CTOR_TRAIT( T ) \ - template<> struct trait_trivial_ctor< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_DTOR_TRAIT( T ) \ - template<> struct trait_trivial_dtor< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_COPY_TRAIT( T ) \ - template<> struct trait_trivial_copy< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_MOVE_TRAIT( T ) \ - template<> struct trait_trivial_move< T > { enum { value = true }; }; - -#define ANDROID_BASIC_TYPES_TRAITS( T ) \ - ANDROID_TRIVIAL_CTOR_TRAIT( T ) \ - ANDROID_TRIVIAL_DTOR_TRAIT( T ) \ - ANDROID_TRIVIAL_COPY_TRAIT( T ) \ - ANDROID_TRIVIAL_MOVE_TRAIT( T ) - -// --------------------------------------------------------------------------- - -/* - * basic types traits - */ - -ANDROID_BASIC_TYPES_TRAITS( void ) -ANDROID_BASIC_TYPES_TRAITS( bool ) -ANDROID_BASIC_TYPES_TRAITS( char ) -ANDROID_BASIC_TYPES_TRAITS( unsigned char ) -ANDROID_BASIC_TYPES_TRAITS( short ) -ANDROID_BASIC_TYPES_TRAITS( unsigned short ) -ANDROID_BASIC_TYPES_TRAITS( int ) -ANDROID_BASIC_TYPES_TRAITS( unsigned int ) -ANDROID_BASIC_TYPES_TRAITS( long ) -ANDROID_BASIC_TYPES_TRAITS( unsigned long ) -ANDROID_BASIC_TYPES_TRAITS( long long ) -ANDROID_BASIC_TYPES_TRAITS( unsigned long long ) -ANDROID_BASIC_TYPES_TRAITS( float ) -ANDROID_BASIC_TYPES_TRAITS( double ) - -// --------------------------------------------------------------------------- - - -/* - * compare and order types - */ - -template inline -int strictly_order_type(const TYPE& lhs, const TYPE& rhs) { - return (lhs < rhs) ? 1 : 0; -} - -template inline -int compare_type(const TYPE& lhs, const TYPE& rhs) { - return strictly_order_type(rhs, lhs) - strictly_order_type(lhs, rhs); -} - -/* - * create, destroy, copy and move types... - */ - -template inline -void construct_type(TYPE* p, size_t n) { - if (!traits::has_trivial_ctor) { - while (n--) { - new(p++) TYPE; - } - } -} - -template inline -void destroy_type(TYPE* p, size_t n) { - if (!traits::has_trivial_dtor) { - while (n--) { - p->~TYPE(); - p++; - } - } -} - -template inline -void copy_type(TYPE* d, const TYPE* s, size_t n) { - if (!traits::has_trivial_copy) { - while (n--) { - new(d) TYPE(*s); - d++, s++; - } - } else { - memcpy(d,s,n*sizeof(TYPE)); - } -} - -template inline -void splat_type(TYPE* where, const TYPE* what, size_t n) { - if (!traits::has_trivial_copy) { - while (n--) { - new(where) TYPE(*what); - where++; - } - } else { - while (n--) { - *where++ = *what; - } - } -} - -template inline -void move_forward_type(TYPE* d, const TYPE* s, size_t n = 1) { - if ((traits::has_trivial_dtor && traits::has_trivial_copy) - || traits::has_trivial_move) - { - memmove(d,s,n*sizeof(TYPE)); - } else { - d += n; - s += n; - while (n--) { - --d, --s; - if (!traits::has_trivial_copy) { - new(d) TYPE(*s); - } else { - *d = *s; - } - if (!traits::has_trivial_dtor) { - s->~TYPE(); - } - } - } -} - -template inline -void move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) { - if ((traits::has_trivial_dtor && traits::has_trivial_copy) - || traits::has_trivial_move) - { - memmove(d,s,n*sizeof(TYPE)); - } else { - while (n--) { - if (!traits::has_trivial_copy) { - new(d) TYPE(*s); - } else { - *d = *s; - } - if (!traits::has_trivial_dtor) { - s->~TYPE(); - } - d++, s++; - } - } -} - -// --------------------------------------------------------------------------- - -/* - * a key/value pair - */ - -template -struct key_value_pair_t { - typedef KEY key_t; - typedef VALUE value_t; - - KEY key; - VALUE value; - key_value_pair_t() { } - key_value_pair_t(const key_value_pair_t& o) : key(o.key), value(o.value) { } - key_value_pair_t(const KEY& k, const VALUE& v) : key(k), value(v) { } - key_value_pair_t(const KEY& k) : key(k) { } - inline bool operator < (const key_value_pair_t& o) const { - return strictly_order_type(key, o.key); - } - inline const KEY& getKey() const { - return key; - } - inline const VALUE& getValue() const { - return value; - } -}; - -template -struct trait_trivial_ctor< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_ctor }; }; -template -struct trait_trivial_dtor< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_dtor }; }; -template -struct trait_trivial_copy< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_copy }; }; -template -struct trait_trivial_move< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_move }; }; - -// --------------------------------------------------------------------------- - -/* - * Hash codes. - */ -typedef uint32_t hash_t; - -template -hash_t hash_type(const TKey& key); - -/* Built-in hash code specializations. - * Assumes pointers are 32bit. */ -#define ANDROID_INT32_HASH(T) \ - template <> inline hash_t hash_type(const T& value) { return hash_t(value); } -#define ANDROID_INT64_HASH(T) \ - template <> inline hash_t hash_type(const T& value) { \ - return hash_t((value >> 32) ^ value); } -#define ANDROID_REINTERPRET_HASH(T, R) \ - template <> inline hash_t hash_type(const T& value) { \ - return hash_type(*reinterpret_cast(&value)); } - -ANDROID_INT32_HASH(bool) -ANDROID_INT32_HASH(int8_t) -ANDROID_INT32_HASH(uint8_t) -ANDROID_INT32_HASH(int16_t) -ANDROID_INT32_HASH(uint16_t) -ANDROID_INT32_HASH(int32_t) -ANDROID_INT32_HASH(uint32_t) -ANDROID_INT64_HASH(int64_t) -ANDROID_INT64_HASH(uint64_t) -ANDROID_REINTERPRET_HASH(float, uint32_t) -ANDROID_REINTERPRET_HASH(double, uint64_t) - -template inline hash_t hash_type(T* const & value) { - return hash_type(uintptr_t(value)); -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_TYPE_HELPERS_H diff --git a/third_party/android_system_core/include/utils/Unicode.h b/third_party/android_system_core/include/utils/Unicode.h deleted file mode 100644 index 4e17cc3d9c..0000000000 --- a/third_party/android_system_core/include/utils/Unicode.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2005 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_UNICODE_H -#define ANDROID_UNICODE_H - -#include -#include - -extern "C" { - -// Standard string functions on char16_t strings. -int strcmp16(const char16_t *, const char16_t *); -int strncmp16(const char16_t *s1, const char16_t *s2, size_t n); -size_t strlen16(const char16_t *); -size_t strnlen16(const char16_t *, size_t); -char16_t *strcpy16(char16_t *, const char16_t *); -char16_t *strncpy16(char16_t *, const char16_t *, size_t); - -// Version of comparison that supports embedded nulls. -// This is different than strncmp() because we don't stop -// at a nul character and consider the strings to be different -// if the lengths are different (thus we need to supply the -// lengths of both strings). This can also be used when -// your string is not nul-terminated as it will have the -// equivalent result as strcmp16 (unlike strncmp16). -int strzcmp16(const char16_t *s1, size_t n1, const char16_t *s2, size_t n2); - -// Version of strzcmp16 for comparing strings in different endianness. -int strzcmp16_h_n(const char16_t *s1H, size_t n1, const char16_t *s2N, size_t n2); - -// Standard string functions on char32_t strings. -size_t strlen32(const char32_t *); -size_t strnlen32(const char32_t *, size_t); - -/** - * Measure the length of a UTF-32 string in UTF-8. If the string is invalid - * such as containing a surrogate character, -1 will be returned. - */ -ssize_t utf32_to_utf8_length(const char32_t *src, size_t src_len); - -/** - * Stores a UTF-8 string converted from "src" in "dst", if "dst_length" is not - * large enough to store the string, the part of the "src" string is stored - * into "dst" as much as possible. See the examples for more detail. - * Returns the size actually used for storing the string. - * dst" is not null-terminated when dst_len is fully used (like strncpy). - * - * Example 1 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" >= 7 - * -> - * Returned value == 6 - * "dst" becomes \xE3\x81\x82\xE3\x81\x84\0 - * (note that "dst" is null-terminated) - * - * Example 2 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" == 5 - * -> - * Returned value == 3 - * "dst" becomes \xE3\x81\x82\0 - * (note that "dst" is null-terminated, but \u3044 is not stored in "dst" - * since "dst" does not have enough size to store the character) - * - * Example 3 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" == 6 - * -> - * Returned value == 6 - * "dst" becomes \xE3\x81\x82\xE3\x81\x84 - * (note that "dst" is NOT null-terminated, like strncpy) - */ -void utf32_to_utf8(const char32_t* src, size_t src_len, char* dst, size_t dst_len); - -/** - * Returns the unicode value at "index". - * Returns -1 when the index is invalid (equals to or more than "src_len"). - * If returned value is positive, it is able to be converted to char32_t, which - * is unsigned. Then, if "next_index" is not NULL, the next index to be used is - * stored in "next_index". "next_index" can be NULL. - */ -int32_t utf32_from_utf8_at(const char *src, size_t src_len, size_t index, size_t *next_index); - - -/** - * Returns the UTF-8 length of UTF-16 string "src". - */ -ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len); - -/** - * Converts a UTF-16 string to UTF-8. The destination buffer must be large - * enough to fit the UTF-16 as measured by utf16_to_utf8_length with an added - * NULL terminator. - */ -void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst, size_t dst_len); - -/** - * Returns the length of "src" when "src" is valid UTF-8 string. - * Returns 0 if src is NULL or 0-length string. Returns -1 when the source - * is an invalid string. - * - * This function should be used to determine whether "src" is valid UTF-8 - * characters with valid unicode codepoints. "src" must be null-terminated. - * - * If you are going to use other utf8_to_... functions defined in this header - * with string which may not be valid UTF-8 with valid codepoint (form 0 to - * 0x10FFFF), you should use this function before calling others, since the - * other functions do not check whether the string is valid UTF-8 or not. - * - * If you do not care whether "src" is valid UTF-8 or not, you should use - * strlen() as usual, which should be much faster. - */ -ssize_t utf8_length(const char *src); - -/** - * Measure the length of a UTF-32 string. - */ -size_t utf8_to_utf32_length(const char *src, size_t src_len); - -/** - * Stores a UTF-32 string converted from "src" in "dst". "dst" must be large - * enough to store the entire converted string as measured by - * utf8_to_utf32_length plus space for a NULL terminator. - */ -void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst); - -/** - * Returns the UTF-16 length of UTF-8 string "src". - */ -ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen); - -/** - * Convert UTF-8 to UTF-16 including surrogate pairs. - * Returns a pointer to the end of the string (where a null terminator might go - * if you wanted to add one). - */ -char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst); - -/** - * Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer - * must be large enough to hold the result as measured by utf8_to_utf16_length - * plus an added NULL terminator. - */ -void utf8_to_utf16(const uint8_t* src, size_t srcLen, char16_t* dst); - -/** - * Like utf8_to_utf16_no_null_terminator, but you can supply a maximum length of the - * decoded string. The decoded string will fill up to that length; if it is longer - * the returned pointer will be to the character after dstLen. - */ -char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen); - -} - -#endif diff --git a/third_party/android_system_core/include/utils/Vector.h b/third_party/android_system_core/include/utils/Vector.h deleted file mode 100644 index ed7b725213..0000000000 --- a/third_party/android_system_core/include/utils/Vector.h +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright (C) 2005 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_VECTOR_H -#define ANDROID_VECTOR_H - -#include -#include -#include - -#include - -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class SortedVector; - -/*! - * The main templated vector class ensuring type safety - * while making use of VectorImpl. - * This is the class users want to use. - */ - -template -class Vector : private VectorImpl -{ -public: - typedef TYPE value_type; - - /*! - * Constructors and destructors - */ - - Vector(); - Vector(const Vector& rhs); - explicit Vector(const SortedVector& rhs); - virtual ~Vector(); - - /*! copy operator */ - const Vector& operator = (const Vector& rhs) const; - Vector& operator = (const Vector& rhs); - - const Vector& operator = (const SortedVector& rhs) const; - Vector& operator = (const SortedVector& rhs); - - /* - * empty the vector - */ - - inline void clear() { VectorImpl::clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return VectorImpl::size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return VectorImpl::isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return VectorImpl::capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); } - - /*! - * set the size of the vector. items are appended with the default - * constructor, or removed from the end as needed. - */ - inline ssize_t resize(size_t size) { return VectorImpl::resize(size); } - - /*! - * C-style array access - */ - - //! read-only C-style access - inline const TYPE* array() const; - //! read-write C-style access - TYPE* editArray(); - - /*! - * accessors - */ - - //! read-only access to an item at a given index - inline const TYPE& operator [] (size_t index) const; - //! alternate name for operator [] - inline const TYPE& itemAt(size_t index) const; - //! stack-usage of the vector. returns the top of the stack (last element) - const TYPE& top() const; - - /*! - * modifying the array - */ - - //! copy-on write support, grants write access to an item - TYPE& editItemAt(size_t index); - //! grants right access to the top of the stack (last element) - TYPE& editTop(); - - /*! - * append/insert another vector - */ - - //! insert another vector at a given index - ssize_t insertVectorAt(const Vector& vector, size_t index); - - //! append another vector at the end of this one - ssize_t appendVector(const Vector& vector); - - - //! insert an array at a given index - ssize_t insertArrayAt(const TYPE* array, size_t index, size_t length); - - //! append an array at the end of this vector - ssize_t appendArray(const TYPE* array, size_t length); - - /*! - * add/insert/replace items - */ - - //! insert one or several items initialized with their default constructor - inline ssize_t insertAt(size_t index, size_t numItems = 1); - //! insert one or several items initialized from a prototype item - ssize_t insertAt(const TYPE& prototype_item, size_t index, size_t numItems = 1); - //! pop the top of the stack (removes the last element). No-op if the stack's empty - inline void pop(); - //! pushes an item initialized with its default constructor - inline void push(); - //! pushes an item on the top of the stack - void push(const TYPE& item); - //! same as push() but returns the index the item was added at (or an error) - inline ssize_t add(); - //! same as push() but returns the index the item was added at (or an error) - ssize_t add(const TYPE& item); - //! replace an item with a new one initialized with its default constructor - inline ssize_t replaceAt(size_t index); - //! replace an item with a new one - ssize_t replaceAt(const TYPE& item, size_t index); - - /*! - * remove items - */ - - //! remove several items - inline ssize_t removeItemsAt(size_t index, size_t count = 1); - //! remove one item - inline ssize_t removeAt(size_t index) { return removeItemsAt(index); } - - /*! - * sort (stable) the array - */ - - typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs); - typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state); - - inline status_t sort(compar_t cmp); - inline status_t sort(compar_r_t cmp, void* state); - - // for debugging only - inline size_t getItemSize() const { return itemSize(); } - - - /* - * these inlines add some level of compatibility with STL. eventually - * we should probably turn things around. - */ - typedef TYPE* iterator; - typedef TYPE const* const_iterator; - - inline iterator begin() { return editArray(); } - inline iterator end() { return editArray() + size(); } - inline const_iterator begin() const { return array(); } - inline const_iterator end() const { return array() + size(); } - inline void reserve(size_t n) { setCapacity(n); } - inline bool empty() const{ return isEmpty(); } - inline void push_back(const TYPE& item) { insertAt(item, size(), 1); } - inline void push_front(const TYPE& item) { insertAt(item, 0, 1); } - inline iterator erase(iterator pos) { - ssize_t index = removeItemsAt(pos-array()); - return begin() + index; - } - -protected: - virtual void do_construct(void* storage, size_t num) const; - virtual void do_destroy(void* storage, size_t num) const; - virtual void do_copy(void* dest, const void* from, size_t num) const; - virtual void do_splat(void* dest, const void* item, size_t num) const; - virtual void do_move_forward(void* dest, const void* from, size_t num) const; - virtual void do_move_backward(void* dest, const void* from, size_t num) const; -}; - -// Vector can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -template struct trait_trivial_move > { enum { value = true }; }; - -// --------------------------------------------------------------------------- -// No user serviceable parts from here... -// --------------------------------------------------------------------------- - -template inline -Vector::Vector() - : VectorImpl(sizeof(TYPE), - ((traits::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0) - |(traits::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0) - |(traits::has_trivial_copy ? HAS_TRIVIAL_COPY : 0)) - ) -{ -} - -template inline -Vector::Vector(const Vector& rhs) - : VectorImpl(rhs) { -} - -template inline -Vector::Vector(const SortedVector& rhs) - : VectorImpl(static_cast(rhs)) { -} - -template inline -Vector::~Vector() { - finish_vector(); -} - -template inline -Vector& Vector::operator = (const Vector& rhs) { - VectorImpl::operator = (rhs); - return *this; -} - -template inline -const Vector& Vector::operator = (const Vector& rhs) const { - VectorImpl::operator = (static_cast(rhs)); - return *this; -} - -template inline -Vector& Vector::operator = (const SortedVector& rhs) { - VectorImpl::operator = (static_cast(rhs)); - return *this; -} - -template inline -const Vector& Vector::operator = (const SortedVector& rhs) const { - VectorImpl::operator = (rhs); - return *this; -} - -template inline -const TYPE* Vector::array() const { - return static_cast(arrayImpl()); -} - -template inline -TYPE* Vector::editArray() { - return static_cast(editArrayImpl()); -} - - -template inline -const TYPE& Vector::operator[](size_t index) const { - LOG_FATAL_IF(index>=size(), - "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__, - int(index), int(size())); - return *(array() + index); -} - -template inline -const TYPE& Vector::itemAt(size_t index) const { - return operator[](index); -} - -template inline -const TYPE& Vector::top() const { - return *(array() + size() - 1); -} - -template inline -TYPE& Vector::editItemAt(size_t index) { - return *( static_cast(editItemLocation(index)) ); -} - -template inline -TYPE& Vector::editTop() { - return *( static_cast(editItemLocation(size()-1)) ); -} - -template inline -ssize_t Vector::insertVectorAt(const Vector& vector, size_t index) { - return VectorImpl::insertVectorAt(reinterpret_cast(vector), index); -} - -template inline -ssize_t Vector::appendVector(const Vector& vector) { - return VectorImpl::appendVector(reinterpret_cast(vector)); -} - -template inline -ssize_t Vector::insertArrayAt(const TYPE* array, size_t index, size_t length) { - return VectorImpl::insertArrayAt(array, index, length); -} - -template inline -ssize_t Vector::appendArray(const TYPE* array, size_t length) { - return VectorImpl::appendArray(array, length); -} - -template inline -ssize_t Vector::insertAt(const TYPE& item, size_t index, size_t numItems) { - return VectorImpl::insertAt(&item, index, numItems); -} - -template inline -void Vector::push(const TYPE& item) { - return VectorImpl::push(&item); -} - -template inline -ssize_t Vector::add(const TYPE& item) { - return VectorImpl::add(&item); -} - -template inline -ssize_t Vector::replaceAt(const TYPE& item, size_t index) { - return VectorImpl::replaceAt(&item, index); -} - -template inline -ssize_t Vector::insertAt(size_t index, size_t numItems) { - return VectorImpl::insertAt(index, numItems); -} - -template inline -void Vector::pop() { - VectorImpl::pop(); -} - -template inline -void Vector::push() { - VectorImpl::push(); -} - -template inline -ssize_t Vector::add() { - return VectorImpl::add(); -} - -template inline -ssize_t Vector::replaceAt(size_t index) { - return VectorImpl::replaceAt(index); -} - -template inline -ssize_t Vector::removeItemsAt(size_t index, size_t count) { - return VectorImpl::removeItemsAt(index, count); -} - -template inline -status_t Vector::sort(Vector::compar_t cmp) { - return VectorImpl::sort((VectorImpl::compar_t)cmp); -} - -template inline -status_t Vector::sort(Vector::compar_r_t cmp, void* state) { - return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state); -} - -// --------------------------------------------------------------------------- - -template -void Vector::do_construct(void* storage, size_t num) const { - construct_type( reinterpret_cast(storage), num ); -} - -template -void Vector::do_destroy(void* storage, size_t num) const { - destroy_type( reinterpret_cast(storage), num ); -} - -template -void Vector::do_copy(void* dest, const void* from, size_t num) const { - copy_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void Vector::do_splat(void* dest, const void* item, size_t num) const { - splat_type( reinterpret_cast(dest), reinterpret_cast(item), num ); -} - -template -void Vector::do_move_forward(void* dest, const void* from, size_t num) const { - move_forward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void Vector::do_move_backward(void* dest, const void* from, size_t num) const { - move_backward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_H diff --git a/third_party/android_system_core/include/utils/VectorImpl.h b/third_party/android_system_core/include/utils/VectorImpl.h deleted file mode 100644 index 21ad71ce60..0000000000 --- a/third_party/android_system_core/include/utils/VectorImpl.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2005 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_VECTOR_IMPL_H -#define ANDROID_VECTOR_IMPL_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -// No user serviceable parts in here... -// --------------------------------------------------------------------------- - -namespace android { - -/*! - * Implementation of the guts of the vector<> class - * this ensures backward binary compatibility and - * reduces code size. - * For performance reasons, we expose mStorage and mCount - * so these fields are set in stone. - * - */ - -class VectorImpl -{ -public: - enum { // flags passed to the ctor - HAS_TRIVIAL_CTOR = 0x00000001, - HAS_TRIVIAL_DTOR = 0x00000002, - HAS_TRIVIAL_COPY = 0x00000004, - }; - - VectorImpl(size_t itemSize, uint32_t flags); - VectorImpl(const VectorImpl& rhs); - virtual ~VectorImpl(); - - /*! must be called from subclasses destructor */ - void finish_vector(); - - VectorImpl& operator = (const VectorImpl& rhs); - - /*! C-style array access */ - inline const void* arrayImpl() const { return mStorage; } - void* editArrayImpl(); - - /*! vector stats */ - inline size_t size() const { return mCount; } - inline bool isEmpty() const { return mCount == 0; } - size_t capacity() const; - ssize_t setCapacity(size_t size); - ssize_t resize(size_t size); - - /*! append/insert another vector or array */ - ssize_t insertVectorAt(const VectorImpl& vector, size_t index); - ssize_t appendVector(const VectorImpl& vector); - ssize_t insertArrayAt(const void* array, size_t index, size_t length); - ssize_t appendArray(const void* array, size_t length); - - /*! add/insert/replace items */ - ssize_t insertAt(size_t where, size_t numItems = 1); - ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); - void pop(); - void push(); - void push(const void* item); - ssize_t add(); - ssize_t add(const void* item); - ssize_t replaceAt(size_t index); - ssize_t replaceAt(const void* item, size_t index); - - /*! remove items */ - ssize_t removeItemsAt(size_t index, size_t count = 1); - void clear(); - - const void* itemLocation(size_t index) const; - void* editItemLocation(size_t index); - - typedef int (*compar_t)(const void* lhs, const void* rhs); - typedef int (*compar_r_t)(const void* lhs, const void* rhs, void* state); - status_t sort(compar_t cmp); - status_t sort(compar_r_t cmp, void* state); - -protected: - size_t itemSize() const; - void release_storage(); - - virtual void do_construct(void* storage, size_t num) const = 0; - virtual void do_destroy(void* storage, size_t num) const = 0; - virtual void do_copy(void* dest, const void* from, size_t num) const = 0; - virtual void do_splat(void* dest, const void* item, size_t num) const = 0; - virtual void do_move_forward(void* dest, const void* from, size_t num) const = 0; - virtual void do_move_backward(void* dest, const void* from, size_t num) const = 0; - -private: - void* _grow(size_t where, size_t amount); - void _shrink(size_t where, size_t amount); - - inline void _do_construct(void* storage, size_t num) const; - inline void _do_destroy(void* storage, size_t num) const; - inline void _do_copy(void* dest, const void* from, size_t num) const; - inline void _do_splat(void* dest, const void* item, size_t num) const; - inline void _do_move_forward(void* dest, const void* from, size_t num) const; - inline void _do_move_backward(void* dest, const void* from, size_t num) const; - - // These 2 fields are exposed in the inlines below, - // so they're set in stone. - void * mStorage; // base address of the vector - size_t mCount; // number of items - - const uint32_t mFlags; - const size_t mItemSize; -}; - - - -class SortedVectorImpl : public VectorImpl -{ -public: - SortedVectorImpl(size_t itemSize, uint32_t flags); - SortedVectorImpl(const VectorImpl& rhs); - virtual ~SortedVectorImpl(); - - SortedVectorImpl& operator = (const SortedVectorImpl& rhs); - - //! finds the index of an item - ssize_t indexOf(const void* item) const; - - //! finds where this item should be inserted - size_t orderOf(const void* item) const; - - //! add an item in the right place (or replaces it if there is one) - ssize_t add(const void* item); - - //! merges a vector into this one - ssize_t merge(const VectorImpl& vector); - ssize_t merge(const SortedVectorImpl& vector); - - //! removes an item - ssize_t remove(const void* item); - -protected: - virtual int do_compare(const void* lhs, const void* rhs) const = 0; - -private: - ssize_t _indexOrderOf(const void* item, size_t* order = 0) const; - - // these are made private, because they can't be used on a SortedVector - // (they don't have an implementation either) - ssize_t add(); - void pop(); - void push(); - void push(const void* item); - ssize_t insertVectorAt(const VectorImpl& vector, size_t index); - ssize_t appendVector(const VectorImpl& vector); - ssize_t insertArrayAt(const void* array, size_t index, size_t length); - ssize_t appendArray(const void* array, size_t length); - ssize_t insertAt(size_t where, size_t numItems = 1); - ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); - ssize_t replaceAt(size_t index); - ssize_t replaceAt(const void* item, size_t index); -}; - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_IMPL_H diff --git a/third_party/android_system_core/include/utils/ashmem.h b/third_party/android_system_core/include/utils/ashmem.h deleted file mode 100644 index 0854775780..0000000000 --- a/third_party/android_system_core/include/utils/ashmem.h +++ /dev/null @@ -1,41 +0,0 @@ -/* utils/ashmem.h - ** - ** Copyright 2008 The Android Open Source Project - ** - ** This file is dual licensed. It may be redistributed and/or modified - ** under the terms of the Apache 2.0 License OR version 2 of the GNU - ** General Public License. - */ - -#ifndef _UTILS_ASHMEM_H -#define _UTILS_ASHMEM_H - -#include -#include - -#define ASHMEM_NAME_LEN 256 - -#define ASHMEM_NAME_DEF "dev/ashmem" - -/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ -#define ASHMEM_NOT_REAPED 0 -#define ASHMEM_WAS_REAPED 1 - -/* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ -#define ASHMEM_NOW_UNPINNED 0 -#define ASHMEM_NOW_PINNED 1 - -#define __ASHMEMIOC 0x77 - -#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN]) -#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN]) -#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t) -#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4) -#define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long) -#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6) -#define ASHMEM_PIN _IO(__ASHMEMIOC, 7) -#define ASHMEM_UNPIN _IO(__ASHMEMIOC, 8) -#define ASHMEM_ISPINNED _IO(__ASHMEMIOC, 9) -#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10) - -#endif /* _UTILS_ASHMEM_H */ diff --git a/third_party/android_system_core/include/utils/misc.h b/third_party/android_system_core/include/utils/misc.h deleted file mode 100644 index 6cccec387d..0000000000 --- a/third_party/android_system_core/include/utils/misc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// Handy utility functions and portability code. -// -#ifndef _LIBS_UTILS_MISC_H -#define _LIBS_UTILS_MISC_H - -#include - -/* get #of elements in a static array */ -#ifndef NELEM -# define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) -#endif - -namespace android { - -typedef void (*sysprop_change_callback)(void); -void add_sysprop_change_callback(sysprop_change_callback cb, int priority); -void report_sysprop_change(); - -}; // namespace android - -#endif // _LIBS_UTILS_MISC_H diff --git a/third_party/android_system_core/include/utils/threads.h b/third_party/android_system_core/include/utils/threads.h deleted file mode 100644 index 9de3382118..0000000000 --- a/third_party/android_system_core/include/utils/threads.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007 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 _LIBS_UTILS_THREADS_H -#define _LIBS_UTILS_THREADS_H - -/* - * Please, DO NOT USE! - * - * This file is here only for legacy reasons. Instead, include directly - * the headers you need below. - * - */ - -#include - -#ifdef __cplusplus -#include -#include -#include -#include -#include -#endif - -#endif // _LIBS_UTILS_THREADS_H diff --git a/third_party/libgralloc/include/gralloc_priv.h b/third_party/libgralloc/include/gralloc_priv.h deleted file mode 100644 index 4aa47541b0..0000000000 --- a/third_party/libgralloc/include/gralloc_priv.h +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. - * - * 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 GRALLOC_PRIV_H_ -#define GRALLOC_PRIV_H_ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#define ROUND_UP_PAGESIZE(x) ( (((unsigned long)(x)) + PAGE_SIZE-1) & \ - (~(PAGE_SIZE-1)) ) - -/* Gralloc usage bits indicating the type of allocation that should be used */ -/* SYSTEM heap comes from kernel vmalloc (ION_SYSTEM_HEAP_ID) - * is cached by default and - * is not secured */ - -/* GRALLOC_USAGE_PRIVATE_0 is unused */ - -/* Non linear, Universal Bandwidth Compression */ -#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_1 - -/* IOMMU heap comes from manually allocated pages, can be cached/uncached, - * is not secured */ -#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP GRALLOC_USAGE_PRIVATE_2 - -/* MM heap is a carveout heap for video, can be secured */ -#define GRALLOC_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_3 - -/* ADSP heap is a carveout heap, is not secured */ -#define GRALLOC_USAGE_PRIVATE_ADSP_HEAP 0x01000000 - -/* Set this for allocating uncached memory (using O_DSYNC), - * cannot be used with noncontiguous heaps */ -#define GRALLOC_USAGE_PRIVATE_UNCACHED 0x02000000 - -/* Buffer content should be displayed on an primary display only */ -#define GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY 0x04000000 - -/* Buffer content should be displayed on an external display only */ -#define GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY 0x08000000 - -/* This flag is set for WFD usecase */ -#define GRALLOC_USAGE_PRIVATE_WFD 0x00200000 - -/* CAMERA heap is a carveout heap for camera, is not secured */ -#define GRALLOC_USAGE_PRIVATE_CAMERA_HEAP 0x00400000 - -/* This flag is used for SECURE display usecase */ -#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY 0x00800000 - -/* define Gralloc perform */ -#define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1 -// This will be used by the graphics drivers to know if certain features -// are defined in this display HAL. -// Ex: Newer GFX libraries + Older Display HAL -#define GRALLOC_MODULE_PERFORM_GET_STRIDE 2 -#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3 -#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4 -#define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5 -#define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6 -#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7 -#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8 -#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9 -#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10 -#define GRALLOC_MODULE_PERFORM_GET_IGC 11 -#define GRALLOC_MODULE_PERFORM_SET_IGC 12 -#define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13 - -/* OEM specific HAL formats */ - -#define HAL_PIXEL_FORMAT_RGBA_5551 6 -#define HAL_PIXEL_FORMAT_RGBA_4444 7 -#define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109 -#define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01 -#define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B -#define HAL_PIXEL_FORMAT_R_8 0x10D -#define HAL_PIXEL_FORMAT_RG_88 0x10E -#define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F -#define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110 -#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111 -#define HAL_PIXEL_FORMAT_BGRX_8888 0x112 -#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113 -#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114 -#define HAL_PIXEL_FORMAT_BGR_565 0x115 -#define HAL_PIXEL_FORMAT_INTERLACE 0x180 - -//v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component -#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559 - -//v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed -//format reduces the memory access bandwidth -#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259 - -// UBWC aligned Venus format -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06 - -//Khronos ASTC formats -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD - -/* possible values for inverse gamma correction */ -#define HAL_IGC_NOT_SPECIFIED 0 -#define HAL_IGC_s_RGB 1 - -/* possible formats for 3D content*/ -enum { - HAL_NO_3D = 0x0, - HAL_3D_SIDE_BY_SIDE_L_R = 0x1, - HAL_3D_SIDE_BY_SIDE_R_L = 0x2, - HAL_3D_TOP_BOTTOM = 0x4, - HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, //unused legacy format -}; - -enum { - BUFFER_TYPE_UI = 0, - BUFFER_TYPE_VIDEO -}; - -#ifdef __cplusplus -struct private_handle_t : public native_handle { -#else - struct private_handle_t { - native_handle_t nativeHandle; -#endif - enum { - PRIV_FLAGS_FRAMEBUFFER = 0x00000001, - PRIV_FLAGS_USES_ION = 0x00000008, - PRIV_FLAGS_USES_ASHMEM = 0x00000010, - PRIV_FLAGS_NEEDS_FLUSH = 0x00000020, - PRIV_FLAGS_INTERNAL_ONLY = 0x00000040, - PRIV_FLAGS_NON_CPU_WRITER = 0x00000080, - PRIV_FLAGS_NONCONTIGUOUS_MEM = 0x00000100, - PRIV_FLAGS_CACHED = 0x00000200, - PRIV_FLAGS_SECURE_BUFFER = 0x00000400, - // Display on external only - PRIV_FLAGS_EXTERNAL_ONLY = 0x00002000, - // Set by HWC for protected non secure buffers - PRIV_FLAGS_PROTECTED_BUFFER = 0x00004000, - PRIV_FLAGS_VIDEO_ENCODER = 0x00010000, - PRIV_FLAGS_CAMERA_WRITE = 0x00020000, - PRIV_FLAGS_CAMERA_READ = 0x00040000, - PRIV_FLAGS_HW_COMPOSER = 0x00080000, - PRIV_FLAGS_HW_TEXTURE = 0x00100000, - PRIV_FLAGS_ITU_R_601 = 0x00200000, //Unused from display - PRIV_FLAGS_ITU_R_601_FR = 0x00400000, //Unused from display - PRIV_FLAGS_ITU_R_709 = 0x00800000, //Unused from display - PRIV_FLAGS_SECURE_DISPLAY = 0x01000000, - // Buffer is rendered in Tile Format - PRIV_FLAGS_TILE_RENDERED = 0x02000000, - // Buffer rendered using CPU/SW renderer - PRIV_FLAGS_CPU_RENDERED = 0x04000000, - // Buffer is allocated with UBWC alignment - PRIV_FLAGS_UBWC_ALIGNED = 0x08000000, - // Buffer allocated will be consumed by SF/HWC - PRIV_FLAGS_DISP_CONSUMER = 0x10000000 - }; - - // file-descriptors - int fd; - int fd_metadata; // fd for the meta-data - // ints - int magic; - int flags; - unsigned int size; - unsigned int offset; - int bufferType; - uint64_t base __attribute__((aligned(8))); - unsigned int offset_metadata; - // The gpu address mapped into the mmu. - uint64_t gpuaddr __attribute__((aligned(8))); - int format; - int width; // specifies aligned width - int height; // specifies aligned height - int real_width; - int real_height; - uint64_t base_metadata __attribute__((aligned(8))); - -#ifdef __cplusplus - static const int sNumFds = 2; - static inline int sNumInts() { - return ((sizeof(private_handle_t) - sizeof(native_handle_t)) / - sizeof(int)) - sNumFds; - } - static const int sMagic = 'gmsm'; - - private_handle_t(int fd, unsigned int size, int flags, int bufferType, - int format, int aligned_width, int aligned_height, - int width, int height, int eFd = -1, - unsigned int eOffset = 0, uint64_t eBase = 0) : - fd(fd), fd_metadata(eFd), magic(sMagic), - flags(flags), size(size), offset(0), bufferType(bufferType), - base(0), offset_metadata(eOffset), gpuaddr(0), - format(format), width(aligned_width), height(aligned_height), - real_width(width), real_height(height), base_metadata(eBase) - { - version = (int) sizeof(native_handle); - numInts = sNumInts(); - numFds = sNumFds; - } - ~private_handle_t() { - magic = 0; - } - - static int validate(const native_handle* h) { - const private_handle_t* hnd = (const private_handle_t*)h; - if (!h || h->version != sizeof(native_handle) || - h->numInts != sNumInts() || h->numFds != sNumFds || - hnd->magic != sMagic) - { - ALOGD("Invalid gralloc handle (at %p): " - "ver(%d/%zu) ints(%d/%d) fds(%d/%d)" - "magic(%c%c%c%c/%c%c%c%c)", - h, - h ? h->version : -1, sizeof(native_handle), - h ? h->numInts : -1, sNumInts(), - h ? h->numFds : -1, sNumFds, - hnd ? (((hnd->magic >> 24) & 0xFF)? - ((hnd->magic >> 24) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 16) & 0xFF)? - ((hnd->magic >> 16) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 8) & 0xFF)? - ((hnd->magic >> 8) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 0) & 0xFF)? - ((hnd->magic >> 0) & 0xFF) : '-') : '?', - (sMagic >> 24) & 0xFF, - (sMagic >> 16) & 0xFF, - (sMagic >> 8) & 0xFF, - (sMagic >> 0) & 0xFF); - return -EINVAL; - } - return 0; - } - - static private_handle_t* dynamicCast(const native_handle* in) { - if (validate(in) == 0) { - return (private_handle_t*) in; - } - return NULL; - } -#endif - }; - -#endif /* GRALLOC_PRIV_H_ */ diff --git a/third_party/snpe/aarch64 b/third_party/snpe/aarch64 deleted file mode 120000 index baf4e9cb6e..0000000000 --- a/third_party/snpe/aarch64 +++ /dev/null @@ -1 +0,0 @@ -aarch64-android-clang6.0 \ No newline at end of file diff --git a/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so b/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so deleted file mode 100644 index f4aec21b8e..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:794cbc139e812c01b18d0a6d7635225e1dbc812b55c0f7621b80af19c4ef726c -size 413488 diff --git a/third_party/snpe/aarch64-android-clang6.0/libSNPE.so b/third_party/snpe/aarch64-android-clang6.0/libSNPE.so deleted file mode 100644 index 0f8fe7aa59..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libSNPE.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:794da0eaef843c6c4b42ae1487aaecb8f798f0ca883774d2996f7b26661d726a -size 7669368 diff --git a/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so b/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so deleted file mode 100644 index da77c6b9b4..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4833d0e5488454cbe272c4da279d15edc2518712b6e97870df768a99341d4389 -size 5813576 diff --git a/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so b/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so deleted file mode 100644 index 23bcb036c5..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cbf48c05fd429d280da9947a3e59623bc2918a4522e47335330b3fac8bc4c4e1 -size 1055016 diff --git a/third_party/snpe/aarch64-android-clang6.0/libcalculator.so b/third_party/snpe/aarch64-android-clang6.0/libcalculator.so deleted file mode 100644 index 70ef9abd66..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libcalculator.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2ba78b101e6a068b9308131b2d959cb240409dd3c79d8dd6e7102510a16e6c2d -size 14128 diff --git a/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so b/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so deleted file mode 100644 index 1351f68f1b..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f699873950919cce2a35256dc5d85d664bce9cd3bd5c94aaf639ff5f85ae8f6c -size 14128 diff --git a/third_party/snpe/aarch64-android-clang6.0/libhta.so b/third_party/snpe/aarch64-android-clang6.0/libhta.so deleted file mode 100644 index bfd90065b8..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libhta.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3791200c2ed36a306061547493e79980337fde20439d43877f367e6c040c4af2 -size 3684560 diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so deleted file mode 100644 index 77fb88f761..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4df81ebde99a4f3e715a87b7e984f5354ebebfa58f2ab3da654366716fbd7f8c -size 22408 diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so deleted file mode 100644 index 3281faaa61..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:eb36b274a78ed174f68f882b9d8429b3e291ec4b878ae1a5e964abc2a1c2816f -size 22344 diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so deleted file mode 100644 index aea0ce0d90..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ebf0cb28e9117706fa78c7fdeefa8182b150e4beb0ebcb74b2ef413f6207bb21 -size 22344 diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so deleted file mode 100644 index 87f3aaaa48..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6d723d035e48a08a611e5c613b2a577228cd9eda59c3763766a070fbe84cdd30 -size 22368 diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so deleted file mode 100644 index 39f7f7f4e5..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ee0822e300c33ccf81e67dea63c76b68cf319c5abc66518db225328f9fa908d9 -size 22368 diff --git a/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so b/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so deleted file mode 100644 index 3254b9b919..0000000000 --- a/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:42af709f7e21aae6611142feed95abbc4a8a1bf0791208a1b9648a53c162f8fb -size 563320 diff --git a/tools/ssh/README.md b/tools/ssh/README.md index 5c7f3519b2..66f030de52 100644 --- a/tools/ssh/README.md +++ b/tools/ssh/README.md @@ -7,7 +7,7 @@ In order to SSH into your device, you'll need a GitHub account with SSH keys. Se * Enable SSH in your device's settings * Enter your GitHub username in the device's settings * Connect to your device - * Username: `root` (comma two) or `comma` (comma three) + * Username: `comma` (comma three) * Port: `22` or `8022` Here's an example command for connecting to your device using its tethered connection: