Allow both RENDER and TEXTURE flags when creating native client buffers.
am: 304f78173f
Change-Id: I998b562175698d60f5641ef2f6f2142c7f9e674e
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..cd05b21
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,15 @@
+ndk_headers {
+ name: "libandroid_headers",
+ from: "include/android",
+ to: "android",
+ srcs: ["include/android/**/*.h"],
+ license: "NOTICE",
+}
+
+subdirs = [
+ "cmds/*",
+ "libs/*",
+ "opengl",
+ "services/*",
+ "vulkan",
+]
diff --git a/cmds/atrace/Android.bp b/cmds/atrace/Android.bp
new file mode 100644
index 0000000..69ed416
--- /dev/null
+++ b/cmds/atrace/Android.bp
@@ -0,0 +1,21 @@
+// Copyright 2012 The Android Open Source Project
+
+cc_binary {
+ name: "atrace",
+ srcs: ["atrace.cpp"],
+
+ shared_libs: [
+ "libbinder",
+ "libhwbinder",
+ "android.hidl.manager@1.0",
+ "libhidlbase",
+ "libhidltransport",
+ "liblog",
+ "libcutils",
+ "libutils",
+ "libz",
+ "libbase",
+ ],
+
+ init_rc: ["atrace.rc"],
+}
diff --git a/cmds/atrace/Android.mk b/cmds/atrace/Android.mk
deleted file mode 100644
index a787e95..0000000
--- a/cmds/atrace/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2012 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= atrace.cpp
-
-LOCAL_C_INCLUDES += external/zlib
-
-LOCAL_MODULE:= atrace
-
-LOCAL_MODULE_TAGS:= optional
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libcutils \
- libutils \
- libz \
-
-LOCAL_INIT_RC := atrace.rc
-
-include $(BUILD_EXECUTABLE)
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index 5885738..f4c6be2 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -31,19 +31,25 @@
#include <unistd.h>
#include <zlib.h>
+#include <memory>
+
#include <binder/IBinder.h>
#include <binder/IServiceManager.h>
#include <binder/Parcel.h>
+#include <android/hidl/manager/1.0/IServiceManager.h>
+#include <hidl/ServiceManagement.h>
#include <cutils/properties.h>
#include <utils/String8.h>
#include <utils/Timers.h>
#include <utils/Tokenizer.h>
#include <utils/Trace.h>
+#include <android-base/file.h>
using namespace android;
+using std::string;
#define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
#define MAX_SYS_FILES 10
@@ -503,6 +509,42 @@
return true;
}
+// Poke all the HAL processes in the system to get them to re-read
+// their system properties.
+static void pokeHalServices()
+{
+ using ::android::hidl::manager::V1_0::IServiceManager;
+ using ::android::hardware::hidl_string;
+
+ sp<IServiceManager> sm = ::android::hardware::defaultServiceManager();
+ auto listRet = sm->list([&](const auto &interfaces) {
+ for (size_t i = 0; i < interfaces.size(); i++) {
+ string fqInstanceName = interfaces[i];
+ string::size_type n = fqInstanceName.find("/");
+ if (n == std::string::npos || interfaces[i].size() == n+1)
+ continue;
+ hidl_string fqInterfaceName = fqInstanceName.substr(0, n);
+ hidl_string instanceName = fqInstanceName.substr(n+1, std::string::npos);
+ auto getRet = sm->get(fqInterfaceName, instanceName, [&](const auto &interface) {
+ auto notifyRet = interface->notifySyspropsChanged();
+ if (!notifyRet.isOk()) {
+ fprintf(stderr, "failed to notifySyspropsChanged on service %s: %s\n",
+ fqInstanceName.c_str(),
+ notifyRet.getStatus().toString8().string());
+ }
+ });
+ if (!getRet.isOk()) {
+ fprintf(stderr, "failed to get service %s: %s\n",
+ fqInstanceName.c_str(),
+ getRet.getStatus().toString8().string());
+ }
+ }
+ });
+ if (!listRet.isOk()) {
+ fprintf(stderr, "failed to list services: %s\n", listRet.getStatus().toString8().string());
+ }
+}
+
// Set the trace tags that userland tracing uses, and poke the running
// processes to pick up the new value.
static bool setTagsProperty(uint64_t tags)
@@ -533,11 +575,11 @@
// Set the system property that indicates which apps should perform
// application-level tracing.
-static bool setAppCmdlineProperty(const char* cmdline)
+static bool setAppCmdlineProperty(char* cmdline)
{
char buf[PROPERTY_KEY_MAX];
int i = 0;
- const char* start = cmdline;
+ char* start = cmdline;
while (start != NULL) {
if (i == MAX_PACKAGES) {
fprintf(stderr, "error: only 16 packages could be traced at once\n");
@@ -587,24 +629,14 @@
// kernel.
static bool verifyKernelTraceFuncs(const char* funcs)
{
- int fd = open(k_ftraceFilterPath, O_RDONLY);
- if (fd == -1) {
- fprintf(stderr, "error opening %s: %s (%d)\n", k_ftraceFilterPath,
+ std::string buf;
+ if (!android::base::ReadFileToString(k_ftraceFilterPath, &buf)) {
+ fprintf(stderr, "error opening %s: %s (%d)\n", k_ftraceFilterPath,
strerror(errno), errno);
- return false;
+ return false;
}
- char buf[4097];
- ssize_t n = read(fd, buf, 4096);
- close(fd);
- if (n == -1) {
- fprintf(stderr, "error reading %s: %s (%d)\n", k_ftraceFilterPath,
- strerror(errno), errno);
- return false;
- }
-
- buf[n] = '\0';
- String8 funcList = String8::format("\n%s", buf);
+ String8 funcList = String8::format("\n%s",buf.c_str());
// Make sure that every function listed in funcs is in the list we just
// read from the kernel, except for wildcard inputs.
@@ -624,7 +656,6 @@
func = strtok(NULL, ",");
}
free(myFuncs);
-
return ok;
}
@@ -754,8 +785,9 @@
}
packageList += value;
}
- ok &= setAppCmdlineProperty(packageList.data());
+ ok &= setAppCmdlineProperty(&packageList[0]);
ok &= pokeBinderServices();
+ pokeHalServices();
// Disable all the sysfs enables. This is done as a separate loop from
// the enables to allow the same enable to exist in multiple categories.
@@ -853,30 +885,34 @@
if (g_compress) {
z_stream zs;
- uint8_t *in, *out;
- int result, flush;
-
memset(&zs, 0, sizeof(zs));
- result = deflateInit(&zs, Z_DEFAULT_COMPRESSION);
+
+ int result = deflateInit(&zs, Z_DEFAULT_COMPRESSION);
if (result != Z_OK) {
fprintf(stderr, "error initializing zlib: %d\n", result);
close(traceFD);
return;
}
- const size_t bufSize = 64*1024;
- in = (uint8_t*)malloc(bufSize);
- out = (uint8_t*)malloc(bufSize);
- flush = Z_NO_FLUSH;
+ constexpr size_t bufSize = 64*1024;
+ std::unique_ptr<uint8_t> in(new uint8_t[bufSize]);
+ std::unique_ptr<uint8_t> out(new uint8_t[bufSize]);
+ if (!in || !out) {
+ fprintf(stderr, "couldn't allocate buffers\n");
+ close(traceFD);
+ return;
+ }
- zs.next_out = out;
+ int flush = Z_NO_FLUSH;
+
+ zs.next_out = reinterpret_cast<Bytef*>(out.get());
zs.avail_out = bufSize;
do {
if (zs.avail_in == 0) {
// More input is needed.
- result = read(traceFD, in, bufSize);
+ result = read(traceFD, in.get(), bufSize);
if (result < 0) {
fprintf(stderr, "error reading trace: %s (%d)\n",
strerror(errno), errno);
@@ -885,14 +921,14 @@
} else if (result == 0) {
flush = Z_FINISH;
} else {
- zs.next_in = in;
+ zs.next_in = reinterpret_cast<Bytef*>(in.get());
zs.avail_in = result;
}
}
if (zs.avail_out == 0) {
// Need to write the output.
- result = write(outFd, out, bufSize);
+ result = write(outFd, out.get(), bufSize);
if ((size_t)result < bufSize) {
fprintf(stderr, "error writing deflated trace: %s (%d)\n",
strerror(errno), errno);
@@ -900,7 +936,7 @@
zs.avail_out = bufSize; // skip the final write
break;
}
- zs.next_out = out;
+ zs.next_out = reinterpret_cast<Bytef*>(out.get());
zs.avail_out = bufSize;
}
@@ -912,7 +948,7 @@
if (zs.avail_out < bufSize) {
size_t bytes = bufSize - zs.avail_out;
- result = write(outFd, out, bytes);
+ result = write(outFd, out.get(), bytes);
if ((size_t)result < bytes) {
fprintf(stderr, "error writing deflated trace: %s (%d)\n",
strerror(errno), errno);
@@ -923,9 +959,6 @@
if (result != Z_OK) {
fprintf(stderr, "error cleaning up zlib: %d\n", result);
}
-
- free(in);
- free(out);
} else {
ssize_t sent = 0;
while ((sent = sendfile(outFd, traceFD, NULL, 64*1024*1024)) > 0);
@@ -981,7 +1014,7 @@
" -k fname,... trace the listed kernel functions\n"
" -n ignore signals\n"
" -s N sleep for N seconds before tracing [default 0]\n"
- " -t N trace for N seconds [defualt 5]\n"
+ " -t N trace for N seconds [default 5]\n"
" -z compress the trace dump\n"
" --async_start start circular trace and return immediatly\n"
" --async_dump dump the current contents of circular trace buffer\n"
diff --git a/cmds/bugreport/Android.bp b/cmds/bugreport/Android.bp
new file mode 100644
index 0000000..139e4b2
--- /dev/null
+++ b/cmds/bugreport/Android.bp
@@ -0,0 +1,6 @@
+cc_binary {
+ name: "bugreport",
+ srcs: ["bugreport.cpp"],
+ cflags: ["-Wall"],
+ shared_libs: ["libcutils"],
+}
diff --git a/cmds/bugreport/Android.mk b/cmds/bugreport/Android.mk
deleted file mode 100644
index ced5d30..0000000
--- a/cmds/bugreport/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= bugreport.cpp
-
-LOCAL_MODULE:= bugreport
-
-LOCAL_CFLAGS := -Wall
-
-LOCAL_SHARED_LIBRARIES := libcutils
-
-include $(BUILD_EXECUTABLE)
diff --git a/cmds/dumpstate/Android.bp b/cmds/dumpstate/Android.bp
new file mode 100644
index 0000000..3db41c2
--- /dev/null
+++ b/cmds/dumpstate/Android.bp
@@ -0,0 +1,4 @@
+cc_library_static {
+ name: "libdumpstate.default",
+ srcs: ["libdumpstate_default.cpp"],
+}
diff --git a/cmds/dumpstate/Android.mk b/cmds/dumpstate/Android.mk
index 791a7c4..0433f31 100644
--- a/cmds/dumpstate/Android.mk
+++ b/cmds/dumpstate/Android.mk
@@ -1,8 +1,4 @@
LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := libdumpstate_default.cpp
-LOCAL_MODULE := libdumpstate.default
-include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
@@ -16,7 +12,7 @@
LOCAL_SHARED_LIBRARIES := libcutils liblog libselinux libbase
# ZipArchive support, the order matters here to get all symbols.
-LOCAL_STATIC_LIBRARIES := libziparchive libz libmincrypt
+LOCAL_STATIC_LIBRARIES := libziparchive libz libcrypto_static
LOCAL_HAL_STATIC_LIBRARIES := libdumpstate
LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
LOCAL_INIT_RC := dumpstate.rc
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 6de2eb5..357e73a 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#define LOG_TAG "dumpstate"
#include <dirent.h>
#include <errno.h>
@@ -37,18 +38,16 @@
#include <android-base/file.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
+#include <android-base/unique_fd.h>
#include <cutils/properties.h>
-#include "private/android_filesystem_config.h"
-
-#define LOG_TAG "dumpstate"
-#include <cutils/log.h>
+#include <private/android_filesystem_config.h>
+#include <private/android_logger.h>
#include "dumpstate.h"
-#include "ScopedFd.h"
#include "ziparchive/zip_writer.h"
-#include "mincrypt/sha256.h"
+#include <openssl/sha.h>
using android::base::StringPrintf;
@@ -646,102 +645,14 @@
return 0;
}
-/* Copied policy from system/core/logd/LogBuffer.cpp */
-
-#define LOG_BUFFER_SIZE (256 * 1024)
-#define LOG_BUFFER_MIN_SIZE (64 * 1024UL)
-#define LOG_BUFFER_MAX_SIZE (256 * 1024 * 1024UL)
-
-static bool valid_size(unsigned long value) {
- if ((value < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < value)) {
- return false;
- }
-
- long pages = sysconf(_SC_PHYS_PAGES);
- if (pages < 1) {
- return true;
- }
-
- long pagesize = sysconf(_SC_PAGESIZE);
- if (pagesize <= 1) {
- pagesize = PAGE_SIZE;
- }
-
- // maximum memory impact a somewhat arbitrary ~3%
- pages = (pages + 31) / 32;
- unsigned long maximum = pages * pagesize;
-
- if ((maximum < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < maximum)) {
- return true;
- }
-
- return value <= maximum;
-}
-
-static unsigned long property_get_size(const char *key) {
- unsigned long value;
- char *cp, property[PROPERTY_VALUE_MAX];
-
- property_get(key, property, "");
- value = strtoul(property, &cp, 10);
-
- switch(*cp) {
- case 'm':
- case 'M':
- value *= 1024;
- /* FALLTHRU */
- case 'k':
- case 'K':
- value *= 1024;
- /* FALLTHRU */
- case '\0':
- break;
-
- default:
- value = 0;
- }
-
- if (!valid_size(value)) {
- value = 0;
- }
-
- return value;
-}
-
/* timeout in ms */
static unsigned long logcat_timeout(const char *name) {
- static const char global_tuneable[] = "persist.logd.size"; // Settings App
- static const char global_default[] = "ro.logd.size"; // BoardConfig.mk
- char key[PROP_NAME_MAX];
- unsigned long property_size, default_size;
-
- default_size = property_get_size(global_tuneable);
- if (!default_size) {
- default_size = property_get_size(global_default);
- }
-
- snprintf(key, sizeof(key), "%s.%s", global_tuneable, name);
- property_size = property_get_size(key);
-
- if (!property_size) {
- snprintf(key, sizeof(key), "%s.%s", global_default, name);
- property_size = property_get_size(key);
- }
-
- if (!property_size) {
- property_size = default_size;
- }
-
- if (!property_size) {
- property_size = LOG_BUFFER_SIZE;
- }
-
+ log_id_t id = android_name_to_log_id(name);
+ unsigned long property_size = __android_logger_get_buffer_size(id);
/* Engineering margin is ten-fold our guess */
return 10 * (property_size + worst_write_perf) / worst_write_perf;
}
-/* End copy from system/core/logd/LogBuffer.cpp */
-
/* dumps the current system state to stdout */
static void print_header(std::string version) {
char build[PROPERTY_VALUE_MAX], fingerprint[PROPERTY_VALUE_MAX];
@@ -838,8 +749,9 @@
}
bool add_zip_entry(const std::string& entry_name, const std::string& entry_path) {
- ScopedFd fd(TEMP_FAILURE_RETRY(open(entry_path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC)));
- if (fd.get() == -1) {
+ android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(entry_path.c_str(), O_RDONLY | O_NONBLOCK
+ | O_CLOEXEC)));
+ if (fd == -1) {
MYLOGE("open(%s): %s\n", entry_path.c_str(), strerror(errno));
return false;
}
@@ -917,7 +829,8 @@
dump_files("UPTIME MMC PERF", mmcblk0, skip_not_stat, dump_stat_from_fd);
dump_emmc_ecsd("/d/mmc0/mmc0:0001/ext_csd");
dump_file("MEMORY INFO", "/proc/meminfo");
- run_command("CPU INFO", 10, "top", "-n", "1", "-d", "1", "-m", "30", "-H", NULL);
+ run_command("CPU INFO", 10, "top", "-b", "-n", "1", "-H", "-s", "6",
+ "-o", "pid,tid,user,pr,ni,%cpu,s,virt,res,pcy,cmd,name", NULL);
run_command("PROCRANK", 20, SU_PATH, "root", "procrank", NULL);
dump_file("VIRTUAL MEMORY STATS", "/proc/vmstat");
dump_file("VMALLOC INFO", "/proc/vmallocinfo");
@@ -931,11 +844,12 @@
dump_file("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
dump_file("KERNEL SYNC", "/d/sync");
- run_command("PROCESSES AND THREADS", 10, "ps", "-Z", "-t", "-p", "-P", NULL);
+ run_command("PROCESSES AND THREADS", 10, "ps", "-A", "-T", "-Z",
+ "-O", "pri,nice,rtprio,sched,pcy", NULL);
run_command("LIBRANK", 10, SU_PATH, "root", "librank", NULL);
run_command("PRINTENV", 10, "printenv", NULL);
- run_command("NETSTAT", 10, "netstat", "-n", NULL);
+ run_command("NETSTAT", 10, "netstat", "-nW", NULL);
run_command("LSMOD", 10, "lsmod", NULL);
do_dmesg();
@@ -945,6 +859,9 @@
for_each_tid(show_wchan, "BLOCKED PROCESS WAIT-CHANNELS");
for_each_pid(show_showtime, "PROCESS TIMES (pid cmd user system iowait+percentage)");
+ /* Dump Bluetooth HCI logs */
+ add_dir("/data/misc/bluetooth/logs", true);
+
if (!screenshot_path.empty()) {
MYLOGI("taking late screenshot\n");
take_screenshot(screenshot_path);
@@ -1271,15 +1188,15 @@
}
static std::string SHA256_file_hash(std::string filepath) {
- ScopedFd fd(TEMP_FAILURE_RETRY(open(filepath.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC
- | O_NOFOLLOW)));
- if (fd.get() == -1) {
+ android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(filepath.c_str(), O_RDONLY | O_NONBLOCK
+ | O_CLOEXEC | O_NOFOLLOW)));
+ if (fd == -1) {
MYLOGE("open(%s): %s\n", filepath.c_str(), strerror(errno));
return NULL;
}
SHA256_CTX ctx;
- SHA256_init(&ctx);
+ SHA256_Init(&ctx);
std::vector<uint8_t> buffer(65536);
while (1) {
@@ -1291,13 +1208,14 @@
return NULL;
}
- SHA256_update(&ctx, buffer.data(), bytes_read);
+ SHA256_Update(&ctx, buffer.data(), bytes_read);
}
- uint8_t hash[SHA256_DIGEST_SIZE];
- memcpy(hash, SHA256_final(&ctx), SHA256_DIGEST_SIZE);
- char hash_buffer[SHA256_DIGEST_SIZE * 2 + 1];
- for(size_t i = 0; i < SHA256_DIGEST_SIZE; i++) {
+ uint8_t hash[SHA256_DIGEST_LENGTH];
+ SHA256_Final(hash, &ctx);
+
+ char hash_buffer[SHA256_DIGEST_LENGTH * 2 + 1];
+ for(size_t i = 0; i < SHA256_DIGEST_LENGTH; i++) {
sprintf(hash_buffer + (i * 2), "%02x", hash[i]);
}
hash_buffer[sizeof(hash_buffer) - 1] = 0;
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 514af59..1b28c49 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -221,7 +221,7 @@
*/
class DurationReporter {
public:
- DurationReporter(const char *title);
+ explicit DurationReporter(const char *title);
DurationReporter(const char *title, FILE* out);
~DurationReporter();
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index fd6413d..285c01e 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -28,7 +28,6 @@
#include <sys/capability.h>
#include <sys/inotify.h>
#include <sys/stat.h>
-#include <sys/sysconf.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/klog.h>
@@ -181,7 +180,7 @@
void for_each_pid(for_each_pid_func func, const char *header) {
ON_DRY_RUN_RETURN();
- __for_each_pid(for_each_pid_helper, header, (void *)func);
+ __for_each_pid(for_each_pid_helper, header, (void *) func);
}
static void for_each_tid_helper(int pid, const char *cmdline, void *arg) {
@@ -578,6 +577,7 @@
* stuck.
*/
int dump_file_from_fd(const char *title, const char *path, int fd) {
+ ON_DRY_RUN_RETURN(0);
int flags = fcntl(fd, F_GETFL);
if (flags == -1) {
printf("*** %s: failed to get flags on fd %d: %s\n", path, fd, strerror(errno));
@@ -828,7 +828,7 @@
}
gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW,
- AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC };
+ AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC, AID_BLUETOOTH };
if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
MYLOGE("Unable to setgroups, aborting: %s\n", strerror(errno));
return false;
diff --git a/cmds/dumpsys/Android.bp b/cmds/dumpsys/Android.bp
new file mode 100644
index 0000000..38442e7
--- /dev/null
+++ b/cmds/dumpsys/Android.bp
@@ -0,0 +1,15 @@
+cc_binary {
+ name: "dumpsys",
+
+ srcs: ["dumpsys.cpp"],
+
+ shared_libs: [
+ "libbase",
+ "libutils",
+ "liblog",
+ "libbinder",
+ ],
+
+ cflags: ["-DXP_UNIX"],
+ //shared_libs: ["librt"],
+}
diff --git a/cmds/dumpsys/Android.mk b/cmds/dumpsys/Android.mk
deleted file mode 100644
index 8335c14..0000000
--- a/cmds/dumpsys/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- dumpsys.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- libutils \
- liblog \
- libbinder
-
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
- #LOCAL_SHARED_LIBRARIES += librt
-endif
-
-LOCAL_MODULE:= dumpsys
-
-include $(BUILD_EXECUTABLE)
diff --git a/cmds/dumpsys/dumpsys.cpp b/cmds/dumpsys/dumpsys.cpp
index d19e98a..772d17f 100644
--- a/cmds/dumpsys/dumpsys.cpp
+++ b/cmds/dumpsys/dumpsys.cpp
@@ -203,7 +203,7 @@
// call returns, to terminate our reads if the other end closes their copy of the
// file descriptor, but then hangs for some reason. There doesn't seem to be a good
// way to do this, though.
- remote_end.clear();
+ remote_end.reset();
if (err != 0) {
aerr << "Error dumping service info: (" << strerror(err) << ") " << service_name
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp
index ddf3aa8..5c04f6c 100644
--- a/cmds/flatland/GLHelper.cpp
+++ b/cmds/flatland/GLHelper.cpp
@@ -365,6 +365,7 @@
if (!result) {
fprintf(stderr, "Shader source:\n");
printShaderSource(lines);
+ delete[] src;
return false;
}
delete[] src;
diff --git a/cmds/installd/Android.bp b/cmds/installd/Android.bp
new file mode 100644
index 0000000..93174bf
--- /dev/null
+++ b/cmds/installd/Android.bp
@@ -0,0 +1,73 @@
+cc_defaults {
+ name: "installd_defaults",
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ srcs: [
+ "InstalldNativeService.cpp",
+ "dexopt.cpp",
+ "globals.cpp",
+ "utils.cpp",
+ "binder/android/os/IInstalld.aidl",
+ ],
+ shared_libs: [
+ "libbase",
+ "libbinder",
+ "libcutils",
+ "liblog",
+ "liblogwrap",
+ "libselinux",
+ "libutils",
+ ],
+
+ clang: true,
+}
+
+//
+// Static library used in testing and executable
+//
+
+cc_library_static {
+ name: "libinstalld",
+ defaults: ["installd_defaults"],
+
+ export_include_dirs: ["."],
+ aidl: {
+ export_aidl_headers: true,
+ },
+}
+
+//
+// Executable
+//
+
+cc_binary {
+ name: "installd",
+ defaults: ["installd_defaults"],
+ srcs: ["installd.cpp"],
+
+ static_libs: ["libdiskusage"],
+
+ init_rc: ["installd.rc"],
+}
+
+// OTA chroot tool
+
+cc_binary {
+ name: "otapreopt_chroot",
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ clang: true,
+
+ srcs: ["otapreopt_chroot.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ ],
+}
+
+subdirs = ["tests"]
diff --git a/cmds/installd/Android.mk b/cmds/installd/Android.mk
index 86df596..8bf0b53 100644
--- a/cmds/installd/Android.mk
+++ b/cmds/installd/Android.mk
@@ -1,48 +1,5 @@
LOCAL_PATH := $(call my-dir)
-common_src_files := commands.cpp globals.cpp utils.cpp
-common_cflags := -Wall -Werror
-
-#
-# Static library used in testing and executable
-#
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libinstalld
-LOCAL_MODULE_TAGS := eng tests
-LOCAL_SRC_FILES := $(common_src_files)
-LOCAL_CFLAGS := $(common_cflags)
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- liblogwrap \
- libselinux \
-
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
-LOCAL_CLANG := true
-include $(BUILD_STATIC_LIBRARY)
-
-#
-# Executable
-#
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := installd
-LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS := $(common_cflags)
-LOCAL_SRC_FILES := installd.cpp $(common_src_files)
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- libcutils \
- liblog \
- liblogwrap \
- libselinux \
-
-LOCAL_STATIC_LIBRARIES := libdiskusage
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
-LOCAL_INIT_RC := installd.rc
-LOCAL_CLANG := true
-include $(BUILD_EXECUTABLE)
-
#
# OTA Executable
#
@@ -50,7 +7,7 @@
include $(CLEAR_VARS)
LOCAL_MODULE := otapreopt
LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS := $(common_cflags)
+LOCAL_CFLAGS := -Wall -Werror
# Base & ASLR boundaries for boot image creation.
ifndef LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA
@@ -67,35 +24,21 @@
LOCAL_CFLAGS += -DART_BASE_ADDRESS_MIN_DELTA=$(LOCAL_LIBART_IMG_HOST_MIN_BASE_ADDRESS_DELTA)
LOCAL_CFLAGS += -DART_BASE_ADDRESS_MAX_DELTA=$(LOCAL_LIBART_IMG_HOST_MAX_BASE_ADDRESS_DELTA)
-LOCAL_SRC_FILES := otapreopt.cpp $(common_src_files)
+LOCAL_SRC_FILES := otapreopt.cpp InstalldNativeService.cpp globals.cpp utils.cpp dexopt.cpp binder/android/os/IInstalld.aidl
LOCAL_SHARED_LIBRARIES := \
libbase \
+ libbinder \
libcutils \
liblog \
liblogwrap \
libselinux \
+ libutils \
LOCAL_STATIC_LIBRARIES := libdiskusage
LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
LOCAL_CLANG := true
include $(BUILD_EXECUTABLE)
-# OTA chroot tool
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := otapreopt_chroot
-LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS := $(common_cflags)
-
-LOCAL_SRC_FILES := otapreopt_chroot.cpp
-LOCAL_SHARED_LIBRARIES := \
- libbase \
- liblog \
-
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
-LOCAL_CLANG := true
-include $(BUILD_EXECUTABLE)
-
# OTA slot script
include $(CLEAR_VARS)
@@ -120,7 +63,3 @@
LOCAL_REQUIRED_MODULES := otapreopt otapreopt_chroot otapreopt_slot
include $(BUILD_PREBUILT)
-
-# Tests.
-
-include $(LOCAL_PATH)/tests/Android.mk
\ No newline at end of file
diff --git a/cmds/installd/commands.cpp b/cmds/installd/InstalldNativeService.cpp
similarity index 71%
rename from cmds/installd/commands.cpp
rename to cmds/installd/InstalldNativeService.cpp
index 271c75b..5d01368 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -14,7 +14,7 @@
** limitations under the License.
*/
-#include "commands.h"
+#include "InstalldNativeService.h"
#include <errno.h>
#include <inttypes.h>
@@ -42,10 +42,11 @@
#include <selinux/android.h>
#include <system/thread_defs.h>
-#include <globals.h>
-#include <installd_deps.h>
-#include <otapreopt_utils.h>
-#include <utils.h>
+#include "dexopt.h"
+#include "globals.h"
+#include "installd_deps.h"
+#include "otapreopt_utils.h"
+#include "utils.h"
#ifndef LOG_TAG
#define LOG_TAG "installd"
@@ -76,14 +77,77 @@
static constexpr int FLAG_CLEAR_CODE_CACHE_ONLY = 1 << 9;
/* dexopt needed flags matching those in dalvik.system.DexFile */
-static constexpr int DEXOPT_DEX2OAT_NEEDED = 1;
-static constexpr int DEXOPT_PATCHOAT_NEEDED = 2;
-static constexpr int DEXOPT_SELF_PATCHOAT_NEEDED = 3;
+static constexpr int DEX2OAT_FROM_SCRATCH = 1;
+static constexpr int DEX2OAT_FOR_BOOT_IMAGE = 2;
+static constexpr int DEX2OAT_FOR_FILTER = 3;
+static constexpr int DEX2OAT_FOR_RELOCATION = 4;
+static constexpr int PATCHOAT_FOR_RELOCATION = 5;
#define MIN_RESTRICTED_HOME_SDK_VERSION 24 // > M
typedef int fd_t;
+namespace {
+
+constexpr const char* kDump = "android.permission.DUMP";
+
+binder::Status checkPermission(const char* permission) {
+ pid_t pid;
+ uid_t uid;
+
+ if (checkCallingPermission(String16(permission), reinterpret_cast<int32_t*>(&pid),
+ reinterpret_cast<int32_t*>(&uid))) {
+ return binder::Status::ok();
+ } else {
+ auto err = StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, permission);
+ return binder::Status::fromExceptionCode(binder::Status::EX_SECURITY, String8(err.c_str()));
+ }
+}
+
+binder::Status checkUid(uid_t expectedUid) {
+ uid_t uid = IPCThreadState::self()->getCallingUid();
+ if (uid == expectedUid || uid == AID_ROOT) {
+ return binder::Status::ok();
+ } else {
+ auto err = StringPrintf("UID %d is not expected UID %d", uid, expectedUid);
+ return binder::Status::fromExceptionCode(binder::Status::EX_SECURITY, String8(err.c_str()));
+ }
+}
+
+#define ENFORCE_UID(uid) { \
+ binder::Status status = checkUid((uid)); \
+ if (!status.isOk()) { \
+ return status; \
+ } \
+}
+
+} // namespace
+
+status_t InstalldNativeService::start() {
+ IPCThreadState::self()->disableBackgroundScheduling(true);
+ status_t ret = BinderService<InstalldNativeService>::publish();
+ if (ret != android::OK) {
+ return ret;
+ }
+ sp<ProcessState> ps(ProcessState::self());
+ ps->startThreadPool();
+ ps->giveThreadPoolName();
+ return android::OK;
+}
+
+status_t InstalldNativeService::dump(int fd, const Vector<String16> & /* args */) {
+ const binder::Status dump_permission = checkPermission(kDump);
+ if (!dump_permission.isOk()) {
+ const String8 msg(dump_permission.toString8());
+ write(fd, msg.string(), msg.size());
+ return PERMISSION_DENIED;
+ }
+
+ std::string msg = "installd is happy\n";
+ write(fd, msg.c_str(), strlen(msg.c_str()));
+ return NO_ERROR;
+}
+
static bool property_get_bool(const char* property_name, bool default_value = false) {
char tmp_property_value[kPropertyValueMax];
bool have_property = get_property(property_name, tmp_property_value, nullptr) > 0;
@@ -104,7 +168,7 @@
* if the label of that top-level file actually changed. This can save us
* significant time by avoiding no-op traversals of large filesystem trees.
*/
-static int restorecon_app_data_lazy(const std::string& path, const char* seinfo, uid_t uid) {
+static int restorecon_app_data_lazy(const std::string& path, const std::string& seInfo, uid_t uid) {
int res = 0;
char* before = nullptr;
char* after = nullptr;
@@ -116,7 +180,7 @@
PLOG(ERROR) << "Failed before getfilecon for " << path;
goto fail;
}
- if (selinux_android_restorecon_pkgdir(path.c_str(), seinfo, uid, 0) < 0) {
+ if (selinux_android_restorecon_pkgdir(path.c_str(), seInfo.c_str(), uid, 0) < 0) {
PLOG(ERROR) << "Failed top-level restorecon for " << path;
goto fail;
}
@@ -130,7 +194,7 @@
if (strcmp(before, after)) {
LOG(DEBUG) << "Detected label change from " << before << " to " << after << " at " << path
<< "; running recursive restorecon";
- if (selinux_android_restorecon_pkgdir(path.c_str(), seinfo, uid,
+ if (selinux_android_restorecon_pkgdir(path.c_str(), seInfo.c_str(), uid,
SELINUX_ANDROID_RESTORECON_RECURSE) < 0) {
PLOG(ERROR) << "Failed recursive restorecon for " << path;
goto fail;
@@ -146,9 +210,9 @@
return res;
}
-static int restorecon_app_data_lazy(const std::string& parent, const char* name, const char* seinfo,
- uid_t uid) {
- return restorecon_app_data_lazy(StringPrintf("%s/%s", parent.c_str(), name), seinfo, uid);
+static int restorecon_app_data_lazy(const std::string& parent, const char* name,
+ const std::string& seInfo, uid_t uid) {
+ return restorecon_app_data_lazy(StringPrintf("%s/%s", parent.c_str(), name), seInfo, uid);
}
static int prepare_app_dir(const std::string& path, mode_t target_mode, uid_t uid) {
@@ -164,56 +228,62 @@
return prepare_app_dir(StringPrintf("%s/%s", parent.c_str(), name), target_mode, uid);
}
-int create_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags,
- appid_t appid, const char* seinfo, int target_sdk_version) {
- uid_t uid = multiuser_get_uid(userid, appid);
- mode_t target_mode = target_sdk_version >= MIN_RESTRICTED_HOME_SDK_VERSION ? 0700 : 0751;
+binder::Status InstalldNativeService::createAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
+ const std::string& seInfo, int32_t targetSdkVersion) {
+ ENFORCE_UID(AID_SYSTEM);
+
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ const char* pkgname = packageName.c_str();
+
+ uid_t uid = multiuser_get_uid(userId, appId);
+ mode_t target_mode = targetSdkVersion >= MIN_RESTRICTED_HOME_SDK_VERSION ? 0700 : 0751;
if (flags & FLAG_STORAGE_CE) {
- auto path = create_data_user_ce_package_path(uuid, userid, pkgname);
+ auto path = create_data_user_ce_package_path(uuid_, userId, pkgname);
if (prepare_app_dir(path, target_mode, uid) ||
prepare_app_dir(path, "cache", 0771, uid) ||
prepare_app_dir(path, "code_cache", 0771, uid)) {
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
// Consider restorecon over contents if label changed
- if (restorecon_app_data_lazy(path, seinfo, uid) ||
- restorecon_app_data_lazy(path, "cache", seinfo, uid) ||
- restorecon_app_data_lazy(path, "code_cache", seinfo, uid)) {
- return -1;
+ if (restorecon_app_data_lazy(path, seInfo, uid) ||
+ restorecon_app_data_lazy(path, "cache", seInfo, uid) ||
+ restorecon_app_data_lazy(path, "code_cache", seInfo, uid)) {
+ return binder::Status::fromServiceSpecificError(-1);
}
// Remember inode numbers of cache directories so that we can clear
// contents while CE storage is locked
if (write_path_inode(path, "cache", kXattrInodeCache) ||
write_path_inode(path, "code_cache", kXattrInodeCodeCache)) {
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
}
if (flags & FLAG_STORAGE_DE) {
- auto path = create_data_user_de_package_path(uuid, userid, pkgname);
+ auto path = create_data_user_de_package_path(uuid_, userId, pkgname);
if (prepare_app_dir(path, target_mode, uid)) {
// TODO: include result once 25796509 is fixed
- return 0;
+ return binder::Status::ok();
}
// Consider restorecon over contents if label changed
- if (restorecon_app_data_lazy(path, seinfo, uid)) {
- return -1;
+ if (restorecon_app_data_lazy(path, seInfo, uid)) {
+ return binder::Status::fromServiceSpecificError(-1);
}
if (property_get_bool("dalvik.vm.usejitprofiles")) {
- const std::string profile_path = create_data_user_profile_package_path(userid, pkgname);
+ const std::string profile_path = create_data_user_profile_package_path(userId, pkgname);
// read-write-execute only for the app user.
if (fs_prepare_dir_strict(profile_path.c_str(), 0700, uid, uid) != 0) {
PLOG(ERROR) << "Failed to prepare " << profile_path;
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
std::string profile_file = create_primary_profile(profile_path);
// read-write only for the app user.
if (fs_prepare_file_strict(profile_file.c_str(), 0600, uid, uid) != 0) {
PLOG(ERROR) << "Failed to prepare " << profile_path;
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
const std::string ref_profile_path = create_data_ref_profile_package_path(pkgname);
// dex2oat/profman runs under the shared app gid and it needs to read/write reference
@@ -222,28 +292,33 @@
if (fs_prepare_dir_strict(
ref_profile_path.c_str(), 0700, shared_app_gid, shared_app_gid) != 0) {
PLOG(ERROR) << "Failed to prepare " << ref_profile_path;
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
}
}
- return 0;
+ return binder::Status::ok();
}
-int migrate_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) {
+binder::Status InstalldNativeService::migrateAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ const char* pkgname = packageName.c_str();
+
// This method only exists to upgrade system apps that have requested
// forceDeviceEncrypted, so their default storage always lives in a
// consistent location. This only works on non-FBE devices, since we
// never want to risk exposing data on a device with real CE/DE storage.
- auto ce_path = create_data_user_ce_package_path(uuid, userid, pkgname);
- auto de_path = create_data_user_de_package_path(uuid, userid, pkgname);
+ auto ce_path = create_data_user_ce_package_path(uuid_, userId, pkgname);
+ auto de_path = create_data_user_de_package_path(uuid_, userId, pkgname);
// If neither directory is marked as default, assume CE is default
if (getxattr(ce_path.c_str(), kXattrDefault, nullptr, 0) == -1
&& getxattr(de_path.c_str(), kXattrDefault, nullptr, 0) == -1) {
if (setxattr(ce_path.c_str(), kXattrDefault, nullptr, 0, 0) != 0) {
PLOG(ERROR) << "Failed to mark default storage " << ce_path;
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
}
@@ -256,15 +331,15 @@
<< " is not active; migrating from " << source;
if (delete_dir_contents_and_dir(target) != 0) {
PLOG(ERROR) << "Failed to delete";
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
if (rename(source.c_str(), target.c_str()) != 0) {
PLOG(ERROR) << "Failed to rename";
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
}
- return 0;
+ return binder::Status::ok();
}
static bool clear_profile(const std::string& profile) {
@@ -332,18 +407,24 @@
return success;
}
-int clear_app_profiles(const char* pkgname) {
+binder::Status InstalldNativeService::clearAppProfiles(const std::string& packageName) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* pkgname = packageName.c_str();
bool success = true;
success &= clear_reference_profile(pkgname);
success &= clear_current_profiles(pkgname);
- return success ? 0 : -1;
+ return success ? binder::Status::ok() : binder::Status::fromServiceSpecificError(-1);
}
-int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags,
- ino_t ce_data_inode) {
+binder::Status InstalldNativeService::clearAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ const char* pkgname = packageName.c_str();
+
int res = 0;
if (flags & FLAG_STORAGE_CE) {
- auto path = create_data_user_ce_package_path(uuid, userid, pkgname, ce_data_inode);
+ auto path = create_data_user_ce_package_path(uuid_, userId, pkgname, ceDataInode);
if (flags & FLAG_CLEAR_CACHE_ONLY) {
path = read_path_inode(path, "cache", kXattrInodeCache);
} else if (flags & FLAG_CLEAR_CODE_CACHE_ONLY) {
@@ -364,18 +445,18 @@
only_cache = true;
}
- auto path = create_data_user_de_package_path(uuid, userid, pkgname) + suffix;
+ auto path = create_data_user_de_package_path(uuid_, userId, pkgname) + suffix;
if (access(path.c_str(), F_OK) == 0) {
// TODO: include result once 25796509 is fixed
delete_dir_contents(path);
}
if (!only_cache) {
- if (!clear_current_profile(pkgname, userid)) {
+ if (!clear_current_profile(pkgname, userId)) {
res |= -1;
}
}
}
- return res;
+ return res ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
}
static int destroy_app_reference_profile(const char *pkgname) {
@@ -390,37 +471,51 @@
/*ignore_if_missing*/ true);
}
-int destroy_app_profiles(const char *pkgname) {
+binder::Status InstalldNativeService::destroyAppProfiles(const std::string& packageName) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* pkgname = packageName.c_str();
int result = 0;
std::vector<userid_t> users = get_known_users(/*volume_uuid*/ nullptr);
for (auto user : users) {
result |= destroy_app_current_profiles(pkgname, user);
}
result |= destroy_app_reference_profile(pkgname);
- return result;
+ return result ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
}
-int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags,
- ino_t ce_data_inode) {
+binder::Status InstalldNativeService::destroyAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ const char* pkgname = packageName.c_str();
+
int res = 0;
if (flags & FLAG_STORAGE_CE) {
res |= delete_dir_contents_and_dir(
- create_data_user_ce_package_path(uuid, userid, pkgname, ce_data_inode));
+ create_data_user_ce_package_path(uuid_, userId, pkgname, ceDataInode));
}
if (flags & FLAG_STORAGE_DE) {
res |= delete_dir_contents_and_dir(
- create_data_user_de_package_path(uuid, userid, pkgname));
- destroy_app_current_profiles(pkgname, userid);
+ create_data_user_de_package_path(uuid_, userId, pkgname));
+ destroy_app_current_profiles(pkgname, userId);
// TODO(calin): If the package is still installed by other users it's probably
// beneficial to keep the reference profile around.
// Verify if it's ok to do that.
destroy_app_reference_profile(pkgname);
}
- return res;
+ return res ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
}
-int move_complete_app(const char *from_uuid, const char *to_uuid, const char *package_name,
- const char *data_app_name, appid_t appid, const char* seinfo, int target_sdk_version) {
+binder::Status InstalldNativeService::moveCompleteApp(const std::unique_ptr<std::string>& fromUuid,
+ const std::unique_ptr<std::string>& toUuid, const std::string& packageName,
+ const std::string& dataAppName, int32_t appId, const std::string& seInfo,
+ int32_t targetSdkVersion) {
+
+ const char* from_uuid = fromUuid ? fromUuid->c_str() : nullptr;
+ const char* to_uuid = toUuid ? toUuid->c_str() : nullptr;
+ const char* package_name = packageName.c_str();
+ const char* data_app_name = dataAppName.c_str();
+
std::vector<userid_t> users = get_known_users(from_uuid);
// Copy app
@@ -465,8 +560,8 @@
continue;
}
- if (create_app_data(to_uuid, package_name, user, FLAG_STORAGE_CE | FLAG_STORAGE_DE,
- appid, seinfo, target_sdk_version) != 0) {
+ if (!createAppData(toUuid, packageName, user, FLAG_STORAGE_CE | FLAG_STORAGE_DE, appId,
+ seInfo, targetSdkVersion).isOk()) {
LOG(ERROR) << "Failed to create package target on " << to_uuid;
goto fail;
}
@@ -509,8 +604,8 @@
}
}
- if (restorecon_app_data(to_uuid, package_name, user, FLAG_STORAGE_CE | FLAG_STORAGE_DE,
- appid, seinfo) != 0) {
+ if (!restoreconAppData(toUuid, packageName, user, FLAG_STORAGE_CE | FLAG_STORAGE_DE,
+ appId, seInfo).isOk()) {
LOG(ERROR) << "Failed to restorecon";
goto fail;
}
@@ -519,7 +614,7 @@
// We let the framework scan the new location and persist that before
// deleting the data in the old location; this ordering ensures that
// we can recover from things like battery pulls.
- return 0;
+ return binder::Status::ok();
fail:
// Nuke everything we might have already copied
@@ -543,33 +638,39 @@
}
}
}
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
-int create_user_data(const char *uuid, userid_t userid, int user_serial ATTRIBUTE_UNUSED,
- int flags) {
- if (flags & FLAG_STORAGE_DE) {
- if (uuid == nullptr) {
- return ensure_config_user_dirs(userid);
- }
- }
- return 0;
-}
-
-int destroy_user_data(const char *uuid, userid_t userid, int flags) {
+binder::Status InstalldNativeService::createUserData(const std::unique_ptr<std::string>& uuid,
+ int32_t userId, int32_t userSerial ATTRIBUTE_UNUSED, int32_t flags) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
int res = 0;
if (flags & FLAG_STORAGE_DE) {
- res |= delete_dir_contents_and_dir(create_data_user_de_path(uuid, userid), true);
- if (uuid == nullptr) {
- res |= delete_dir_contents_and_dir(create_data_misc_legacy_path(userid), true);
- res |= delete_dir_contents_and_dir(create_data_user_profiles_path(userid), true);
+ if (uuid_ == nullptr) {
+ res = ensure_config_user_dirs(userId);
+ }
+ }
+ return res ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
+}
+
+binder::Status InstalldNativeService::destroyUserData(const std::unique_ptr<std::string>& uuid,
+ int32_t userId, int32_t flags) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ int res = 0;
+ if (flags & FLAG_STORAGE_DE) {
+ res |= delete_dir_contents_and_dir(create_data_user_de_path(uuid_, userId), true);
+ if (uuid_ == nullptr) {
+ res |= delete_dir_contents_and_dir(create_data_misc_legacy_path(userId), true);
+ res |= delete_dir_contents_and_dir(create_data_user_profiles_path(userId), true);
}
}
if (flags & FLAG_STORAGE_CE) {
- res |= delete_dir_contents_and_dir(create_data_user_ce_path(uuid, userid), true);
- res |= delete_dir_contents_and_dir(create_data_media_path(uuid, userid), true);
+ res |= delete_dir_contents_and_dir(create_data_user_ce_path(uuid_, userId), true);
+ res |= delete_dir_contents_and_dir(create_data_media_path(uuid_, userId), true);
}
- return res;
+ return res ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
}
/* Try to ensure free_size bytes of storage are available.
@@ -579,53 +680,70 @@
* also require that apps constantly modify file metadata even
* when just reading from the cache, which is pretty awful.
*/
-int free_cache(const char *uuid, int64_t free_size) {
+binder::Status InstalldNativeService::freeCache(const std::unique_ptr<std::string>& uuid,
+ int64_t freeStorageSize) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
cache_t* cache;
int64_t avail;
- auto data_path = create_data_path(uuid);
+ auto data_path = create_data_path(uuid_);
avail = data_disk_free(data_path);
- if (avail < 0) return -1;
+ if (avail < 0) {
+ return binder::Status::fromServiceSpecificError(-1);
+ }
- ALOGI("free_cache(%" PRId64 ") avail %" PRId64 "\n", free_size, avail);
- if (avail >= free_size) return 0;
+ ALOGI("free_cache(%" PRId64 ") avail %" PRId64 "\n", freeStorageSize, avail);
+ if (avail >= freeStorageSize) {
+ return binder::Status::ok();
+ }
cache = start_cache_collection();
- auto users = get_known_users(uuid);
+ auto users = get_known_users(uuid_);
for (auto user : users) {
- add_cache_files(cache, create_data_user_ce_path(uuid, user));
- add_cache_files(cache, create_data_user_de_path(uuid, user));
+ add_cache_files(cache, create_data_user_ce_path(uuid_, user));
+ add_cache_files(cache, create_data_user_de_path(uuid_, user));
add_cache_files(cache,
- StringPrintf("%s/Android/data", create_data_media_path(uuid, user).c_str()));
+ StringPrintf("%s/Android/data", create_data_media_path(uuid_, user).c_str()));
}
- clear_cache_files(data_path, cache, free_size);
+ clear_cache_files(data_path, cache, freeStorageSize);
finish_cache_collection(cache);
- return data_disk_free(data_path) >= free_size ? 0 : -1;
+ if (data_disk_free(data_path) >= freeStorageSize) {
+ return binder::Status::ok();
+ } else {
+ return binder::Status::fromServiceSpecificError(-1);
+ }
}
-int rm_dex(const char *path, const char *instruction_set)
-{
+binder::Status InstalldNativeService::rmdex(const std::string& codePath,
+ const std::string& instructionSet) {
+ ENFORCE_UID(AID_SYSTEM);
char dex_path[PKG_PATH_MAX];
+ const char* path = codePath.c_str();
+ const char* instruction_set = instructionSet.c_str();
+
if (validate_apk_path(path) && validate_system_app_path(path)) {
ALOGE("invalid apk path '%s' (bad prefix)\n", path);
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
- if (!create_cache_path(dex_path, path, instruction_set)) return -1;
+ if (!create_cache_path(dex_path, path, instruction_set)) {
+ return binder::Status::fromServiceSpecificError(-1);
+ }
ALOGV("unlink %s\n", dex_path);
if (unlink(dex_path) < 0) {
if (errno != ENOENT) {
ALOGE("Couldn't unlink %s: %s\n", dex_path, strerror(errno));
}
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
} else {
- return 0;
+ return binder::Status::ok();
}
}
@@ -679,39 +797,58 @@
closedir(d);
}
-int get_app_size(const char *uuid, const char *pkgname, int userid, int flags, ino_t ce_data_inode,
- const char *code_path, int64_t *codesize, int64_t *datasize, int64_t *cachesize,
- int64_t* asecsize) {
+binder::Status InstalldNativeService::getAppSize(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode,
+ const std::string& codePath, std::vector<int64_t>* _aidl_return) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ const char* pkgname = packageName.c_str();
+ const char* code_path = codePath.c_str();
+
DIR *d;
int dfd;
+ int64_t codesize = 0;
+ int64_t datasize = 0;
+ int64_t cachesize = 0;
+ int64_t asecsize = 0;
d = opendir(code_path);
if (d != nullptr) {
dfd = dirfd(d);
- *codesize += calculate_dir_size(dfd);
+ codesize += calculate_dir_size(dfd);
closedir(d);
}
if (flags & FLAG_STORAGE_CE) {
- auto path = create_data_user_ce_package_path(uuid, userid, pkgname, ce_data_inode);
- add_app_data_size(path, codesize, datasize, cachesize);
+ auto path = create_data_user_ce_package_path(uuid_, userId, pkgname, ceDataInode);
+ add_app_data_size(path, &codesize, &datasize, &cachesize);
}
if (flags & FLAG_STORAGE_DE) {
- auto path = create_data_user_de_package_path(uuid, userid, pkgname);
- add_app_data_size(path, codesize, datasize, cachesize);
+ auto path = create_data_user_de_package_path(uuid_, userId, pkgname);
+ add_app_data_size(path, &codesize, &datasize, &cachesize);
}
- *asecsize = 0;
-
- return 0;
+ std::vector<int64_t> res;
+ res.push_back(codesize);
+ res.push_back(datasize);
+ res.push_back(cachesize);
+ res.push_back(asecsize);
+ *_aidl_return = res;
+ return binder::Status::ok();
}
-int get_app_data_inode(const char *uuid, const char *pkgname, int userid, int flags, ino_t *inode) {
+binder::Status InstalldNativeService::getAppDataInode(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int64_t* _aidl_return) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ const char* pkgname = packageName.c_str();
+
+ int res = 0;
if (flags & FLAG_STORAGE_CE) {
- auto path = create_data_user_ce_package_path(uuid, userid, pkgname);
- return get_path_inode(path, inode);
+ auto path = create_data_user_ce_package_path(uuid_, userId, pkgname);
+ res = get_path_inode(path, reinterpret_cast<ino_t*>(_aidl_return));
}
- return -1;
+ return res ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
}
static int split_count(const char *str)
@@ -746,8 +883,10 @@
return count;
}
-static void run_patchoat(int input_fd, int oat_fd, const char* input_file_name,
- const char* output_file_name, const char *pkgname ATTRIBUTE_UNUSED, const char *instruction_set)
+static void run_patchoat(int input_oat_fd, int input_vdex_fd, int out_oat_fd, int out_vdex_fd,
+ const char* input_oat_file_name, const char* input_vdex_file_name,
+ const char* output_oat_file_name, const char* output_vdex_file_name,
+ const char *pkgname ATTRIBUTE_UNUSED, const char *instruction_set)
{
static const int MAX_INT_LEN = 12; // '-'+10dig+'\0' -OR- 0x+8dig
static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
@@ -761,35 +900,44 @@
/* input_file_name/input_fd should be the .odex/.oat file that is precompiled. I think*/
char instruction_set_arg[strlen("--instruction-set=") + MAX_INSTRUCTION_SET_LEN];
- char output_oat_fd_arg[strlen("--output-oat-fd=") + MAX_INT_LEN];
char input_oat_fd_arg[strlen("--input-oat-fd=") + MAX_INT_LEN];
+ char input_vdex_fd_arg[strlen("--input-vdex-fd=") + MAX_INT_LEN];
+ char output_oat_fd_arg[strlen("--output-oat-fd=") + MAX_INT_LEN];
+ char output_vdex_fd_arg[strlen("--output-vdex-fd=") + MAX_INT_LEN];
const char* patched_image_location_arg = "--patched-image-location=/system/framework/boot.art";
// The caller has already gotten all the locks we need.
const char* no_lock_arg = "--no-lock-output";
sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set);
- sprintf(output_oat_fd_arg, "--output-oat-fd=%d", oat_fd);
- sprintf(input_oat_fd_arg, "--input-oat-fd=%d", input_fd);
- ALOGV("Running %s isa=%s in-fd=%d (%s) out-fd=%d (%s)\n",
- PATCHOAT_BIN, instruction_set, input_fd, input_file_name, oat_fd, output_file_name);
+ sprintf(output_oat_fd_arg, "--output-oat-fd=%d", out_oat_fd);
+ sprintf(input_oat_fd_arg, "--input-oat-fd=%d", input_oat_fd);
+ ALOGV("Running %s isa=%s in-oat-fd=%d (%s) in-vdex-fd=%d (%s) "
+ "out-oat-fd=%d (%s) out-vdex-fd=%d (%s)\n",
+ PATCHOAT_BIN, instruction_set,
+ input_oat_fd, input_oat_file_name,
+ input_vdex_fd, input_vdex_file_name,
+ out_oat_fd, output_oat_file_name,
+ out_vdex_fd, output_vdex_file_name);
/* patchoat, patched-image-location, no-lock, isa, input-fd, output-fd */
- char* argv[7];
+ char* argv[9];
argv[0] = (char*) PATCHOAT_BIN;
argv[1] = (char*) patched_image_location_arg;
argv[2] = (char*) no_lock_arg;
argv[3] = instruction_set_arg;
- argv[4] = output_oat_fd_arg;
- argv[5] = input_oat_fd_arg;
- argv[6] = NULL;
+ argv[4] = input_oat_fd_arg;
+ argv[5] = input_vdex_fd_arg;
+ argv[6] = output_oat_fd_arg;
+ argv[7] = output_vdex_fd_arg;
+ argv[8] = NULL;
execv(PATCHOAT_BIN, (char* const *)argv);
ALOGE("execv(%s) failed: %s\n", PATCHOAT_BIN, strerror(errno));
}
-static void run_dex2oat(int zip_fd, int oat_fd, int image_fd, const char* input_file_name,
- const char* output_file_name, int swap_fd, const char *instruction_set,
- const char* compiler_filter, bool vm_safe_mode, bool debuggable, bool post_bootcomplete,
- int profile_fd, const char* shared_libraries) {
+static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vdex_fd, int image_fd,
+ const char* input_file_name, const char* output_file_name, int swap_fd,
+ const char *instruction_set, const char* compiler_filter, bool vm_safe_mode,
+ bool debuggable, bool post_bootcomplete, int profile_fd, const char* shared_libraries) {
static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) {
@@ -870,6 +1018,8 @@
char zip_fd_arg[strlen("--zip-fd=") + MAX_INT_LEN];
char zip_location_arg[strlen("--zip-location=") + PKG_PATH_MAX];
+ char input_vdex_fd_arg[strlen("--input-vdex-fd=") + MAX_INT_LEN];
+ char output_vdex_fd_arg[strlen("--output-vdex-fd=") + MAX_INT_LEN];
char oat_fd_arg[strlen("--oat-fd=") + MAX_INT_LEN];
char oat_location_arg[strlen("--oat-location=") + PKG_PATH_MAX];
char instruction_set_arg[strlen("--instruction-set=") + MAX_INSTRUCTION_SET_LEN];
@@ -885,6 +1035,8 @@
sprintf(zip_fd_arg, "--zip-fd=%d", zip_fd);
sprintf(zip_location_arg, "--zip-location=%s", input_file_name);
+ sprintf(input_vdex_fd_arg, "--input-vdex-fd=%d", input_vdex_fd);
+ sprintf(output_vdex_fd_arg, "--output-vdex-fd=%d", output_vdex_fd);
sprintf(oat_fd_arg, "--oat-fd=%d", oat_fd);
sprintf(oat_location_arg, "--oat-location=%s", output_file_name);
sprintf(instruction_set_arg, "--instruction-set=%s", instruction_set);
@@ -947,7 +1099,7 @@
ALOGV("Running %s in=%s out=%s\n", DEX2OAT_BIN, input_file_name, output_file_name);
- const char* argv[7 // program name, mandatory arguments and the final NULL
+ const char* argv[9 // program name, mandatory arguments and the final NULL
+ (have_dex2oat_isa_variant ? 1 : 0)
+ (have_dex2oat_isa_features ? 1 : 0)
+ (have_dex2oat_Xms_flag ? 2 : 0)
@@ -968,6 +1120,8 @@
argv[i++] = DEX2OAT_BIN;
argv[i++] = zip_fd_arg;
argv[i++] = zip_location_arg;
+ argv[i++] = input_vdex_fd_arg;
+ argv[i++] = output_vdex_fd_arg;
argv[i++] = oat_fd_arg;
argv[i++] = oat_location_arg;
argv[i++] = instruction_set_arg;
@@ -1366,7 +1520,13 @@
// Dumps the contents of a profile file, using pkgname's dex files for pretty
// printing the result.
-bool dump_profile(uid_t uid, const char* pkgname, const char* code_path_string) {
+binder::Status InstalldNativeService::dumpProfiles(int32_t uid, const std::string& packageName,
+ const std::string& codePaths, bool* _aidl_return) {
+ ENFORCE_UID(AID_SYSTEM);
+
+ const char* pkgname = packageName.c_str();
+ const char* code_path_string = codePaths.c_str();
+
std::vector<fd_t> profile_fds;
fd_t reference_profile_fd = -1;
std::string out_file_name = StringPrintf("/data/misc/profman/%s.txt", pkgname);
@@ -1380,13 +1540,15 @@
if (!has_reference_profile && !has_profiles) {
ALOGE("profman dump: no profiles to dump for '%s'", pkgname);
- return false;
+ *_aidl_return = false;
+ return binder::Status::ok();
}
fd_t output_fd = open(out_file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW);
if (fchmod(output_fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
ALOGE("installd cannot chmod '%s' dump_profile\n", out_file_name.c_str());
- return false;
+ *_aidl_return = false;
+ return binder::Status::ok();
}
std::vector<std::string> code_full_paths = base::Split(code_path_string, ";");
std::vector<std::string> dex_locations;
@@ -1396,7 +1558,8 @@
fd_t apk_fd = open(full_path, O_RDONLY | O_NOFOLLOW);
if (apk_fd == -1) {
ALOGE("installd cannot open '%s'\n", full_path);
- return false;
+ *_aidl_return = false;
+ return binder::Status::ok();
}
dex_locations.push_back(get_location_from_path(full_path));
apk_fds.push_back(apk_fd);
@@ -1420,36 +1583,47 @@
if (!WIFEXITED(return_code)) {
LOG(WARNING) << "profman failed for package " << pkgname << ": "
<< return_code;
- return false;
+ *_aidl_return = false;
+ return binder::Status::ok();
}
- return true;
+ *_aidl_return = true;
+ return binder::Status::ok();
}
-// Translate the given oat path to an art (app image) path. An empty string
-// denotes an error.
-static std::string create_image_filename(const std::string& oat_path) {
- // A standard dalvik-cache entry. Replace ".dex" with ".art."
+static std::string replace_file_extension(const std::string& oat_path, const std::string& new_ext) {
+ // A standard dalvik-cache entry. Replace ".dex" with `new_ext`.
if (EndsWith(oat_path, ".dex")) {
- std::string art_path = oat_path;
- art_path.replace(art_path.length() - strlen("dex"), strlen("dex"), "art");
- CHECK(EndsWith(art_path, ".art"));
- return art_path;
+ std::string new_path = oat_path;
+ new_path.replace(new_path.length() - strlen(".dex"), strlen(".dex"), new_ext);
+ CHECK(EndsWith(new_path, new_ext.c_str()));
+ return new_path;
}
// An odex entry. Not that this may not be an extension, e.g., in the OTA
// case (where the base name will have an extension for the B artifact).
size_t odex_pos = oat_path.rfind(".odex");
if (odex_pos != std::string::npos) {
- std::string art_path = oat_path;
- art_path.replace(odex_pos, strlen(".odex"), ".art");
- CHECK_NE(art_path.find(".art"), std::string::npos);
- return art_path;
+ std::string new_path = oat_path;
+ new_path.replace(odex_pos, strlen(".odex"), new_ext);
+ CHECK_NE(new_path.find(new_ext), std::string::npos);
+ return new_path;
}
// Don't know how to handle this.
return "";
}
+// Translate the given oat path to an art (app image) path. An empty string
+// denotes an error.
+static std::string create_image_filename(const std::string& oat_path) {
+ return replace_file_extension(oat_path, ".art");
+}
+
+// Translate the given oat path to a vdex path. An empty string denotes an error.
+static std::string create_vdex_filename(const std::string& oat_path) {
+ return replace_file_extension(oat_path, ".vdex");
+}
+
static bool add_extension_to_file_name(char* file_name, const char* extension) {
if (strlen(file_name) + strlen(extension) + 1 > PKG_PATH_MAX) {
return false;
@@ -1484,8 +1658,16 @@
return true;
}
+static bool IsOutputDalvikCache(const char* oat_dir) {
+ // InstallerConnection.java (which invokes installd) transforms Java null arguments
+ // into '!'. Play it safe by handling it both.
+ // TODO: ensure we never get null.
+ // TODO: pass a flag instead of inferring if the output is dalvik cache.
+ return oat_dir == nullptr || oat_dir[0] == '!';
+}
+
static bool create_oat_out_path(const char* apk_path, const char* instruction_set,
- const char* oat_dir, /*out*/ char* out_path) {
+ const char* oat_dir, /*out*/ char* out_oat_path) {
// Early best-effort check whether we can fit the the path into our buffers.
// Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run
// without a swap file, if necessary. Reference profiles file also add an extra ".prof"
@@ -1495,16 +1677,16 @@
return false;
}
- if (oat_dir != NULL && oat_dir[0] != '!') {
+ if (!IsOutputDalvikCache(oat_dir)) {
if (validate_apk_path(oat_dir)) {
- ALOGE("invalid oat_dir '%s'\n", oat_dir);
+ ALOGE("cannot validate apk path with oat_dir '%s'\n", oat_dir);
return false;
}
- if (!calculate_oat_file_path(out_path, oat_dir, apk_path, instruction_set)) {
+ if (!calculate_oat_file_path(out_oat_path, oat_dir, apk_path, instruction_set)) {
return false;
}
} else {
- if (!create_cache_path(out_path, apk_path, instruction_set)) {
+ if (!create_cache_path(out_oat_path, apk_path, instruction_set)) {
return false;
}
}
@@ -1512,30 +1694,12 @@
}
// TODO: Consider returning error codes.
-bool merge_profiles(uid_t uid, const char *pkgname) {
- return analyse_profiles(uid, pkgname);
-}
-
-static const char* parse_null(const char* arg) {
- if (strcmp(arg, "!") == 0) {
- return nullptr;
- } else {
- return arg;
- }
-}
-
-int dexopt(const char* const params[DEXOPT_PARAM_COUNT]) {
- return dexopt(params[0], // apk_path
- atoi(params[1]), // uid
- params[2], // pkgname
- params[3], // instruction_set
- atoi(params[4]), // dexopt_needed
- params[5], // oat_dir
- atoi(params[6]), // dexopt_flags
- params[7], // compiler_filter
- parse_null(params[8]), // volume_uuid
- parse_null(params[9])); // shared_libraries
- static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param count");
+binder::Status InstalldNativeService::mergeProfiles(int32_t uid, const std::string& packageName,
+ bool* _aidl_return) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* pkgname = packageName.c_str();
+ *_aidl_return = analyse_profiles(uid, pkgname);
+ return binder::Status::ok();
}
// Helper for fd management. This is similar to a unique_fd in that it closes the file descriptor
@@ -1616,19 +1780,16 @@
bool do_cleanup_;
};
+// TODO: eventually move dexopt() implementation into dexopt.cpp
int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* instruction_set,
- int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter,
- const char* volume_uuid ATTRIBUTE_UNUSED, const char* shared_libraries)
-{
+ int dexopt_needed, const char* oat_dir, int dexopt_flags,const char* compiler_filter,
+ const char* volume_uuid ATTRIBUTE_UNUSED, const char* shared_libraries) {
bool is_public = ((dexopt_flags & DEXOPT_PUBLIC) != 0);
bool vm_safe_mode = (dexopt_flags & DEXOPT_SAFEMODE) != 0;
bool debuggable = (dexopt_flags & DEXOPT_DEBUGGABLE) != 0;
bool boot_complete = (dexopt_flags & DEXOPT_BOOTCOMPLETE) != 0;
bool profile_guided = (dexopt_flags & DEXOPT_PROFILE_GUIDED) != 0;
- // Don't use profile for vm_safe_mode. b/30688277
- profile_guided = profile_guided && !vm_safe_mode;
-
CHECK(pkgname != nullptr);
CHECK(pkgname[0] != 0);
@@ -1649,27 +1810,32 @@
LOG_FATAL("dexopt flags contains unknown fields\n");
}
- char out_path[PKG_PATH_MAX];
- if (!create_oat_out_path(apk_path, instruction_set, oat_dir, out_path)) {
+ char out_oat_path[PKG_PATH_MAX];
+ if (!create_oat_out_path(apk_path, instruction_set, oat_dir, out_oat_path)) {
return false;
}
const char *input_file;
char in_odex_path[PKG_PATH_MAX];
- switch (dexopt_needed) {
- case DEXOPT_DEX2OAT_NEEDED:
+ int dexopt_action = abs(dexopt_needed);
+ bool is_odex_location = dexopt_needed < 0;
+ switch (dexopt_action) {
+ case DEX2OAT_FROM_SCRATCH:
+ case DEX2OAT_FOR_BOOT_IMAGE:
+ case DEX2OAT_FOR_FILTER:
+ case DEX2OAT_FOR_RELOCATION:
input_file = apk_path;
break;
- case DEXOPT_PATCHOAT_NEEDED:
- if (!calculate_odex_file_path(in_odex_path, apk_path, instruction_set)) {
- return -1;
+ case PATCHOAT_FOR_RELOCATION:
+ if (is_odex_location) {
+ if (!calculate_odex_file_path(in_odex_path, apk_path, instruction_set)) {
+ return -1;
+ }
+ input_file = in_odex_path;
+ } else {
+ input_file = out_oat_path;
}
- input_file = in_odex_path;
- break;
-
- case DEXOPT_SELF_PATCHOAT_NEEDED:
- input_file = out_path;
break;
default:
@@ -1681,21 +1847,79 @@
memset(&input_stat, 0, sizeof(input_stat));
stat(input_file, &input_stat);
+ // Open the input file. If running dex2oat, `input_file` is the APK. If running
+ // patchoat, it is the OAT file to be relocated.
base::unique_fd input_fd(open(input_file, O_RDONLY, 0));
if (input_fd.get() < 0) {
ALOGE("installd cannot open '%s' for input during dexopt\n", input_file);
return -1;
}
- const std::string out_path_str(out_path);
- Dex2oatFileWrapper<std::function<void ()>> out_fd(
- open_output_file(out_path, /*recreate*/true, /*permissions*/0644),
- [out_path_str]() { unlink(out_path_str.c_str()); });
- if (out_fd.get() < 0) {
- ALOGE("installd cannot open '%s' for output during dexopt\n", out_path);
+ // Create the output OAT file.
+ const std::string out_oat_path_str(out_oat_path);
+ Dex2oatFileWrapper<std::function<void ()>> out_oat_fd(
+ open_output_file(out_oat_path, /*recreate*/true, /*permissions*/0644),
+ [out_oat_path_str]() { unlink(out_oat_path_str.c_str()); });
+ if (out_oat_fd.get() < 0) {
+ ALOGE("installd cannot open '%s' for output during dexopt\n", out_oat_path);
return -1;
}
- if (!set_permissions_and_ownership(out_fd.get(), is_public, uid, out_path)) {
+ if (!set_permissions_and_ownership(out_oat_fd.get(), is_public, uid, out_oat_path)) {
+ return -1;
+ }
+
+ // Open the existing VDEX. We do this before creating the new output VDEX, which will
+ // unlink the old one.
+ base::unique_fd in_vdex_fd;
+ std::string in_vdex_path_str;
+ if (dexopt_action == PATCHOAT_FOR_RELOCATION) {
+ // `input_file` is the OAT file to be relocated. The VDEX has to be there as well.
+ in_vdex_path_str = create_vdex_filename(input_file);
+ if (in_vdex_path_str.empty()) {
+ ALOGE("installd cannot compute input vdex location for '%s'\n", input_file);
+ return -1;
+ }
+ in_vdex_fd.reset(open(in_vdex_path_str.c_str(), O_RDONLY, 0));
+ if (in_vdex_fd.get() < 0) {
+ ALOGE("installd cannot open '%s' for input during dexopt: %s\n",
+ in_vdex_path_str.c_str(), strerror(errno));
+ return -1;
+ }
+ } else if (dexopt_action != DEX2OAT_FROM_SCRATCH) {
+ // Open the possibly existing vdex. If none exist, we pass -1 to dex2oat for input-vdex-fd.
+ const char* path = nullptr;
+ if (is_odex_location) {
+ if (calculate_odex_file_path(in_odex_path, apk_path, instruction_set)) {
+ path = in_odex_path;
+ } else {
+ ALOGE("installd cannot compute input vdex location for '%s'\n", apk_path);
+ return -1;
+ }
+ } else {
+ path = out_oat_path;
+ }
+ in_vdex_path_str = create_vdex_filename(path);
+ if (in_vdex_path_str.empty()) {
+ ALOGE("installd cannot compute input vdex location for '%s'\n", path);
+ return -1;
+ }
+ in_vdex_fd.reset(open(in_vdex_path_str.c_str(), O_RDONLY, 0));
+ }
+
+ // Infer the name of the output VDEX and create it.
+ const std::string out_vdex_path_str = create_vdex_filename(out_oat_path_str);
+ if (out_vdex_path_str.empty()) {
+ return -1;
+ }
+ Dex2oatFileWrapper<std::function<void ()>> out_vdex_fd(
+ open_output_file(out_vdex_path_str.c_str(), /*recreate*/true, /*permissions*/0644),
+ [out_vdex_path_str]() { unlink(out_vdex_path_str.c_str()); });
+ if (out_vdex_fd.get() < 0) {
+ ALOGE("installd cannot open '%s' for output during dexopt\n", out_vdex_path_str.c_str());
+ return -1;
+ }
+ if (!set_permissions_and_ownership(out_vdex_fd.get(), is_public,
+ uid, out_vdex_path_str.c_str())) {
return -1;
}
@@ -1704,7 +1928,7 @@
if (ShouldUseSwapFileForDexopt()) {
// Make sure there really is enough space.
char swap_file_name[PKG_PATH_MAX];
- strcpy(swap_file_name, out_path);
+ strcpy(swap_file_name, out_oat_path);
if (add_extension_to_file_name(swap_file_name, ".swap")) {
swap_fd.reset(open_output_file(swap_file_name, /*recreate*/true, /*permissions*/0600));
}
@@ -1722,8 +1946,8 @@
// Avoid generating an app image for extract only since it will not contain any classes.
Dex2oatFileWrapper<std::function<void ()>> image_fd;
- const std::string image_path = create_image_filename(out_path);
- if (!image_path.empty()) {
+ const std::string image_path = create_image_filename(out_oat_path);
+ if (dexopt_action != PATCHOAT_FOR_RELOCATION && !image_path.empty()) {
char app_image_format[kPropertyValueMax];
bool have_app_image_format =
get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0;
@@ -1768,27 +1992,32 @@
drop_capabilities(uid);
SetDex2OatAndPatchOatScheduling(boot_complete);
- if (flock(out_fd.get(), LOCK_EX | LOCK_NB) != 0) {
- ALOGE("flock(%s) failed: %s\n", out_path, strerror(errno));
+ if (flock(out_oat_fd.get(), LOCK_EX | LOCK_NB) != 0) {
+ ALOGE("flock(%s) failed: %s\n", out_oat_path, strerror(errno));
_exit(67);
}
- if (dexopt_needed == DEXOPT_PATCHOAT_NEEDED
- || dexopt_needed == DEXOPT_SELF_PATCHOAT_NEEDED) {
+ if (dexopt_action == PATCHOAT_FOR_RELOCATION) {
run_patchoat(input_fd.get(),
- out_fd.get(),
+ in_vdex_fd.get(),
+ out_oat_fd.get(),
+ out_vdex_fd.get(),
input_file,
- out_path,
+ in_vdex_path_str.c_str(),
+ out_oat_path,
+ out_vdex_path_str.c_str(),
pkgname,
instruction_set);
- } else if (dexopt_needed == DEXOPT_DEX2OAT_NEEDED) {
+ } else {
// Pass dex2oat the relative path to the input file.
const char *input_file_name = get_location_from_path(input_file);
run_dex2oat(input_fd.get(),
- out_fd.get(),
+ out_oat_fd.get(),
+ in_vdex_fd.get(),
+ out_vdex_fd.get(),
image_fd.get(),
input_file_name,
- out_path,
+ out_oat_path,
swap_fd.get(),
instruction_set,
compiler_filter,
@@ -1797,9 +2026,6 @@
boot_complete,
reference_profile_fd.get(),
shared_libraries);
- } else {
- ALOGE("Invalid dexopt needed: %d\n", dexopt_needed);
- _exit(73);
}
_exit(68); /* only get here on exec failure */
} else {
@@ -1815,33 +2041,54 @@
struct utimbuf ut;
ut.actime = input_stat.st_atime;
ut.modtime = input_stat.st_mtime;
- utime(out_path, &ut);
+ utime(out_oat_path, &ut);
// We've been successful, don't delete output.
- out_fd.SetCleanup(false);
+ out_oat_fd.SetCleanup(false);
+ out_vdex_fd.SetCleanup(false);
image_fd.SetCleanup(false);
reference_profile_fd.SetCleanup(false);
return 0;
}
-int mark_boot_complete(const char* instruction_set)
-{
- char boot_marker_path[PKG_PATH_MAX];
- sprintf(boot_marker_path,
+binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t uid,
+ const std::unique_ptr<std::string>& packageName, const std::string& instructionSet,
+ int32_t dexoptNeeded, const std::unique_ptr<std::string>& outputPath, int32_t dexFlags,
+ const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid,
+ const std::unique_ptr<std::string>& sharedLibraries) {
+ ENFORCE_UID(AID_SYSTEM);
+
+ const char* apk_path = apkPath.c_str();
+ const char* pkgname = packageName ? packageName->c_str() : "*";
+ const char* instruction_set = instructionSet.c_str();
+ const char* oat_dir = outputPath ? outputPath->c_str() : nullptr;
+ const char* compiler_filter = compilerFilter.c_str();
+ const char* volume_uuid = uuid ? uuid->c_str() : nullptr;
+ const char* shared_libraries = sharedLibraries ? sharedLibraries->c_str() : nullptr;
+
+ int res = android::installd::dexopt(apk_path, uid, pkgname, instruction_set, dexoptNeeded,
+ oat_dir, dexFlags, compiler_filter, volume_uuid, shared_libraries);
+ return res ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
+}
+
+binder::Status InstalldNativeService::markBootComplete(const std::string& instructionSet) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* instruction_set = instructionSet.c_str();
+
+ char boot_marker_path[PKG_PATH_MAX];
+ sprintf(boot_marker_path,
"%s/%s/%s/.booting",
android_data_dir.path,
DALVIK_CACHE,
instruction_set);
- ALOGV("mark_boot_complete : %s", boot_marker_path);
- if (unlink(boot_marker_path) != 0) {
- ALOGE("Unable to unlink boot marker at %s, error=%s", boot_marker_path,
- strerror(errno));
- return -1;
- }
-
- return 0;
+ ALOGV("mark_boot_complete : %s", boot_marker_path);
+ if (unlink(boot_marker_path) != 0) {
+ ALOGE("Unable to unlink boot marker at %s, error=%s", boot_marker_path, strerror(errno));
+ return binder::Status::fromServiceSpecificError(-1);
+ }
+ return binder::Status::ok();
}
void mkinnerdirs(char* path, int basepos, mode_t mode, int uid, int gid,
@@ -1865,22 +2112,29 @@
}
}
-int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId)
-{
+binder::Status InstalldNativeService::linkNativeLibraryDirectory(
+ const std::unique_ptr<std::string>& uuid, const std::string& packageName,
+ const std::string& nativeLibPath32, int32_t userId) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ const char* pkgname = packageName.c_str();
+ const char* asecLibDir = nativeLibPath32.c_str();
struct stat s, libStat;
int rc = 0;
- std::string _pkgdir(create_data_user_ce_package_path(uuid, userId, pkgname));
+ std::string _pkgdir(create_data_user_ce_package_path(uuid_, userId, pkgname));
std::string _libsymlink(_pkgdir + PKG_LIB_POSTFIX);
const char* pkgdir = _pkgdir.c_str();
const char* libsymlink = _libsymlink.c_str();
- if (stat(pkgdir, &s) < 0) return -1;
+ if (stat(pkgdir, &s) < 0) {
+ return binder::Status::fromServiceSpecificError(-1);
+ }
if (chown(pkgdir, AID_INSTALL, AID_INSTALL) < 0) {
ALOGE("failed to chown '%s': %s\n", pkgdir, strerror(errno));
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
if (chmod(pkgdir, 0700) < 0) {
@@ -1925,10 +2179,10 @@
if (chown(pkgdir, s.st_uid, s.st_gid) < 0) {
ALOGE("failed to chown '%s' : %s\n", pkgdir, strerror(errno));
- return -errno;
+ rc = -errno;
}
- return rc;
+ return rc ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
}
static void run_idmap(const char *target_apk, const char *overlay_apk, int idmap_fd)
@@ -1978,8 +2232,11 @@
return 0;
}
-int idmap(const char *target_apk, const char *overlay_apk, uid_t uid)
-{
+binder::Status InstalldNativeService::idmap(const std::string& targetApkPath,
+ const std::string& overlayApkPath, int32_t uid) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* target_apk = targetApkPath.c_str();
+ const char* overlay_apk = overlayApkPath.c_str();
ALOGV("idmap target_apk=%s overlay_apk=%s uid=%d\n", target_apk, overlay_apk, uid);
int idmap_fd = -1;
@@ -2034,78 +2291,93 @@
}
close(idmap_fd);
- return 0;
+ return binder::Status::ok();
fail:
if (idmap_fd >= 0) {
close(idmap_fd);
unlink(idmap_path);
}
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
-int restorecon_app_data(const char* uuid, const char* pkgName, userid_t userid, int flags,
- appid_t appid, const char* seinfo) {
+binder::Status InstalldNativeService::restoreconAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
+ const std::string& seInfo) {
+ ENFORCE_UID(AID_SYSTEM);
int res = 0;
// SELINUX_ANDROID_RESTORECON_DATADATA flag is set by libselinux. Not needed here.
unsigned int seflags = SELINUX_ANDROID_RESTORECON_RECURSE;
+ const char* uuid_ = uuid ? uuid->c_str() : nullptr;
+ const char* pkgName = packageName.c_str();
+ const char* seinfo = seInfo.c_str();
if (!pkgName || !seinfo) {
ALOGE("Package name or seinfo tag is null when trying to restorecon.");
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
- uid_t uid = multiuser_get_uid(userid, appid);
+ uid_t uid = multiuser_get_uid(userId, appId);
if (flags & FLAG_STORAGE_CE) {
- auto path = create_data_user_ce_package_path(uuid, userid, pkgName);
+ auto path = create_data_user_ce_package_path(uuid_, userId, pkgName);
if (selinux_android_restorecon_pkgdir(path.c_str(), seinfo, uid, seflags) < 0) {
PLOG(ERROR) << "restorecon failed for " << path;
res = -1;
}
}
if (flags & FLAG_STORAGE_DE) {
- auto path = create_data_user_de_package_path(uuid, userid, pkgName);
+ auto path = create_data_user_de_package_path(uuid_, userId, pkgName);
if (selinux_android_restorecon_pkgdir(path.c_str(), seinfo, uid, seflags) < 0) {
PLOG(ERROR) << "restorecon failed for " << path;
// TODO: include result once 25796509 is fixed
}
}
-
- return res;
+ return res ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
}
-int create_oat_dir(const char* oat_dir, const char* instruction_set)
-{
+binder::Status InstalldNativeService::createOatDir(const std::string& oatDir,
+ const std::string& instructionSet) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* oat_dir = oatDir.c_str();
+ const char* instruction_set = instructionSet.c_str();
char oat_instr_dir[PKG_PATH_MAX];
if (validate_apk_path(oat_dir)) {
ALOGE("invalid apk path '%s' (bad prefix)\n", oat_dir);
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
if (fs_prepare_dir(oat_dir, S_IRWXU | S_IRWXG | S_IXOTH, AID_SYSTEM, AID_INSTALL)) {
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
if (selinux_android_restorecon(oat_dir, 0)) {
ALOGE("cannot restorecon dir '%s': %s\n", oat_dir, strerror(errno));
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
snprintf(oat_instr_dir, PKG_PATH_MAX, "%s/%s", oat_dir, instruction_set);
if (fs_prepare_dir(oat_instr_dir, S_IRWXU | S_IRWXG | S_IXOTH, AID_SYSTEM, AID_INSTALL)) {
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
- return 0;
+ return binder::Status::ok();
}
-int rm_package_dir(const char* apk_path)
-{
+binder::Status InstalldNativeService::rmPackageDir(const std::string& packageDir) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* apk_path = packageDir.c_str();
if (validate_apk_path(apk_path)) {
ALOGE("invalid apk path '%s' (bad prefix)\n", apk_path);
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
- return delete_dir_contents(apk_path, 1 /* also_delete_dir */ , NULL /* exclusion_predicate */);
+ int res = delete_dir_contents(apk_path, 1 /* also_delete_dir */,
+ NULL /* exclusion_predicate */);
+ return res ? binder::Status::fromServiceSpecificError(-1) : binder::Status::ok();
}
-int link_file(const char* relative_path, const char* from_base, const char* to_base) {
+binder::Status InstalldNativeService::linkFile(const std::string& relativePath,
+ const std::string& fromBase, const std::string& toBase) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* relative_path = relativePath.c_str();
+ const char* from_base = fromBase.c_str();
+ const char* to_base = toBase.c_str();
char from_path[PKG_PATH_MAX];
char to_path[PKG_PATH_MAX];
snprintf(from_path, PKG_PATH_MAX, "%s/%s", from_base, relative_path);
@@ -2113,21 +2385,21 @@
if (validate_apk_path_subdirs(from_path)) {
ALOGE("invalid app data sub-path '%s' (bad prefix)\n", from_path);
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
if (validate_apk_path_subdirs(to_path)) {
ALOGE("invalid app data sub-path '%s' (bad prefix)\n", to_path);
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
const int ret = link(from_path, to_path);
if (ret < 0) {
ALOGE("link(%s, %s) failed : %s", from_path, to_path, strerror(errno));
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
- return 0;
+ return binder::Status::ok();
}
// Helper for move_ab, so that we can have common failure-case cleanup.
@@ -2154,7 +2426,6 @@
PLOG(ERROR) << "Could not rename " << from << " to " << to;
return false;
}
-
return true;
}
@@ -2189,82 +2460,94 @@
return true;
}
-int move_ab(const char* apk_path, const char* instruction_set, const char* oat_dir) {
- if (apk_path == nullptr || instruction_set == nullptr || oat_dir == nullptr) {
- LOG(ERROR) << "Cannot move_ab with null input";
- return -1;
- }
+binder::Status InstalldNativeService::moveAb(const std::string& apkPath,
+ const std::string& instructionSet, const std::string& outputPath) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* apk_path = apkPath.c_str();
+ const char* instruction_set = instructionSet.c_str();
+ const char* oat_dir = outputPath.c_str();
// Get the current slot suffix. No suffix, no A/B.
std::string slot_suffix;
{
char buf[kPropertyValueMax];
if (get_property("ro.boot.slot_suffix", buf, nullptr) <= 0) {
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
slot_suffix = buf;
if (!ValidateTargetSlotSuffix(slot_suffix)) {
LOG(ERROR) << "Target slot suffix not legal: " << slot_suffix;
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
}
// Validate other inputs.
if (validate_apk_path(apk_path) != 0) {
LOG(ERROR) << "invalid apk_path " << apk_path;
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
if (validate_apk_path(oat_dir) != 0) {
LOG(ERROR) << "invalid oat_dir " << oat_dir;
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
char a_path[PKG_PATH_MAX];
if (!calculate_oat_file_path(a_path, oat_dir, apk_path, instruction_set)) {
- return -1;
+ return binder::Status::fromServiceSpecificError(-1);
}
+ const std::string a_vdex_path = create_vdex_filename(a_path);
const std::string a_image_path = create_image_filename(a_path);
// B path = A path + slot suffix.
const std::string b_path = StringPrintf("%s.%s", a_path, slot_suffix.c_str());
+ const std::string b_vdex_path = StringPrintf("%s.%s", a_vdex_path.c_str(), slot_suffix.c_str());
const std::string b_image_path = StringPrintf("%s.%s",
a_image_path.c_str(),
slot_suffix.c_str());
- bool oat_success = move_ab_path(b_path, a_path);
- bool success;
+ bool success = true;
+ if (move_ab_path(b_path, a_path)) {
+ if (move_ab_path(b_vdex_path, a_vdex_path)) {
+ // Note: we can live without an app image. As such, ignore failure to move the image file.
+ // If we decide to require the app image, or the app image being moved correctly,
+ // then change accordingly.
+ constexpr bool kIgnoreAppImageFailure = true;
- if (oat_success) {
- // Note: we can live without an app image. As such, ignore failure to move the image file.
- // If we decide to require the app image, or the app image being moved correctly,
- // then change accordingly.
- constexpr bool kIgnoreAppImageFailure = true;
-
- bool art_success = true;
- if (!a_image_path.empty()) {
- art_success = move_ab_path(b_image_path, a_image_path);
- if (!art_success) {
- unlink(a_image_path.c_str());
+ if (!a_image_path.empty()) {
+ if (!move_ab_path(b_image_path, a_image_path)) {
+ unlink(a_image_path.c_str());
+ if (!kIgnoreAppImageFailure) {
+ success = false;
+ }
+ }
}
+ } else {
+ // Cleanup: delete B image, ignore errors.
+ unlink(b_image_path.c_str());
+ success = false;
}
-
- success = art_success || kIgnoreAppImageFailure;
} else {
// Cleanup: delete B image, ignore errors.
+ unlink(b_vdex_path.c_str());
unlink(b_image_path.c_str());
-
success = false;
}
- return success ? 0 : -1;
+ return success ? binder::Status::ok() : binder::Status::fromServiceSpecificError(-1);
}
-bool delete_odex(const char *apk_path, const char *instruction_set, const char *oat_dir) {
+binder::Status InstalldNativeService::deleteOdex(const std::string& apkPath,
+ const std::string& instructionSet, const std::string& outputPath) {
+ ENFORCE_UID(AID_SYSTEM);
+ const char* apk_path = apkPath.c_str();
+ const char* instruction_set = instructionSet.c_str();
+ const char* oat_dir = outputPath.c_str();
+
// Delete the oat/odex file.
char out_path[PKG_PATH_MAX];
if (!create_oat_out_path(apk_path, instruction_set, oat_dir, out_path)) {
- return false;
+ return binder::Status::fromServiceSpecificError(-1);
}
// In case of a permission failure report the issue. Otherwise just print a warning.
@@ -2287,7 +2570,8 @@
bool return_value_art = unlink_and_check(create_image_filename(out_path).c_str());
// Report success.
- return return_value_oat && return_value_art;
+ bool success = return_value_oat && return_value_art;
+ return success ? binder::Status::ok() : binder::Status::fromServiceSpecificError(-1);
}
} // namespace installd
diff --git a/cmds/installd/InstalldNativeService.h b/cmds/installd/InstalldNativeService.h
new file mode 100644
index 0000000..749a218
--- /dev/null
+++ b/cmds/installd/InstalldNativeService.h
@@ -0,0 +1,102 @@
+/*
+**
+** Copyright 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 COMMANDS_H_
+#define COMMANDS_H_
+
+#include <inttypes.h>
+#include <unistd.h>
+
+#include <vector>
+
+#include <binder/BinderService.h>
+#include <cutils/multiuser.h>
+
+#include "android/os/BnInstalld.h"
+#include "installd_constants.h"
+
+namespace android {
+namespace installd {
+
+class InstalldNativeService : public BinderService<InstalldNativeService>, public os::BnInstalld {
+public:
+ static status_t start();
+ static char const* getServiceName() { return "installd"; }
+ virtual status_t dump(int fd, const Vector<String16> &args) override;
+
+ binder::Status createUserData(const std::unique_ptr<std::string>& uuid, int32_t userId,
+ int32_t userSerial, int32_t flags);
+ binder::Status destroyUserData(const std::unique_ptr<std::string>& uuid, int32_t userId,
+ int32_t flags);
+
+ binder::Status createAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
+ const std::string& seInfo, int32_t targetSdkVersion);
+ binder::Status restoreconAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
+ const std::string& seInfo);
+ binder::Status migrateAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags);
+ binder::Status clearAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode);
+ binder::Status destroyAppData(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode);
+ binder::Status getAppDataInode(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int64_t* _aidl_return);
+ binder::Status getAppSize(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, int32_t userId, int32_t flags, int64_t ceDataInode,
+ const std::string& codePath, std::vector<int64_t>* _aidl_return);
+
+ binder::Status moveCompleteApp(const std::unique_ptr<std::string>& fromUuid,
+ const std::unique_ptr<std::string>& toUuid, const std::string& packageName,
+ const std::string& dataAppName, int32_t appId, const std::string& seInfo,
+ int32_t targetSdkVersion);
+
+ binder::Status dexopt(const std::string& apkPath, int32_t uid,
+ const std::unique_ptr<std::string>& packageName, const std::string& instructionSet,
+ int32_t dexoptNeeded, const std::unique_ptr<std::string>& outputPath, int32_t dexFlags,
+ const std::string& compilerFilter, const std::unique_ptr<std::string>& uuid,
+ const std::unique_ptr<std::string>& sharedLibraries);
+
+ binder::Status rmdex(const std::string& codePath, const std::string& instructionSet);
+
+ binder::Status mergeProfiles(int32_t uid, const std::string& packageName, bool* _aidl_return);
+ binder::Status dumpProfiles(int32_t uid, const std::string& packageName,
+ const std::string& codePaths, bool* _aidl_return);
+ binder::Status clearAppProfiles(const std::string& packageName);
+ binder::Status destroyAppProfiles(const std::string& packageName);
+
+ binder::Status idmap(const std::string& targetApkPath, const std::string& overlayApkPath,
+ int32_t uid);
+ binder::Status rmPackageDir(const std::string& packageDir);
+ binder::Status markBootComplete(const std::string& instructionSet);
+ binder::Status freeCache(const std::unique_ptr<std::string>& uuid, int64_t freeStorageSize);
+ binder::Status linkNativeLibraryDirectory(const std::unique_ptr<std::string>& uuid,
+ const std::string& packageName, const std::string& nativeLibPath32, int32_t userId);
+ binder::Status createOatDir(const std::string& oatDir, const std::string& instructionSet);
+ binder::Status linkFile(const std::string& relativePath, const std::string& fromBase,
+ const std::string& toBase);
+ binder::Status moveAb(const std::string& apkPath, const std::string& instructionSet,
+ const std::string& outputPath);
+ binder::Status deleteOdex(const std::string& apkPath, const std::string& instructionSet,
+ const std::string& outputPath);
+};
+
+} // namespace installd
+} // namespace android
+
+#endif // COMMANDS_H_
diff --git a/cmds/installd/binder/android/os/IInstalld.aidl b/cmds/installd/binder/android/os/IInstalld.aidl
new file mode 100644
index 0000000..bcfaca8
--- /dev/null
+++ b/cmds/installd/binder/android/os/IInstalld.aidl
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package android.os;
+
+/** {@hide} */
+interface IInstalld {
+ void createUserData(@nullable @utf8InCpp String uuid, int userId, int userSerial, int flags);
+ void destroyUserData(@nullable @utf8InCpp String uuid, int userId, int flags);
+
+ void createAppData(@nullable @utf8InCpp String uuid, in @utf8InCpp String packageName,
+ int userId, int flags, int appId, in @utf8InCpp String seInfo, int targetSdkVersion);
+ void restoreconAppData(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName,
+ int userId, int flags, int appId, @utf8InCpp String seInfo);
+ void migrateAppData(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName,
+ int userId, int flags);
+ void clearAppData(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName,
+ int userId, int flags, long ceDataInode);
+ void destroyAppData(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName,
+ int userId, int flags, long ceDataInode);
+ long getAppDataInode(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName,
+ int userId, int flags);
+ long[] getAppSize(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName,
+ int userId, int flags, long ceDataInode, @utf8InCpp String codePath);
+
+ void moveCompleteApp(@nullable @utf8InCpp String fromUuid, @nullable @utf8InCpp String toUuid,
+ @utf8InCpp String packageName, @utf8InCpp String dataAppName, int appId,
+ @utf8InCpp String seInfo, int targetSdkVersion);
+
+ void dexopt(@utf8InCpp String apkPath, int uid, @nullable @utf8InCpp String packageName,
+ @utf8InCpp String instructionSet, int dexoptNeeded,
+ @nullable @utf8InCpp String outputPath, int dexFlags,
+ @utf8InCpp String compilerFilter, @nullable @utf8InCpp String uuid,
+ @nullable @utf8InCpp String sharedLibraries);
+
+ void rmdex(@utf8InCpp String codePath, @utf8InCpp String instructionSet);
+
+ boolean mergeProfiles(int uid, @utf8InCpp String packageName);
+ boolean dumpProfiles(int uid, @utf8InCpp String packageName, @utf8InCpp String codePaths);
+ void clearAppProfiles(@utf8InCpp String packageName);
+ void destroyAppProfiles(@utf8InCpp String packageName);
+
+ void idmap(@utf8InCpp String targetApkPath, @utf8InCpp String overlayApkPath, int uid);
+ void rmPackageDir(@utf8InCpp String packageDir);
+ void markBootComplete(@utf8InCpp String instructionSet);
+ void freeCache(@nullable @utf8InCpp String uuid, long freeStorageSize);
+ void linkNativeLibraryDirectory(@nullable @utf8InCpp String uuid,
+ @utf8InCpp String packageName, @utf8InCpp String nativeLibPath32, int userId);
+ void createOatDir(@utf8InCpp String oatDir, @utf8InCpp String instructionSet);
+ void linkFile(@utf8InCpp String relativePath, @utf8InCpp String fromBase,
+ @utf8InCpp String toBase);
+ void moveAb(@utf8InCpp String apkPath, @utf8InCpp String instructionSet,
+ @utf8InCpp String outputPath);
+ void deleteOdex(@utf8InCpp String apkPath, @utf8InCpp String instructionSet,
+ @utf8InCpp String outputPath);
+}
diff --git a/cmds/installd/commands.h b/cmds/installd/commands.h
deleted file mode 100644
index ba27517..0000000
--- a/cmds/installd/commands.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-**
-** Copyright 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 COMMANDS_H_
-#define COMMANDS_H_
-
-#include <inttypes.h>
-#include <unistd.h>
-
-#include <cutils/multiuser.h>
-
-#include <installd_constants.h>
-
-namespace android {
-namespace installd {
-
-static constexpr size_t DEXOPT_PARAM_COUNT = 10U;
-
-int create_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags,
- appid_t appid, const char* seinfo, int target_sdk_version);
-int restorecon_app_data(const char* uuid, const char* pkgName, userid_t userid, int flags,
- appid_t appid, const char* seinfo);
-int migrate_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags);
-int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags,
- ino_t ce_data_inode);
-int destroy_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags,
- ino_t ce_data_inode);
-
-int move_complete_app(const char* from_uuid, const char *to_uuid, const char *package_name,
- const char *data_app_name, appid_t appid, const char* seinfo, int target_sdk_version);
-
-int get_app_size(const char *uuid, const char *pkgname, int userid, int flags, ino_t ce_data_inode,
- const char* code_path, int64_t *codesize, int64_t *datasize, int64_t *cachesize,
- int64_t *asecsize);
-int get_app_data_inode(const char *uuid, const char *pkgname, int userid, int flags, ino_t *inode);
-
-int create_user_data(const char *uuid, userid_t userid, int user_serial, int flags);
-int destroy_user_data(const char *uuid, userid_t userid, int flags);
-
-int rm_dex(const char *path, const char *instruction_set);
-int free_cache(const char *uuid, int64_t free_size);
-
-bool merge_profiles(uid_t uid, const char *pkgname);
-
-bool dump_profile(uid_t uid, const char *pkgname, const char *dex_files);
-
-int dexopt(const char *apk_path,
- uid_t uid,
- const char *pkgName,
- const char *instruction_set,
- int dexopt_needed,
- const char* oat_dir,
- int dexopt_flags,
- const char* compiler_filter,
- const char* volume_uuid,
- const char* shared_libraries);
-static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param size");
-
-// Helper for the above, converting arguments.
-int dexopt(const char* const params[DEXOPT_PARAM_COUNT]);
-
-int mark_boot_complete(const char *instruction_set);
-int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId);
-int idmap(const char *target_path, const char *overlay_path, uid_t uid);
-int create_oat_dir(const char* oat_dir, const char *instruction_set);
-int rm_package_dir(const char* apk_path);
-int clear_app_profiles(const char* pkgname);
-int destroy_app_profiles(const char* pkgname);
-int link_file(const char *relative_path, const char *from_base, const char *to_base);
-
-// Move a B version over to the A location. Only works for oat_dir != nullptr.
-int move_ab(const char *apk_path, const char *instruction_set, const char* oat_dir);
-
-// Delete odex files generated by dexopt.
-bool delete_odex(const char *apk_path, const char *instruction_set, const char *oat_dir);
-
-} // namespace installd
-} // namespace android
-
-#endif // COMMANDS_H_
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
new file mode 100644
index 0000000..71836c3
--- /dev/null
+++ b/cmds/installd/dexopt.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <android-base/logging.h>
+#include <android-base/stringprintf.h>
+
+#include "dexopt.h"
+#include "utils.h"
+
+using android::base::StringPrintf;
+
+namespace android {
+namespace installd {
+
+static const char* parse_null(const char* arg) {
+ if (strcmp(arg, "!") == 0) {
+ return nullptr;
+ } else {
+ return arg;
+ }
+}
+
+int dexopt(const char* const params[DEXOPT_PARAM_COUNT]) {
+ return dexopt(params[0], // apk_path
+ atoi(params[1]), // uid
+ params[2], // pkgname
+ params[3], // instruction_set
+ atoi(params[4]), // dexopt_needed
+ params[5], // oat_dir
+ atoi(params[6]), // dexopt_flags
+ params[7], // compiler_filter
+ parse_null(params[8]), // volume_uuid
+ parse_null(params[9])); // shared_libraries
+ static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param count");
+}
+
+} // namespace installd
+} // namespace android
diff --git a/cmds/installd/dexopt.h b/cmds/installd/dexopt.h
new file mode 100644
index 0000000..1bfef02
--- /dev/null
+++ b/cmds/installd/dexopt.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2016 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 DEXOPT_H_
+#define DEXOPT_H_
+
+#include <sys/types.h>
+
+namespace android {
+namespace installd {
+
+int dexopt(const char *apk_path, uid_t uid, const char *pkgName, const char *instruction_set,
+ int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter,
+ const char* volume_uuid, const char* shared_libraries);
+
+static constexpr size_t DEXOPT_PARAM_COUNT = 10U;
+static_assert(DEXOPT_PARAM_COUNT == 10U, "Unexpected dexopt param size");
+
+// Helper for the above, converting arguments.
+int dexopt(const char* const params[DEXOPT_PARAM_COUNT]);
+
+} // namespace installd
+} // namespace android
+
+#endif // DEXOPT_H_
diff --git a/cmds/installd/globals.h b/cmds/installd/globals.h
index c90beec..8242eec 100644
--- a/cmds/installd/globals.h
+++ b/cmds/installd/globals.h
@@ -20,6 +20,8 @@
#include <inttypes.h>
+#include "InstalldNativeService.h"
+
namespace android {
namespace installd {
diff --git a/cmds/installd/installd.cpp b/cmds/installd/installd.cpp
index 8f883db..6c49aa3 100644
--- a/cmds/installd/installd.cpp
+++ b/cmds/installd/installd.cpp
@@ -20,30 +20,23 @@
#include <sys/capability.h>
#include <sys/fsuid.h>
#include <sys/prctl.h>
-#include <sys/socket.h>
#include <sys/stat.h>
#include <android-base/logging.h>
#include <cutils/fs.h>
#include <cutils/log.h> // TODO: Move everything to base::logging.
#include <cutils/properties.h>
-#include <cutils/sockets.h>
#include <private/android_filesystem_config.h>
-#include <commands.h>
-#include <globals.h>
-#include <installd_constants.h>
-#include <installd_deps.h> // Need to fill in requirements of commands.
-#include <utils.h>
+#include "InstalldNativeService.h"
+#include "globals.h"
+#include "installd_constants.h"
+#include "installd_deps.h" // Need to fill in requirements of commands.
+#include "utils.h"
#ifndef LOG_TAG
#define LOG_TAG "installd"
#endif
-#define SOCKET_PATH "installd"
-
-#define BUFFER_MAX 1024 /* input buffer for commands */
-#define TOKEN_MAX 16 /* max number of arguments in buffer */
-#define REPLY_MAX 256 /* largest reply allowed */
namespace android {
namespace installd {
@@ -65,8 +58,8 @@
const char *oat_dir,
const char *apk_path,
const char *instruction_set) {
- char *file_name_start;
- char *file_name_end;
+ const char *file_name_start;
+ const char *file_name_end;
file_name_start = strrchr(apk_path, '/');
if (file_name_start == NULL) {
@@ -151,12 +144,11 @@
return false;
}
- sprintf(path,"%s%s/%s/%s%s",
+ sprintf(path,"%s%s/%s/%s",
android_data_dir.path,
DALVIK_CACHE,
instruction_set,
- src + 1, /* skip the leading / */
- DALVIK_CACHE_POSTFIX);
+ src + 1 /* skip the leading / */);
char* tmp =
path +
@@ -171,398 +163,10 @@
}
}
+ strcat(path, DALVIK_CACHE_POSTFIX);
return true;
}
-
-static char* parse_null(char* arg) {
- if (strcmp(arg, "!") == 0) {
- return nullptr;
- } else {
- return arg;
- }
-}
-
-static int do_ping(char **arg ATTRIBUTE_UNUSED, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- return 0;
-}
-
-static int do_create_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- /* const char *uuid, const char *pkgname, userid_t userid, int flags,
- appid_t appid, const char* seinfo, int target_sdk_version */
- return create_app_data(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]),
- atoi(arg[4]), arg[5], atoi(arg[6]));
-}
-
-static int do_restorecon_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- /* const char* uuid, const char* pkgName, userid_t userid, int flags,
- appid_t appid, const char* seinfo */
- return restorecon_app_data(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]), atoi(arg[4]), arg[5]);
-}
-
-static int do_migrate_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- /* const char *uuid, const char *pkgname, userid_t userid, int flags */
- return migrate_app_data(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]));
-}
-
-static int do_clear_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- /* const char *uuid, const char *pkgname, userid_t userid, int flags, ino_t ce_data_inode */
- return clear_app_data(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]), atol(arg[4]));
-}
-
-static int do_destroy_app_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- /* const char *uuid, const char *pkgname, userid_t userid, int flags, ino_t ce_data_inode */
- return destroy_app_data(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]), atol(arg[4]));
-}
-
-// We use otapreopt_chroot to get into the chroot.
-static constexpr const char* kOtaPreopt = "/system/bin/otapreopt_chroot";
-
-static int do_ota_dexopt(const char* args[DEXOPT_PARAM_COUNT],
- char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- // Time to fork and run otapreopt.
-
- // Check that the tool exists.
- struct stat s;
- if (stat(kOtaPreopt, &s) != 0) {
- LOG(ERROR) << "Otapreopt chroot tool not found.";
- return -1;
- }
-
- pid_t pid = fork();
- if (pid == 0) {
- const char* argv[1 + DEXOPT_PARAM_COUNT + 1];
- argv[0] = kOtaPreopt;
-
- for (size_t i = 0; i < DEXOPT_PARAM_COUNT; ++i) {
- argv[i + 1] = args[i];
- }
-
- argv[DEXOPT_PARAM_COUNT + 1] = nullptr;
-
- execv(argv[0], (char * const *)argv);
- PLOG(ERROR) << "execv(OTAPREOPT_CHROOT) failed";
- exit(99);
- } else {
- int res = wait_child(pid);
- if (res == 0) {
- ALOGV("DexInv: --- END OTAPREOPT (success) ---\n");
- } else {
- ALOGE("DexInv: --- END OTAPREOPT --- status=0x%04x, process failed\n", res);
- }
- return res;
- }
-}
-
-static int do_regular_dexopt(const char* args[DEXOPT_PARAM_COUNT],
- char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- return dexopt(args);
-}
-
-using DexoptFn = int (*)(const char* args[DEXOPT_PARAM_COUNT],
- char reply[REPLY_MAX]);
-
-static int do_dexopt(char **arg, char reply[REPLY_MAX])
-{
- const char* args[DEXOPT_PARAM_COUNT];
- for (size_t i = 0; i < DEXOPT_PARAM_COUNT; ++i) {
- CHECK(arg[i] != nullptr);
- args[i] = arg[i];
- }
-
- int dexopt_flags = atoi(arg[6]);
- DexoptFn dexopt_fn;
- if ((dexopt_flags & DEXOPT_OTA) != 0) {
- dexopt_fn = do_ota_dexopt;
- } else {
- dexopt_fn = do_regular_dexopt;
- }
- return dexopt_fn(args, reply);
-}
-
-static int do_merge_profiles(char **arg, char reply[REPLY_MAX])
-{
- uid_t uid = static_cast<uid_t>(atoi(arg[0]));
- const char* pkgname = arg[1];
- if (merge_profiles(uid, pkgname)) {
- strncpy(reply, "true", REPLY_MAX);
- } else {
- strncpy(reply, "false", REPLY_MAX);
- }
- return 0;
-}
-
-static int do_dump_profiles(char **arg, char reply[REPLY_MAX])
-{
- uid_t uid = static_cast<uid_t>(atoi(arg[0]));
- const char* pkgname = arg[1];
- const char* dex_files = arg[2];
- if (dump_profile(uid, pkgname, dex_files)) {
- strncpy(reply, "true", REPLY_MAX);
- } else {
- strncpy(reply, "false", REPLY_MAX);
- }
- return 0;
-}
-
-static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- return mark_boot_complete(arg[0] /* instruction set */);
-}
-
-static int do_rm_dex(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- return rm_dex(arg[0], arg[1]); /* pkgname, instruction_set */
-}
-
-static int do_free_cache(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) /* TODO int:free_size */
-{
- return free_cache(parse_null(arg[0]), (int64_t)atoll(arg[1])); /* uuid, free_size */
-}
-
-static int do_get_app_size(char **arg, char reply[REPLY_MAX]) {
- int64_t codesize = 0;
- int64_t datasize = 0;
- int64_t cachesize = 0;
- int64_t asecsize = 0;
- int res = 0;
-
- /* const char *uuid, const char *pkgname, int userid, int flags, ino_t ce_data_inode,
- const char* code_path */
- res = get_app_size(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]), atol(arg[4]),
- arg[5], &codesize, &datasize, &cachesize, &asecsize);
-
- /*
- * Each int64_t can take up 22 characters printed out. Make sure it
- * doesn't go over REPLY_MAX in the future.
- */
- snprintf(reply, REPLY_MAX, "%" PRId64 " %" PRId64 " %" PRId64 " %" PRId64,
- codesize, datasize, cachesize, asecsize);
- return res;
-}
-
-static int do_get_app_data_inode(char **arg, char reply[REPLY_MAX]) {
- ino_t inode = 0;
- int res = 0;
-
- /* const char *uuid, const char *pkgname, int userid, int flags */
- res = get_app_data_inode(parse_null(arg[0]), arg[1], atoi(arg[2]), atoi(arg[3]), &inode);
-
- snprintf(reply, REPLY_MAX, "%" PRId64, (int64_t) inode);
- return res;
-}
-
-static int do_move_complete_app(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- /* const char* from_uuid, const char *to_uuid, const char *package_name,
- const char *data_app_name, appid_t appid, const char* seinfo,
- int target_sdk_version */
- return move_complete_app(parse_null(arg[0]), parse_null(arg[1]), arg[2], arg[3],
- atoi(arg[4]), arg[5], atoi(arg[6]));
-}
-
-static int do_create_user_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- /* const char *uuid, userid_t userid, int user_serial, int flags */
- return create_user_data(parse_null(arg[0]), atoi(arg[1]), atoi(arg[2]), atoi(arg[3]));
-}
-
-static int do_destroy_user_data(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- /* const char *uuid, userid_t userid, int flags */
- return destroy_user_data(parse_null(arg[0]), atoi(arg[1]), atoi(arg[2]));
-}
-
-static int do_linklib(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- return linklib(parse_null(arg[0]), arg[1], arg[2], atoi(arg[3]));
-}
-
-static int do_idmap(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- return idmap(arg[0], arg[1], atoi(arg[2]));
-}
-
-static int do_create_oat_dir(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- /* oat_dir, instruction_set */
- return create_oat_dir(arg[0], arg[1]);
-}
-
-static int do_rm_package_dir(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- /* oat_dir */
- return rm_package_dir(arg[0]);
-}
-
-static int do_clear_app_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- /* package_name */
- return clear_app_profiles(arg[0]);
-}
-
-static int do_destroy_app_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- /* package_name */
- return destroy_app_profiles(arg[0]);
-}
-
-static int do_link_file(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
-{
- /* relative_path, from_base, to_base */
- return link_file(arg[0], arg[1], arg[2]);
-}
-
-static int do_move_ab(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- // apk_path, instruction_set, oat_dir
- return move_ab(arg[0], arg[1], arg[2]);
-}
-
-static int do_delete_odex(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED) {
- // apk_path, instruction_set, oat_dir
- return delete_odex(arg[0], arg[1], arg[2]) ? 0 : -1;
-}
-
-struct cmdinfo {
- const char *name;
- unsigned numargs;
- int (*func)(char **arg, char reply[REPLY_MAX]);
-};
-
-struct cmdinfo cmds[] = {
- { "ping", 0, do_ping },
-
- { "create_app_data", 7, do_create_app_data },
- { "restorecon_app_data", 6, do_restorecon_app_data },
- { "migrate_app_data", 4, do_migrate_app_data },
- { "clear_app_data", 5, do_clear_app_data },
- { "destroy_app_data", 5, do_destroy_app_data },
- { "move_complete_app", 7, do_move_complete_app },
- { "get_app_size", 6, do_get_app_size },
- { "get_app_data_inode", 4, do_get_app_data_inode },
-
- { "create_user_data", 4, do_create_user_data },
- { "destroy_user_data", 3, do_destroy_user_data },
-
- { "dexopt", 10, do_dexopt },
- { "markbootcomplete", 1, do_mark_boot_complete },
- { "rmdex", 2, do_rm_dex },
- { "freecache", 2, do_free_cache },
- { "linklib", 4, do_linklib },
- { "idmap", 3, do_idmap },
- { "createoatdir", 2, do_create_oat_dir },
- { "rmpackagedir", 1, do_rm_package_dir },
- { "clear_app_profiles", 1, do_clear_app_profiles },
- { "destroy_app_profiles", 1, do_destroy_app_profiles },
- { "linkfile", 3, do_link_file },
- { "move_ab", 3, do_move_ab },
- { "merge_profiles", 2, do_merge_profiles },
- { "dump_profiles", 3, do_dump_profiles },
- { "delete_odex", 3, do_delete_odex },
-};
-
-static int readx(int s, void *_buf, int count)
-{
- char *buf = (char *) _buf;
- int n = 0, r;
- if (count < 0) return -1;
- while (n < count) {
- r = read(s, buf + n, count - n);
- if (r < 0) {
- if (errno == EINTR) continue;
- ALOGE("read error: %s\n", strerror(errno));
- return -1;
- }
- if (r == 0) {
- ALOGE("eof\n");
- return -1; /* EOF */
- }
- n += r;
- }
- return 0;
-}
-
-static int writex(int s, const void *_buf, int count)
-{
- const char *buf = (const char *) _buf;
- int n = 0, r;
- if (count < 0) return -1;
- while (n < count) {
- r = write(s, buf + n, count - n);
- if (r < 0) {
- if (errno == EINTR) continue;
- ALOGE("write error: %s\n", strerror(errno));
- return -1;
- }
- n += r;
- }
- return 0;
-}
-
-
-/* Tokenize the command buffer, locate a matching command,
- * ensure that the required number of arguments are provided,
- * call the function(), return the result.
- */
-static int execute(int s, char cmd[BUFFER_MAX])
-{
- char reply[REPLY_MAX];
- char *arg[TOKEN_MAX+1];
- unsigned i;
- unsigned n = 0;
- unsigned short count;
- int ret = -1;
-
- // ALOGI("execute('%s')\n", cmd);
-
- /* default reply is "" */
- reply[0] = 0;
-
- /* n is number of args (not counting arg[0]) */
- arg[0] = cmd;
- while (*cmd) {
- if (isspace(*cmd)) {
- *cmd++ = 0;
- n++;
- arg[n] = cmd;
- if (n == TOKEN_MAX) {
- ALOGE("too many arguments\n");
- goto done;
- }
- }
- if (*cmd) {
- cmd++;
- }
- }
-
- for (i = 0; i < sizeof(cmds) / sizeof(cmds[0]); i++) {
- if (!strcmp(cmds[i].name,arg[0])) {
- if (n != cmds[i].numargs) {
- ALOGE("%s requires %d arguments (%d given)\n",
- cmds[i].name, cmds[i].numargs, n);
- } else {
- ret = cmds[i].func(arg + 1, reply);
- }
- goto done;
- }
- }
- ALOGE("unsupported command '%s'\n", arg[0]);
-
-done:
- if (reply[0]) {
- n = snprintf(cmd, BUFFER_MAX, "%d %s", ret, reply);
- } else {
- n = snprintf(cmd, BUFFER_MAX, "%d", ret);
- }
- if (n > BUFFER_MAX) n = BUFFER_MAX;
- count = n;
-
- // ALOGI("reply: '%s'\n", cmd);
- if (writex(s, &count, sizeof(count))) return -1;
- if (writex(s, cmd, count)) return -1;
- return 0;
-}
-
static bool initialize_globals() {
const char* data_path = getenv("ANDROID_DATA");
if (data_path == nullptr) {
@@ -702,16 +306,13 @@
}
static int installd_main(const int argc ATTRIBUTE_UNUSED, char *argv[]) {
- char buf[BUFFER_MAX];
- struct sockaddr addr;
- socklen_t alen;
- int lsocket, s;
+ int ret;
int selinux_enabled = (is_selinux_enabled() > 0);
setenv("ANDROID_LOG_TAGS", "*:v", 1);
android::base::InitLogging(argv);
- ALOGI("installd firing up\n");
+ LOG(INFO) << "installd firing up";
union selinux_callback cb;
cb.func_log = log_callback;
@@ -732,50 +333,14 @@
exit(1);
}
- lsocket = android_get_control_socket(SOCKET_PATH);
- if (lsocket < 0) {
- ALOGE("Failed to get socket from environment: %s\n", strerror(errno));
+ if ((ret = InstalldNativeService::start()) != android::OK) {
+ ALOGE("Unable to start InstalldNativeService: %d", ret);
exit(1);
}
- if (listen(lsocket, 5)) {
- ALOGE("Listen on socket failed: %s\n", strerror(errno));
- exit(1);
- }
- fcntl(lsocket, F_SETFD, FD_CLOEXEC);
- for (;;) {
- alen = sizeof(addr);
- s = accept(lsocket, &addr, &alen);
- if (s < 0) {
- ALOGE("Accept failed: %s\n", strerror(errno));
- continue;
- }
- fcntl(s, F_SETFD, FD_CLOEXEC);
+ IPCThreadState::self()->joinThreadPool();
- ALOGI("new connection\n");
- for (;;) {
- unsigned short count;
- if (readx(s, &count, sizeof(count))) {
- ALOGE("failed to read size\n");
- break;
- }
- if ((count < 1) || (count >= BUFFER_MAX)) {
- ALOGE("invalid size %d\n", count);
- break;
- }
- if (readx(s, buf, count)) {
- ALOGE("failed to read command\n");
- break;
- }
- buf[count] = 0;
- if (selinux_enabled && selinux_status_updated() > 0) {
- selinux_android_seapp_context_reload();
- }
- if (execute(s, buf)) break;
- }
- ALOGI("closing connection\n");
- close(s);
- }
+ LOG(INFO) << "installd shutting down";
return 0;
}
diff --git a/cmds/installd/installd.rc b/cmds/installd/installd.rc
index 5e4c925..d5d5236 100644
--- a/cmds/installd/installd.rc
+++ b/cmds/installd/installd.rc
@@ -1,3 +1,2 @@
service installd /system/bin/installd
class main
- socket installd stream 600 system system
diff --git a/cmds/installd/installd_constants.h b/cmds/installd/installd_constants.h
index 41732cc..401e581 100644
--- a/cmds/installd/installd_constants.h
+++ b/cmds/installd/installd_constants.h
@@ -28,8 +28,7 @@
// This is used as a string literal, can't be constants. TODO: std::string...
#define DALVIK_CACHE "dalvik-cache"
-constexpr const char* DALVIK_CACHE_POSTFIX = "/classes.dex";
-constexpr const char* DALVIK_CACHE_POSTFIX2 = "@classes.dex";
+constexpr const char* DALVIK_CACHE_POSTFIX = "@classes.dex";
constexpr size_t PKG_NAME_MAX = 128u; /* largest allowed package name */
constexpr size_t PKG_PATH_MAX = 256u; /* max size of any path we use */
@@ -43,7 +42,6 @@
constexpr int DEXOPT_DEBUGGABLE = 1 << 3;
constexpr int DEXOPT_BOOTCOMPLETE = 1 << 4;
constexpr int DEXOPT_PROFILE_GUIDED = 1 << 5;
-constexpr int DEXOPT_OTA = 1 << 6;
/* all known values for dexopt flags */
constexpr int DEXOPT_MASK =
@@ -51,8 +49,7 @@
| DEXOPT_SAFEMODE
| DEXOPT_DEBUGGABLE
| DEXOPT_BOOTCOMPLETE
- | DEXOPT_PROFILE_GUIDED
- | DEXOPT_OTA;
+ | DEXOPT_PROFILE_GUIDED;
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index 5fa972a..d53018f 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -36,13 +36,14 @@
#include <cutils/properties.h>
#include <private/android_filesystem_config.h>
-#include <commands.h>
-#include <file_parsing.h>
-#include <globals.h>
-#include <installd_deps.h> // Need to fill in requirements of commands.
-#include <otapreopt_utils.h>
-#include <system_properties.h>
-#include <utils.h>
+#include "InstalldNativeService.h"
+#include "dexopt.h"
+#include "file_parsing.h"
+#include "globals.h"
+#include "installd_deps.h" // Need to fill in requirements of commands.
+#include "otapreopt_utils.h"
+#include "system_properties.h"
+#include "utils.h"
#ifndef LOG_TAG
#define LOG_TAG "otapreopt"
@@ -823,7 +824,7 @@
DALVIK_CACHE,
instruction_set,
from_src.c_str(),
- DALVIK_CACHE_POSTFIX2);
+ DALVIK_CACHE_POSTFIX);
if (assembled_path.length() + 1 > PKG_PATH_MAX) {
return false;
diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp
index 5ea89e6..cec8f68 100644
--- a/cmds/installd/otapreopt_chroot.cpp
+++ b/cmds/installd/otapreopt_chroot.cpp
@@ -25,8 +25,9 @@
#include <android-base/macros.h>
#include <android-base/stringprintf.h>
-#include <commands.h>
-#include <otapreopt_utils.h>
+#include "installd_constants.h"
+#include "otapreopt_utils.h"
+#include "dexopt.h"
#ifndef LOG_TAG
#define LOG_TAG "otapreopt"
diff --git a/cmds/installd/tests/Android.bp b/cmds/installd/tests/Android.bp
new file mode 100644
index 0000000..a32df22
--- /dev/null
+++ b/cmds/installd/tests/Android.bp
@@ -0,0 +1,16 @@
+// Build the unit tests for installd
+cc_test {
+ name: "installd_utils_test",
+ clang: true,
+ srcs: ["installd_utils_test.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ static_libs: [
+ "libinstalld",
+ "libdiskusage",
+ ],
+}
diff --git a/cmds/installd/tests/Android.mk b/cmds/installd/tests/Android.mk
deleted file mode 100644
index 38a9f69..0000000
--- a/cmds/installd/tests/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Build the unit tests for installd
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-# Build the unit tests.
-test_src_files := \
- installd_utils_test.cpp
-
-shared_libraries := \
- libbase \
- libutils \
- libcutils \
-
-static_libraries := \
- libinstalld \
- libdiskusage \
-
-c_includes := \
- frameworks/native/cmds/installd
-
-$(foreach file,$(test_src_files), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
- $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_C_INCLUDES := $(c_includes)) \
- $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
- $(eval LOCAL_CLANG := true) \
- $(eval include $(BUILD_NATIVE_TEST)) \
-)
diff --git a/cmds/installd/tests/installd_utils_test.cpp b/cmds/installd/tests/installd_utils_test.cpp
index 9b2de88..947cc0d 100644
--- a/cmds/installd/tests/installd_utils_test.cpp
+++ b/cmds/installd/tests/installd_utils_test.cpp
@@ -19,9 +19,9 @@
#include <gtest/gtest.h>
-#include <commands.h>
-#include <globals.h>
-#include <utils.h>
+#include "InstalldNativeService.h"
+#include "globals.h"
+#include "utils.h"
#undef LOG_TAG
#define LOG_TAG "utils_test"
diff --git a/cmds/installd/utils.h b/cmds/installd/utils.h
index 8123e9b..ead73fe 100644
--- a/cmds/installd/utils.h
+++ b/cmds/installd/utils.h
@@ -73,7 +73,6 @@
std::string create_data_path(const char* volume_uuid);
std::string create_data_app_path(const char* volume_uuid);
-
std::string create_data_app_package_path(const char* volume_uuid, const char* package_name);
std::string create_data_user_ce_path(const char* volume_uuid, userid_t userid);
diff --git a/cmds/service/Android.bp b/cmds/service/Android.bp
new file mode 100644
index 0000000..8cffb3c
--- /dev/null
+++ b/cmds/service/Android.bp
@@ -0,0 +1,13 @@
+cc_binary {
+ name: "service",
+
+ srcs: ["service.cpp"],
+
+ shared_libs: [
+ "libutils",
+ "libbinder",
+ ],
+
+ cflags: ["-DXP_UNIX"],
+ //shared_libs: ["librt"],
+}
diff --git a/cmds/service/Android.mk b/cmds/service/Android.mk
deleted file mode 100644
index 275bbb2..0000000
--- a/cmds/service/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- service.cpp
-
-LOCAL_SHARED_LIBRARIES := libutils libbinder
-
-ifeq ($(TARGET_OS),linux)
- LOCAL_CFLAGS += -DXP_UNIX
- #LOCAL_SHARED_LIBRARIES += librt
-endif
-
-LOCAL_MODULE:= service
-
-include $(BUILD_EXECUTABLE)
diff --git a/cmds/servicemanager/Android.bp b/cmds/servicemanager/Android.bp
new file mode 100644
index 0000000..dc8e675
--- /dev/null
+++ b/cmds/servicemanager/Android.bp
@@ -0,0 +1,36 @@
+cc_defaults {
+ name: "servicemanager_flags",
+
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ product_variables: {
+ binder32bit: {
+ cflags: ["-DBINDER_IPC_32BIT=1"],
+ },
+ },
+
+ shared_libs: ["liblog"],
+}
+
+cc_binary {
+ name: "bctest",
+ defaults: ["servicemanager_flags"],
+ srcs: [
+ "bctest.c",
+ "binder.c",
+ ],
+}
+
+cc_binary {
+ name: "servicemanager",
+ defaults: ["servicemanager_flags"],
+ srcs: [
+ "service_manager.c",
+ "binder.c",
+ ],
+ shared_libs: ["libcutils", "libselinux"],
+ init_rc: ["servicemanager.rc"],
+}
diff --git a/cmds/servicemanager/Android.mk b/cmds/servicemanager/Android.mk
deleted file mode 100644
index b214f19..0000000
--- a/cmds/servicemanager/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-svc_c_flags = \
- -Wall -Wextra -Werror \
-
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-svc_c_flags += -DBINDER_IPC_32BIT=1
-endif
-endif
-
-include $(CLEAR_VARS)
-LOCAL_SHARED_LIBRARIES := liblog
-LOCAL_SRC_FILES := bctest.c binder.c
-LOCAL_CFLAGS += $(svc_c_flags)
-LOCAL_MODULE := bctest
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SHARED_LIBRARIES := liblog libcutils libselinux
-LOCAL_SRC_FILES := service_manager.c binder.c
-LOCAL_CFLAGS += $(svc_c_flags)
-LOCAL_MODULE := servicemanager
-LOCAL_INIT_RC := servicemanager.rc
-include $(BUILD_EXECUTABLE)
diff --git a/cmds/servicemanager/binder.h b/cmds/servicemanager/binder.h
index 7915fc2..881ab07 100644
--- a/cmds/servicemanager/binder.h
+++ b/cmds/servicemanager/binder.h
@@ -5,7 +5,7 @@
#define _BINDER_H_
#include <sys/ioctl.h>
-#include <linux/binder.h>
+#include <linux/android/binder.h>
struct binder_state;
diff --git a/data/etc/android.hardware.wifi.nan.xml b/data/etc/android.hardware.wifi.aware.xml
similarity index 90%
rename from data/etc/android.hardware.wifi.nan.xml
rename to data/etc/android.hardware.wifi.aware.xml
index e557610..ae6272e 100644
--- a/data/etc/android.hardware.wifi.nan.xml
+++ b/data/etc/android.hardware.wifi.aware.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<!-- This is the standard feature indicating that the device includes WiFi NAN. -->
+<!-- This is the standard feature indicating that the device includes WiFi Aware. -->
<permissions>
- <feature name="android.hardware.wifi.nan" />
+ <feature name="android.hardware.wifi.aware" />
</permissions>
diff --git a/include/android/asset_manager.h b/include/android/asset_manager.h
index d654839..7ef3ecb 100644
--- a/include/android/asset_manager.h
+++ b/include/android/asset_manager.h
@@ -26,6 +26,9 @@
#ifndef ANDROID_ASSET_MANAGER_H
#define ANDROID_ASSET_MANAGER_H
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -131,6 +134,7 @@
*/
off_t AAsset_seek(AAsset* asset, off_t offset, int whence);
+#if __ANDROID_API__ >= 13
/**
* Seek to the specified offset within the asset data. 'whence' uses the
* same constants as lseek()/fseek().
@@ -141,6 +145,7 @@
* Returns the new position on success, or (off64_t) -1 on error.
*/
off64_t AAsset_seek64(AAsset* asset, off64_t offset, int whence);
+#endif
/**
* Close the asset, freeing all associated resources.
@@ -159,23 +164,27 @@
*/
off_t AAsset_getLength(AAsset* asset);
+#if __ANDROID_API__ >= 13
/**
* 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);
+#endif
/**
* Report the total amount of asset data that can be read from the current position.
*/
off_t AAsset_getRemainingLength(AAsset* asset);
+#if __ANDROID_API__ >= 13
/**
* 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);
+#endif
/**
* Open a new file descriptor that can be used to read the asset data. If the
@@ -187,6 +196,7 @@
*/
int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength);
+#if __ANDROID_API__ >= 13
/**
* Open a new file descriptor that can be used to read the asset data.
*
@@ -197,6 +207,7 @@
* compressed).
*/
int AAsset_openFileDescriptor64(AAsset* asset, off64_t* outStart, off64_t* outLength);
+#endif
/**
* Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not
diff --git a/include/android/choreographer.h b/include/android/choreographer.h
index 02c83dc..43346fe 100644
--- a/include/android/choreographer.h
+++ b/include/android/choreographer.h
@@ -30,6 +30,8 @@
__BEGIN_DECLS
+#if __ANDROID_API__ >= 24
+
struct AChoreographer;
typedef struct AChoreographer AChoreographer;
@@ -62,6 +64,9 @@
*/
void AChoreographer_postFrameCallbackDelayed(AChoreographer* choreographer,
AChoreographer_frameCallback callback, void* data, long delayMillis);
+
+#endif /* __ANDROID_API__ >= 24 */
+
__END_DECLS
#endif // ANDROID_CHOREOGRAPHER_H
diff --git a/include/android/configuration.h b/include/android/configuration.h
index 81f71a9..8e10f67 100644
--- a/include/android/configuration.h
+++ b/include/android/configuration.h
@@ -26,6 +26,8 @@
#ifndef ANDROID_CONFIGURATION_H
#define ANDROID_CONFIGURATION_H
+#include <sys/cdefs.h>
+
#include <android/asset_manager.h>
#ifdef __cplusplus
@@ -628,6 +630,7 @@
*/
void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight);
+#if __ANDROID_API__ >= 13
/**
* Return the current configuration screen width in dp units, or
* ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set.
@@ -660,7 +663,9 @@
* Set the configuration's smallest screen width in dp units.
*/
void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value);
+#endif /* __ANDROID_API__ >= 13 */
+#if __ANDROID_API__ >= 17
/**
* Return the configuration's layout direction, or
* ACONFIGURATION_LAYOUTDIR_ANY if not set.
@@ -671,6 +676,7 @@
* Set the configuration's layout direction.
*/
void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value);
+#endif /* __ANDROID_API__ >= 17 */
/**
* Perform a diff between two configurations. Returns a bit mask of
diff --git a/include/android/input.h b/include/android/input.h
index fd9fa98..f928c6e 100644
--- a/include/android/input.h
+++ b/include/android/input.h
@@ -26,6 +26,8 @@
#ifndef _ANDROID_INPUT_H
#define _ANDROID_INPUT_H
+#include <sys/cdefs.h>
+
/******************************************************************
*
* IMPORTANT NOTICE:
@@ -978,8 +980,10 @@
*/
int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event);
+#if __ANDROID_API__ >= 14
/** Get the button state of all buttons that are pressed. */
int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event);
+#endif
/**
* Get a bitfield indicating which edges, if any, were touched by this motion event.
@@ -1044,12 +1048,14 @@
*/
int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index);
+#if __ANDROID_API__ >= 14
/**
* 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);
+#endif
/**
* Get the original raw X coordinate of this event.
@@ -1139,9 +1145,11 @@
*/
float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index);
+#if __ANDROID_API__ >= 13
/** 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);
+#endif
/**
* Get the number of historical points in this event. These are movements that
@@ -1272,12 +1280,14 @@
float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index,
size_t history_index);
+#if __ANDROID_API__ >= 13
/**
* 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);
+#endif
struct AInputQueue;
diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h
index 6c718c9..be01518 100644
--- a/include/android/multinetwork.h
+++ b/include/android/multinetwork.h
@@ -51,6 +51,7 @@
* on failure with an appropriate errno value set.
*/
+#if __ANDROID_API__ >= 24
/**
* Set the network to be used by the given socket file descriptor.
@@ -104,6 +105,8 @@
const char *node, const char *service,
const struct addrinfo *hints, struct addrinfo **res);
+#endif /* __ANDROID_API__ >= 24 */
+
__END_DECLS
#endif // ANDROID_MULTINETWORK_H
diff --git a/include/android/native_window.h b/include/android/native_window.h
index cf07f1a..b60b9f1 100644
--- a/include/android/native_window.h
+++ b/include/android/native_window.h
@@ -26,6 +26,8 @@
#ifndef ANDROID_NATIVE_WINDOW_H
#define ANDROID_NATIVE_WINDOW_H
+#include <sys/cdefs.h>
+
#include <android/rect.h>
#ifdef __cplusplus
diff --git a/include/android/native_window_jni.h b/include/android/native_window_jni.h
index 60a36c3..1ec2a67 100644
--- a/include/android/native_window_jni.h
+++ b/include/android/native_window_jni.h
@@ -26,6 +26,8 @@
#ifndef ANDROID_NATIVE_WINDOW_JNI_H
#define ANDROID_NATIVE_WINDOW_JNI_H
+#include <sys/cdefs.h>
+
#include <android/native_window.h>
#include <jni.h>
@@ -42,6 +44,16 @@
*/
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);
+#if __ANDROID_API__ >= 13
+/**
+ * Return the ANativeWindow associated with a Java SurfaceTexture 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_fromSurfaceTexture(JNIEnv* env, jobject surfaceTexture);
+#endif
+
#ifdef __cplusplus
};
#endif
diff --git a/include/android/sensor.h b/include/android/sensor.h
index 5a61213..b6a42ae 100644
--- a/include/android/sensor.h
+++ b/include/android/sensor.h
@@ -367,12 +367,14 @@
*/
ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type);
+#if __ANDROID_API__ >= 21
/**
* 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);
+#endif
/**
* Creates a new sensor event queue and associate it with a looper.
@@ -471,6 +473,7 @@
*/
int ASensor_getMinDelay(ASensor const* sensor);
+#if __ANDROID_API__ >= 21
/**
* Returns the maximum size of batches for this sensor. Batches will often be
* smaller, as the hardware fifo might be used for other sensors.
@@ -496,6 +499,7 @@
* Returns true if this is a wake up sensor, false otherwise.
*/
bool ASensor_isWakeUpSensor(ASensor const* sensor);
+#endif /* __ANDROID_API__ >= 21 */
#ifdef __cplusplus
};
diff --git a/include/android/trace.h b/include/android/trace.h
index e42e334..6cdcfeb 100644
--- a/include/android/trace.h
+++ b/include/android/trace.h
@@ -19,11 +19,14 @@
#define ANDROID_NATIVE_TRACE_H
#include <stdbool.h>
+#include <sys/cdefs.h>
#ifdef __cplusplus
extern "C" {
#endif
+#if __ANDROID_API__ >= 23
+
/**
* Returns true if tracing is enabled. Use this signal to avoid expensive computation only necessary
* when tracing is enabled.
@@ -48,6 +51,8 @@
*/
void ATrace_endSection();
+#endif /* __ANDROID_API__ >= 23 */
+
#ifdef __cplusplus
};
#endif
diff --git a/include/batteryservice/IBatteryPropertiesListener.h b/include/batteryservice/IBatteryPropertiesListener.h
index b02d8e9..9154076 100644
--- a/include/batteryservice/IBatteryPropertiesListener.h
+++ b/include/batteryservice/IBatteryPropertiesListener.h
@@ -33,7 +33,7 @@
class IBatteryPropertiesListener : public IInterface {
public:
- DECLARE_META_INTERFACE(BatteryPropertiesListener);
+ DECLARE_META_INTERFACE(BatteryPropertiesListener)
virtual void batteryPropertiesChanged(struct BatteryProperties props) = 0;
};
diff --git a/include/batteryservice/IBatteryPropertiesRegistrar.h b/include/batteryservice/IBatteryPropertiesRegistrar.h
index eca075d..b5c3a4d 100644
--- a/include/batteryservice/IBatteryPropertiesRegistrar.h
+++ b/include/batteryservice/IBatteryPropertiesRegistrar.h
@@ -31,7 +31,7 @@
class IBatteryPropertiesRegistrar : public IInterface {
public:
- DECLARE_META_INTERFACE(BatteryPropertiesRegistrar);
+ DECLARE_META_INTERFACE(BatteryPropertiesRegistrar)
virtual void registerListener(const sp<IBatteryPropertiesListener>& listener) = 0;
virtual void unregisterListener(const sp<IBatteryPropertiesListener>& listener) = 0;
diff --git a/include/binder/Binder.h b/include/binder/Binder.h
index f849fd4..3404881 100644
--- a/include/binder/Binder.h
+++ b/include/binder/Binder.h
@@ -80,7 +80,7 @@
class BpRefBase : public virtual RefBase
{
protected:
- BpRefBase(const sp<IBinder>& o);
+ explicit BpRefBase(const sp<IBinder>& o);
virtual ~BpRefBase();
virtual void onFirstRef();
virtual void onLastStrongRef(const void* id);
diff --git a/include/binder/IAppOpsCallback.h b/include/binder/IAppOpsCallback.h
index 7f8eb01..b62e9e2 100644
--- a/include/binder/IAppOpsCallback.h
+++ b/include/binder/IAppOpsCallback.h
@@ -27,7 +27,7 @@
class IAppOpsCallback : public IInterface
{
public:
- DECLARE_META_INTERFACE(AppOpsCallback);
+ DECLARE_META_INTERFACE(AppOpsCallback)
virtual void opChanged(int32_t op, const String16& packageName) = 0;
diff --git a/include/binder/IAppOpsService.h b/include/binder/IAppOpsService.h
index cd81efa..dc18045 100644
--- a/include/binder/IAppOpsService.h
+++ b/include/binder/IAppOpsService.h
@@ -28,7 +28,7 @@
class IAppOpsService : public IInterface
{
public:
- DECLARE_META_INTERFACE(AppOpsService);
+ 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;
diff --git a/include/binder/IBatteryStats.h b/include/binder/IBatteryStats.h
index 5f38186..e15d6f0 100644
--- a/include/binder/IBatteryStats.h
+++ b/include/binder/IBatteryStats.h
@@ -26,7 +26,7 @@
class IBatteryStats : public IInterface
{
public:
- DECLARE_META_INTERFACE(BatteryStats);
+ DECLARE_META_INTERFACE(BatteryStats)
virtual void noteStartSensor(int uid, int sensor) = 0;
virtual void noteStopSensor(int uid, int sensor) = 0;
diff --git a/include/binder/IBinder.h b/include/binder/IBinder.h
index 5f1e87c..9097cb3 100644
--- a/include/binder/IBinder.h
+++ b/include/binder/IBinder.h
@@ -90,12 +90,24 @@
Parcel* reply,
uint32_t flags = 0) = 0;
+ // DeathRecipient is pure abstract, there is no virtual method
+ // implementation to put in a translation unit in order to silence the
+ // weak vtables warning.
+ #if defined(__clang__)
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wweak-vtables"
+ #endif
+
class DeathRecipient : public virtual RefBase
{
public:
virtual void binderDied(const wp<IBinder>& who) = 0;
};
+ #if defined(__clang__)
+ #pragma clang diagnostic pop
+ #endif
+
/**
* Register the @a recipient for a notification if this binder
* goes away. If this binder object unexpectedly goes away
diff --git a/include/binder/IInterface.h b/include/binder/IInterface.h
index 4ce3613..be72d44 100644
--- a/include/binder/IInterface.h
+++ b/include/binder/IInterface.h
@@ -63,7 +63,7 @@
class BpInterface : public INTERFACE, public BpRefBase
{
public:
- BpInterface(const sp<IBinder>& remote);
+ explicit BpInterface(const sp<IBinder>& remote);
protected:
virtual IBinder* onAsBinder();
@@ -105,7 +105,7 @@
#define CHECK_INTERFACE(interface, data, reply) \
- if (!data.checkInterface(this)) { return PERMISSION_DENIED; } \
+ if (!(data).checkInterface(this)) { return PERMISSION_DENIED; } \
// ----------------------------------------------------------------------
diff --git a/include/binder/IMediaResourceMonitor.h b/include/binder/IMediaResourceMonitor.h
index c671f7a..b21047f 100644
--- a/include/binder/IMediaResourceMonitor.h
+++ b/include/binder/IMediaResourceMonitor.h
@@ -25,7 +25,7 @@
class IMediaResourceMonitor : public IInterface {
public:
- DECLARE_META_INTERFACE(MediaResourceMonitor);
+ DECLARE_META_INTERFACE(MediaResourceMonitor)
// Values should be in sync with Intent.EXTRA_MEDIA_RESOURCE_TYPE_XXX.
enum {
diff --git a/include/binder/IMemory.h b/include/binder/IMemory.h
index 2d0db00..15a104f 100644
--- a/include/binder/IMemory.h
+++ b/include/binder/IMemory.h
@@ -32,7 +32,7 @@
class IMemoryHeap : public IInterface
{
public:
- DECLARE_META_INTERFACE(MemoryHeap);
+ DECLARE_META_INTERFACE(MemoryHeap)
// flags returned by getFlags()
enum {
@@ -70,7 +70,7 @@
class IMemory : public IInterface
{
public:
- DECLARE_META_INTERFACE(Memory);
+ DECLARE_META_INTERFACE(Memory)
virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const = 0;
diff --git a/include/binder/IPermissionController.h b/include/binder/IPermissionController.h
index 4e5fb34..25f3431 100644
--- a/include/binder/IPermissionController.h
+++ b/include/binder/IPermissionController.h
@@ -28,7 +28,7 @@
class IPermissionController : public IInterface
{
public:
- DECLARE_META_INTERFACE(PermissionController);
+ DECLARE_META_INTERFACE(PermissionController)
virtual bool checkPermission(const String16& permission, int32_t pid, int32_t uid) = 0;
diff --git a/include/binder/IProcessInfoService.h b/include/binder/IProcessInfoService.h
index 69dc9a7..2669f91 100644
--- a/include/binder/IProcessInfoService.h
+++ b/include/binder/IProcessInfoService.h
@@ -25,7 +25,7 @@
class IProcessInfoService : public IInterface {
public:
- DECLARE_META_INTERFACE(ProcessInfoService);
+ DECLARE_META_INTERFACE(ProcessInfoService)
virtual status_t getProcessStatesFromPids( size_t length,
/*in*/ int32_t* pids,
diff --git a/include/binder/IResultReceiver.h b/include/binder/IResultReceiver.h
index 02dc6a6..e494fba 100644
--- a/include/binder/IResultReceiver.h
+++ b/include/binder/IResultReceiver.h
@@ -27,7 +27,7 @@
class IResultReceiver : public IInterface
{
public:
- DECLARE_META_INTERFACE(ResultReceiver);
+ DECLARE_META_INTERFACE(ResultReceiver)
virtual void send(int32_t resultCode) = 0;
diff --git a/include/binder/IServiceManager.h b/include/binder/IServiceManager.h
index 7ccd9fe..3b23f81 100644
--- a/include/binder/IServiceManager.h
+++ b/include/binder/IServiceManager.h
@@ -30,7 +30,7 @@
class IServiceManager : public IInterface
{
public:
- DECLARE_META_INTERFACE(ServiceManager);
+ DECLARE_META_INTERFACE(ServiceManager)
/**
* Retrieve an existing service, blocking for a few seconds
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index 2490b82..b0d53ef 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -20,14 +20,14 @@
#include <string>
#include <vector>
+#include <android-base/unique_fd.h>
#include <cutils/native_handle.h>
-#include <nativehelper/ScopedFd.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
#include <utils/String16.h>
#include <utils/Vector.h>
#include <utils/Flattenable.h>
-#include <linux/binder.h>
+#include <linux/android/binder.h>
#include <binder/IInterface.h>
#include <binder/Parcelable.h>
@@ -166,6 +166,10 @@
template<typename T>
status_t write(const LightFlattenable<T>& val);
+ template<typename T>
+ status_t writeVectorSize(const std::vector<T>& val);
+ template<typename T>
+ status_t writeVectorSize(const std::unique_ptr<std::vector<T>>& 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
@@ -186,14 +190,14 @@
// semantics of the smart file descriptor. A new descriptor will be
// created, and will be closed when the parcel is destroyed.
status_t writeUniqueFileDescriptor(
- const ScopedFd& fd);
+ const base::unique_fd& fd);
// Place a vector of file desciptors into the parcel. Each descriptor is
// dup'd as in writeDupFileDescriptor
status_t writeUniqueFileDescriptorVector(
- const std::unique_ptr<std::vector<ScopedFd>>& val);
+ const std::unique_ptr<std::vector<base::unique_fd>>& val);
status_t writeUniqueFileDescriptorVector(
- const std::vector<ScopedFd>& val);
+ const std::vector<base::unique_fd>& val);
// Writes a blob to the parcel.
// If the blob is small, then it is stored in-place, otherwise it is
@@ -246,12 +250,14 @@
const char* readCString() const;
String8 readString8() const;
+ status_t readString8(String8* pArg) const;
String16 readString16() const;
status_t readString16(String16* pArg) const;
status_t readString16(std::unique_ptr<String16>* pArg) const;
const char16_t* readString16Inplace(size_t* outLen) const;
sp<IBinder> readStrongBinder() const;
status_t readStrongBinder(sp<IBinder>* val) const;
+ status_t readNullableStrongBinder(sp<IBinder>* val) const;
wp<IBinder> readWeakBinder() const;
template<typename T>
@@ -268,6 +274,9 @@
template<typename T>
status_t readStrongBinder(sp<T>* val) const;
+ template<typename T>
+ status_t readNullableStrongBinder(sp<T>* val) const;
+
status_t readStrongBinderVector(std::unique_ptr<std::vector<sp<IBinder>>>* val) const;
status_t readStrongBinderVector(std::vector<sp<IBinder>>* val) const;
@@ -300,6 +309,11 @@
template<typename T>
status_t read(LightFlattenable<T>& val) const;
+ template<typename T>
+ status_t resizeOutVector(std::vector<T>* val) const;
+ template<typename T>
+ status_t resizeOutVector(std::unique_ptr<std::vector<T>>* 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
@@ -320,14 +334,14 @@
// Retrieve a smart file descriptor from the parcel.
status_t readUniqueFileDescriptor(
- ScopedFd* val) const;
+ base::unique_fd* val) const;
// Retrieve a vector of smart file descriptors from the parcel.
status_t readUniqueFileDescriptorVector(
- std::unique_ptr<std::vector<ScopedFd>>* val) const;
+ std::unique_ptr<std::vector<base::unique_fd>>* val) const;
status_t readUniqueFileDescriptorVector(
- std::vector<ScopedFd>* val) const;
+ std::vector<base::unique_fd>* val) const;
// Reads a blob from the parcel.
// The caller should call release() on the blob after reading its contents.
@@ -437,7 +451,7 @@
void clear();
void release();
inline size_t size() const { return mSize; }
- inline int fd() const { return mFd; };
+ inline int fd() const { return mFd; }
inline bool isMutable() const { return mMutable; }
protected:
@@ -449,6 +463,11 @@
bool mMutable;
};
+ #if defined(__clang__)
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wweak-vtables"
+ #endif
+
class FlattenableHelperInterface {
protected:
~FlattenableHelperInterface() { }
@@ -459,12 +478,18 @@
virtual status_t unflatten(void const* buffer, size_t size, int const* fds, size_t count) = 0;
};
+ #if defined(__clang__)
+ #pragma clang diagnostic pop
+ #endif
+
template<typename T>
class FlattenableHelper : public FlattenableHelperInterface {
friend class Parcel;
const Flattenable<T>& val;
- explicit FlattenableHelper(const Flattenable<T>& val) : val(val) { }
+ explicit FlattenableHelper(const Flattenable<T>& _val) : val(_val) { }
+ protected:
+ ~FlattenableHelper() = default;
public:
virtual size_t getFlattenedSize() const {
return val.getFlattenedSize();
@@ -517,7 +542,10 @@
status_t Parcel::write(const LightFlattenable<T>& val) {
size_t size(val.getFlattenedSize());
if (!val.isFixedSize()) {
- status_t err = writeInt32(size);
+ if (size > INT32_MAX) {
+ return BAD_VALUE;
+ }
+ status_t err = writeInt32(static_cast<int32_t>(size));
if (err != NO_ERROR) {
return err;
}
@@ -548,7 +576,7 @@
if (err != NO_ERROR) {
return err;
}
- size = s;
+ size = static_cast<size_t>(s);
}
if (size) {
void const* buffer = readInplace(size);
@@ -559,6 +587,54 @@
}
template<typename T>
+status_t Parcel::writeVectorSize(const std::vector<T>& val) {
+ if (val.size() > INT32_MAX) {
+ return BAD_VALUE;
+ }
+ return writeInt32(static_cast<int32_t>(val.size()));
+}
+
+template<typename T>
+status_t Parcel::writeVectorSize(const std::unique_ptr<std::vector<T>>& val) {
+ if (!val) {
+ return writeInt32(-1);
+ }
+
+ return writeVectorSize(*val);
+}
+
+template<typename T>
+status_t Parcel::resizeOutVector(std::vector<T>* val) const {
+ int32_t size;
+ status_t err = readInt32(&size);
+ if (err != NO_ERROR) {
+ return err;
+ }
+
+ if (size < 0) {
+ return UNEXPECTED_NULL;
+ }
+ val->resize(size_t(size));
+ return OK;
+}
+
+template<typename T>
+status_t Parcel::resizeOutVector(std::unique_ptr<std::vector<T>>* val) const {
+ int32_t size;
+ status_t err = readInt32(&size);
+ if (err != NO_ERROR) {
+ return err;
+ }
+
+ val->reset();
+ if (size >= 0) {
+ val->reset(new std::vector<T>(size_t(size)));
+ }
+
+ return OK;
+}
+
+template<typename T>
status_t Parcel::readStrongBinder(sp<T>* val) const {
sp<IBinder> tmp;
status_t ret = readStrongBinder(&tmp);
@@ -574,6 +650,22 @@
return ret;
}
+template<typename T>
+status_t Parcel::readNullableStrongBinder(sp<T>* val) const {
+ sp<IBinder> tmp;
+ status_t ret = readNullableStrongBinder(&tmp);
+
+ if (ret == OK) {
+ *val = interface_cast<T>(tmp);
+
+ if (val->get() == nullptr && tmp.get() != nullptr) {
+ ret = UNKNOWN_ERROR;
+ }
+ }
+
+ return ret;
+}
+
template<typename T, typename U>
status_t Parcel::unsafeReadTypedVector(
std::vector<T>* val,
@@ -589,13 +681,13 @@
return UNEXPECTED_NULL;
}
- if (val->max_size() < size) {
+ if (val->max_size() < static_cast<size_t>(size)) {
return NO_MEMORY;
}
- val->resize(size);
+ val->resize(static_cast<size_t>(size));
- if (val->size() < size) {
+ if (val->size() < static_cast<size_t>(size)) {
return NO_MEMORY;
}
@@ -619,7 +711,7 @@
template<typename T>
status_t Parcel::readNullableTypedVector(std::unique_ptr<std::vector<T>>* val,
status_t(Parcel::*read_func)(T*) const) const {
- const int32_t start = dataPosition();
+ const size_t start = dataPosition();
int32_t size;
status_t status = readInt32(&size);
val->reset();
@@ -647,7 +739,7 @@
return BAD_VALUE;
}
- status_t status = this->writeInt32(val.size());
+ status_t status = this->writeInt32(static_cast<int32_t>(val.size()));
if (status != OK) {
return status;
@@ -703,7 +795,7 @@
template<typename T>
status_t Parcel::readParcelableVector(std::unique_ptr<std::vector<std::unique_ptr<T>>>* val) const {
- const int32_t start = dataPosition();
+ const size_t start = dataPosition();
int32_t size;
status_t status = readInt32(&size);
val->reset();
@@ -726,7 +818,7 @@
template<typename T>
status_t Parcel::readParcelable(std::unique_ptr<T>* parcelable) const {
- const int32_t start = dataPosition();
+ const size_t start = dataPosition();
int32_t present;
status_t status = readInt32(&present);
parcelable->reset();
diff --git a/include/binder/Parcelable.h b/include/binder/Parcelable.h
index faf0d34..d5b57ac 100644
--- a/include/binder/Parcelable.h
+++ b/include/binder/Parcelable.h
@@ -26,6 +26,11 @@
class Parcel;
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wweak-vtables"
+#endif
+
// Abstract interface of all parcelables.
class Parcelable {
public:
@@ -46,6 +51,10 @@
virtual status_t readFromParcel(const Parcel* parcel) = 0;
}; // class Parcelable
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
} // namespace android
#endif // ANDROID_PARCELABLE_H
diff --git a/include/binder/PersistableBundle.h b/include/binder/PersistableBundle.h
index fe5619f..322fef9 100644
--- a/include/binder/PersistableBundle.h
+++ b/include/binder/PersistableBundle.h
@@ -18,6 +18,7 @@
#define ANDROID_PERSISTABLE_BUNDLE_H
#include <map>
+#include <set>
#include <vector>
#include <binder/Parcelable.h>
@@ -79,6 +80,19 @@
bool getStringVector(const String16& key, std::vector<String16>* out) const;
bool getPersistableBundle(const String16& key, PersistableBundle* out) const;
+ /* Getters for all keys for each value type */
+ std::set<String16> getBooleanKeys() const;
+ std::set<String16> getIntKeys() const;
+ std::set<String16> getLongKeys() const;
+ std::set<String16> getDoubleKeys() const;
+ std::set<String16> getStringKeys() const;
+ std::set<String16> getBooleanVectorKeys() const;
+ std::set<String16> getIntVectorKeys() const;
+ std::set<String16> getLongVectorKeys() const;
+ std::set<String16> getDoubleVectorKeys() const;
+ std::set<String16> getStringVectorKeys() const;
+ std::set<String16> getPersistableBundleKeys() const;
+
friend bool operator==(const PersistableBundle& lhs, const PersistableBundle& rhs) {
return (lhs.mBoolMap == rhs.mBoolMap && lhs.mIntMap == rhs.mIntMap &&
lhs.mLongMap == rhs.mLongMap && lhs.mDoubleMap == rhs.mDoubleMap &&
diff --git a/include/binder/Status.h b/include/binder/Status.h
index ce947fa..dd61616 100644
--- a/include/binder/Status.h
+++ b/include/binder/Status.h
@@ -18,6 +18,7 @@
#define ANDROID_BINDER_STATUS_H
#include <cstdint>
+#include <sstream>
#include <binder/Parcel.h>
#include <utils/String8.h>
@@ -71,6 +72,7 @@
// A more readable alias for the default constructor.
static Status ok();
+
// Authors should explicitly pick whether their integer is:
// - an exception code (EX_* above)
// - service specific error code
@@ -83,9 +85,15 @@
static Status fromExceptionCode(int32_t exceptionCode);
static Status fromExceptionCode(int32_t exceptionCode,
const String8& message);
+ static Status fromExceptionCode(int32_t exceptionCode,
+ const char* message);
+
static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode);
static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode,
const String8& message);
+ static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode,
+ const char* message);
+
static Status fromStatusT(status_t status);
Status() = default;
@@ -142,11 +150,7 @@
}; // class Status
// For gtest output logging
-template<typename T>
-T& operator<< (T& stream, const Status& s) {
- stream << s.toString8().string();
- return stream;
-}
+std::stringstream& operator<< (std::stringstream& stream, const Status& s);
} // namespace binder
} // namespace android
diff --git a/include/binder/TextOutput.h b/include/binder/TextOutput.h
index 974a194..851e01f 100644
--- a/include/binder/TextOutput.h
+++ b/include/binder/TextOutput.h
@@ -18,16 +18,15 @@
#define ANDROID_TEXTOUTPUT_H
#include <utils/Errors.h>
+#include <utils/String8.h>
#include <stdint.h>
#include <string.h>
+#include <sstream>
// ---------------------------------------------------------------------------
namespace android {
-class String8;
-class String16;
-
class TextOutput
{
public:
@@ -66,30 +65,26 @@
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);
+template<typename T>
+TextOutput& operator<<(TextOutput& to, const T& val)
+{
+ std::stringstream strbuf;
+ strbuf << val;
+ std::string str = strbuf.str();
+ to.print(str.c_str(), str.size());
+ return to;
+}
-class TypeCode
+TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func);
+
+class TypeCode
{
public:
inline TypeCode(uint32_t code);
inline ~TypeCode();
inline uint32_t typeCode() const;
-
+
private:
uint32_t mCode;
};
@@ -124,6 +119,32 @@
};
TextOutput& operator<<(TextOutput& to, const HexDump& val);
+inline TextOutput& operator<<(TextOutput& to,
+ decltype(std::endl<char,
+ std::char_traits<char>>)
+ /*val*/) {
+ endl(to);
+ return to;
+}
+
+inline TextOutput& operator<<(TextOutput& to, const char &c)
+{
+ to.print(&c, 1);
+ return to;
+}
+
+inline TextOutput& operator<<(TextOutput& to, const bool &val)
+{
+ if (val) to.print("true", 4);
+ else to.print("false", 5);
+ return to;
+}
+
+inline TextOutput& operator<<(TextOutput& to, const String16& val)
+{
+ to << String8(val).string();
+ return to;
+}
// ---------------------------------------------------------------------------
// No user servicable parts below.
@@ -146,18 +167,6 @@
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);
diff --git a/include/gui/BufferItem.h b/include/gui/BufferItem.h
index f45d852..5232d0f 100644
--- a/include/gui/BufferItem.h
+++ b/include/gui/BufferItem.h
@@ -46,6 +46,8 @@
enum { INVALID_BUFFER_SLOT = -1 };
BufferItem();
~BufferItem();
+ BufferItem(const BufferItem&) = default;
+ BufferItem& operator=(const BufferItem&) = default;
static const char* scalingModeName(uint32_t scalingMode);
@@ -72,13 +74,7 @@
// 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;
- };
- };
+ int64_t mTimestamp;
// mIsAutoTimestamp indicates whether mTimestamp was generated
// automatically when the buffer was queued.
@@ -90,13 +86,7 @@
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;
- };
- };
+ uint64_t mFrameNumber;
// mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
int mSlot;
diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h
index fe4b1fa..266f0aa 100644
--- a/include/gui/BufferQueue.h
+++ b/include/gui/BufferQueue.h
@@ -60,7 +60,7 @@
// weak references.
class ProxyConsumerListener : public BnConsumerListener {
public:
- ProxyConsumerListener(const wp<ConsumerListener>& consumerListener);
+ explicit ProxyConsumerListener(const wp<ConsumerListener>& consumerListener);
virtual ~ProxyConsumerListener();
virtual void onFrameAvailable(const BufferItem& item) override;
virtual void onFrameReplaced(const BufferItem& item) override;
diff --git a/include/gui/BufferQueueConsumer.h b/include/gui/BufferQueueConsumer.h
index 8ec0546..e2bafec 100644
--- a/include/gui/BufferQueueConsumer.h
+++ b/include/gui/BufferQueueConsumer.h
@@ -144,7 +144,7 @@
virtual status_t discardFreeBuffers() override;
// dump our state in a String
- virtual void dump(String8& result, const char* prefix) const;
+ virtual void dumpState(String8& result, const char* prefix) const;
// Functions required for backwards compatibility.
// These will be modified/renamed in IGraphicBufferConsumer and will be
diff --git a/include/gui/BufferQueueCore.h b/include/gui/BufferQueueCore.h
index 1226feb..b1c730a 100644
--- a/include/gui/BufferQueueCore.h
+++ b/include/gui/BufferQueueCore.h
@@ -86,7 +86,7 @@
private:
// Dump our state in a string
- void dump(String8& result, const char* prefix) const;
+ void dumpState(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
@@ -317,13 +317,13 @@
// Cached data about the shared buffer in shared buffer mode
struct SharedBufferCache {
- SharedBufferCache(Rect _crop, uint32_t _transform, int _scalingMode,
- android_dataspace _dataspace)
+ SharedBufferCache(Rect _crop, uint32_t _transform,
+ uint32_t _scalingMode, android_dataspace _dataspace)
: crop(_crop),
transform(_transform),
scalingMode(_scalingMode),
dataspace(_dataspace) {
- };
+ }
Rect crop;
uint32_t transform;
diff --git a/include/gui/BufferQueueProducer.h b/include/gui/BufferQueueProducer.h
index 8f613ee..79e7af2 100644
--- a/include/gui/BufferQueueProducer.h
+++ b/include/gui/BufferQueueProducer.h
@@ -22,7 +22,7 @@
namespace android {
-class BufferSlot;
+struct BufferSlot;
class BufferQueueProducer : public BnGraphicBufferProducer,
private IBinder::DeathRecipient {
diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h
index 0490c3c..9f8b638 100644
--- a/include/gui/ConsumerBase.h
+++ b/include/gui/ConsumerBase.h
@@ -63,11 +63,11 @@
// log messages.
void setName(const String8& name);
- // dump writes the current state to a string. Child classes should add
+ // dumpState 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;
+ void dumpState(String8& result) const;
+ void dumpState(String8& result, const char* prefix) const;
// setFrameAvailableListener sets the listener object that will be notified
// when a new frame becomes available.
@@ -101,7 +101,7 @@
// buffers from the given IGraphicBufferConsumer.
// The controlledByApp flag indicates that this consumer is under the application's
// control.
- ConsumerBase(const sp<IGraphicBufferConsumer>& consumer, bool controlledByApp = false);
+ explicit ConsumerBase(const sp<IGraphicBufferConsumer>& 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
diff --git a/include/gui/DisplayEventReceiver.h b/include/gui/DisplayEventReceiver.h
index a4718b9..cb9b373 100644
--- a/include/gui/DisplayEventReceiver.h
+++ b/include/gui/DisplayEventReceiver.h
@@ -35,13 +35,19 @@
class BitTube;
class IDisplayEventConnection;
-// ----------------------------------------------------------------------------
+static inline constexpr uint32_t fourcc(char c1, char c2, char c3, char c4) {
+ return static_cast<uint32_t>(c1) << 24 |
+ static_cast<uint32_t>(c2) << 16 |
+ static_cast<uint32_t>(c3) << 8 |
+ static_cast<uint32_t>(c4);
+}
+// ----------------------------------------------------------------------------
class DisplayEventReceiver {
public:
enum {
- DISPLAY_EVENT_VSYNC = 'vsyn',
- DISPLAY_EVENT_HOTPLUG = 'plug'
+ DISPLAY_EVENT_VSYNC = fourcc('v', 's', 'y', 'n'),
+ DISPLAY_EVENT_HOTPLUG = fourcc('p', 'l', 'u', 'g'),
};
struct Event {
diff --git a/include/gui/IConsumerListener.h b/include/gui/IConsumerListener.h
index 1efcf3c..460a03d 100644
--- a/include/gui/IConsumerListener.h
+++ b/include/gui/IConsumerListener.h
@@ -41,7 +41,7 @@
class ConsumerListener : public virtual RefBase {
public:
ConsumerListener() { }
- virtual ~ConsumerListener() { }
+ virtual ~ConsumerListener();
// onFrameAvailable is called from queueBuffer each time an additional
// frame becomes available for consumption. This means that frames that
@@ -91,7 +91,7 @@
class IConsumerListener : public ConsumerListener, public IInterface
{
public:
- DECLARE_META_INTERFACE(ConsumerListener);
+ DECLARE_META_INTERFACE(ConsumerListener)
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/IDisplayEventConnection.h b/include/gui/IDisplayEventConnection.h
index 86247de..848368c 100644
--- a/include/gui/IDisplayEventConnection.h
+++ b/include/gui/IDisplayEventConnection.h
@@ -34,7 +34,7 @@
{
public:
- DECLARE_META_INTERFACE(DisplayEventConnection);
+ DECLARE_META_INTERFACE(DisplayEventConnection)
/*
* getDataChannel() returns a BitTube where to receive the events from
diff --git a/include/gui/IGraphicBufferAlloc.h b/include/gui/IGraphicBufferAlloc.h
index 600cf27..acc2f30 100644
--- a/include/gui/IGraphicBufferAlloc.h
+++ b/include/gui/IGraphicBufferAlloc.h
@@ -33,7 +33,7 @@
class IGraphicBufferAlloc : public IInterface
{
public:
- DECLARE_META_INTERFACE(GraphicBufferAlloc);
+ DECLARE_META_INTERFACE(GraphicBufferAlloc)
/* Create a new GraphicBuffer for the client to use.
*/
diff --git a/include/gui/IGraphicBufferConsumer.h b/include/gui/IGraphicBufferConsumer.h
index 3b10d78..dcddca4 100644
--- a/include/gui/IGraphicBufferConsumer.h
+++ b/include/gui/IGraphicBufferConsumer.h
@@ -278,10 +278,10 @@
virtual status_t discardFreeBuffers() = 0;
// dump state into a string
- virtual void dump(String8& result, const char* prefix) const = 0;
+ virtual void dumpState(String8& result, const char* prefix) const = 0;
public:
- DECLARE_META_INTERFACE(GraphicBufferConsumer);
+ DECLARE_META_INTERFACE(GraphicBufferConsumer)
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h
index bf427fe..c2dba50 100644
--- a/include/gui/IGraphicBufferProducer.h
+++ b/include/gui/IGraphicBufferProducer.h
@@ -56,7 +56,7 @@
class IGraphicBufferProducer : public IInterface
{
public:
- DECLARE_META_INTERFACE(GraphicBufferProducer);
+ DECLARE_META_INTERFACE(GraphicBufferProducer)
enum {
// A flag returned by dequeueBuffer when the client needs to call
@@ -294,7 +294,7 @@
struct QueueBufferInput : public Flattenable<QueueBufferInput> {
friend class Flattenable<QueueBufferInput>;
- inline QueueBufferInput(const Parcel& parcel);
+ explicit 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
@@ -305,12 +305,13 @@
// 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, const sp<Fence>& fence, uint32_t sticky = 0)
- : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp),
- dataSpace(dataSpace), crop(crop), scalingMode(scalingMode),
- transform(transform), stickyTransform(sticky), fence(fence),
+ inline QueueBufferInput(int64_t _timestamp, bool _isAutoTimestamp,
+ android_dataspace _dataSpace, const Rect& _crop,
+ int _scalingMode, uint32_t _transform, const sp<Fence>& _fence,
+ uint32_t _sticky = 0)
+ : timestamp(_timestamp), isAutoTimestamp(_isAutoTimestamp),
+ dataSpace(_dataSpace), crop(_crop), scalingMode(_scalingMode),
+ transform(_transform), stickyTransform(_sticky), fence(_fence),
surfaceDamage() { }
inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp,
android_dataspace* outDataSpace,
@@ -351,7 +352,7 @@
};
// QueueBufferOutput must be a POD structure
- struct __attribute__ ((__packed__)) QueueBufferOutput {
+ struct QueueBufferOutput {
inline QueueBufferOutput() { }
// outWidth - filled with default width applied to the buffer
// outHeight - filled with default height applied to the buffer
diff --git a/include/gui/IProducerListener.h b/include/gui/IProducerListener.h
index b7826c6..e808bd3 100644
--- a/include/gui/IProducerListener.h
+++ b/include/gui/IProducerListener.h
@@ -33,7 +33,7 @@
{
public:
ProducerListener() {}
- virtual ~ProducerListener() {}
+ virtual ~ProducerListener();
// onBufferReleased is called from IGraphicBufferConsumer::releaseBuffer to
// notify the producer that a new buffer is free and ready to be dequeued.
@@ -61,6 +61,7 @@
class DummyProducerListener : public BnProducerListener
{
public:
+ virtual ~DummyProducerListener();
virtual void onBufferReleased() {}
virtual bool needsReleaseNotify() { return false; }
};
diff --git a/include/gui/ISensorEventConnection.h b/include/gui/ISensorEventConnection.h
index f64c6b8..857444b 100644
--- a/include/gui/ISensorEventConnection.h
+++ b/include/gui/ISensorEventConnection.h
@@ -33,7 +33,7 @@
class ISensorEventConnection : public IInterface
{
public:
- DECLARE_META_INTERFACE(SensorEventConnection);
+ DECLARE_META_INTERFACE(SensorEventConnection)
virtual sp<BitTube> getSensorChannel() const = 0;
virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs,
diff --git a/include/gui/ISensorServer.h b/include/gui/ISensorServer.h
index 571acb5..737c430 100644
--- a/include/gui/ISensorServer.h
+++ b/include/gui/ISensorServer.h
@@ -35,7 +35,7 @@
class ISensorServer : public IInterface
{
public:
- DECLARE_META_INTERFACE(SensorServer);
+ DECLARE_META_INTERFACE(SensorServer)
virtual Vector<Sensor> getSensorList(const String16& opPackageName) = 0;
virtual Vector<Sensor> getDynamicSensorList(const String16& opPackageName) = 0;
diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h
index 74a4123..555a0cc 100644
--- a/include/gui/ISurfaceComposer.h
+++ b/include/gui/ISurfaceComposer.h
@@ -35,8 +35,8 @@
namespace android {
// ----------------------------------------------------------------------------
-class ComposerState;
-class DisplayState;
+struct ComposerState;
+struct DisplayState;
struct DisplayInfo;
struct DisplayStatInfo;
class HdrCapabilities;
@@ -50,7 +50,7 @@
*/
class ISurfaceComposer: public IInterface {
public:
- DECLARE_META_INTERFACE(SurfaceComposer);
+ DECLARE_META_INTERFACE(SurfaceComposer)
// flags for setTransactionState()
enum {
diff --git a/include/gui/ISurfaceComposerClient.h b/include/gui/ISurfaceComposerClient.h
index c27a741..4a4efb6 100644
--- a/include/gui/ISurfaceComposerClient.h
+++ b/include/gui/ISurfaceComposerClient.h
@@ -36,7 +36,7 @@
class ISurfaceComposerClient : public IInterface
{
public:
- DECLARE_META_INTERFACE(SurfaceComposerClient);
+ DECLARE_META_INTERFACE(SurfaceComposerClient)
// flags for createSurface()
enum { // (keep in sync with Surface.java)
diff --git a/include/gui/OccupancyTracker.h b/include/gui/OccupancyTracker.h
index 1d15e7f..d4de8f2 100644
--- a/include/gui/OccupancyTracker.h
+++ b/include/gui/OccupancyTracker.h
@@ -45,12 +45,12 @@
occupancyAverage(0.0f),
usedThirdBuffer(false) {}
- Segment(nsecs_t totalTime, size_t numFrames, float occupancyAverage,
- bool usedThirdBuffer)
- : totalTime(totalTime),
- numFrames(numFrames),
- occupancyAverage(occupancyAverage),
- usedThirdBuffer(usedThirdBuffer) {}
+ Segment(nsecs_t _totalTime, size_t _numFrames, float _occupancyAverage,
+ bool _usedThirdBuffer)
+ : totalTime(_totalTime),
+ numFrames(_numFrames),
+ occupancyAverage(_occupancyAverage),
+ usedThirdBuffer(_usedThirdBuffer) {}
// Parcelable interface
virtual status_t writeToParcel(Parcel* parcel) const override;
diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h
index 094fd16..7506835 100644
--- a/include/gui/Sensor.h
+++ b/include/gui/Sensor.h
@@ -61,6 +61,9 @@
uuid_t() : b{0} {}
};
+ Sensor(const Sensor&) = default;
+ Sensor& operator=(const Sensor&) = default;
+
Sensor(const char * name = "");
Sensor(struct sensor_t const* hwSensor, int halVersion = 0);
Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersion = 0);
diff --git a/include/gui/Surface.h b/include/gui/Surface.h
index f4a22cb..489d5ea 100644
--- a/include/gui/Surface.h
+++ b/include/gui/Surface.h
@@ -66,7 +66,7 @@
* the controlledByApp flag indicates that this Surface (producer) is
* controlled by the application. This flag is used at connect time.
*/
- Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp = false);
+ explicit Surface(const sp<IGraphicBufferProducer>& bufferProducer, bool controlledByApp = false);
/* getIGraphicBufferProducer() returns the IGraphicBufferProducer this
* Surface was created with. Usually it's an error to use the
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index c4f88b6..f2932f2 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -38,7 +38,7 @@
// ---------------------------------------------------------------------------
-class DisplayInfo;
+struct DisplayInfo;
class Composer;
class HdrCapabilities;
class ISurfaceComposerClient;
diff --git a/include/input/IInputFlinger.h b/include/input/IInputFlinger.h
index 629310f..11bb721 100644
--- a/include/input/IInputFlinger.h
+++ b/include/input/IInputFlinger.h
@@ -30,7 +30,7 @@
*/
class IInputFlinger : public IInterface {
public:
- DECLARE_META_INTERFACE(InputFlinger);
+ DECLARE_META_INTERFACE(InputFlinger)
};
diff --git a/include/input/Input.h b/include/input/Input.h
index 55787e7..cfcafab 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -398,7 +398,7 @@
inline int32_t getButtonState() const { return mButtonState; }
- inline int32_t setButtonState(int32_t buttonState) { mButtonState = buttonState; }
+ inline void setButtonState(int32_t buttonState) { mButtonState = buttonState; }
inline int32_t getActionButton() const { return mActionButton; }
diff --git a/include/input/InputEventLabels.h b/include/input/InputEventLabels.h
index 0bd14ea..20154eb 100644
--- a/include/input/InputEventLabels.h
+++ b/include/input/InputEventLabels.h
@@ -425,30 +425,30 @@
return NULL;
}
-static int32_t getKeyCodeByLabel(const char* label) {
+static inline int32_t getKeyCodeByLabel(const char* label) {
return int32_t(lookupValueByLabel(label, KEYCODES));
}
-static const char* getLabelByKeyCode(int32_t keyCode) {
- if (keyCode >= 0 && keyCode < size(KEYCODES)) {
+static inline const char* getLabelByKeyCode(int32_t keyCode) {
+ if (keyCode >= 0 && keyCode < static_cast<int32_t>(size(KEYCODES))) {
return KEYCODES[keyCode].literal;
}
return NULL;
}
-static uint32_t getKeyFlagByLabel(const char* label) {
+static inline uint32_t getKeyFlagByLabel(const char* label) {
return uint32_t(lookupValueByLabel(label, FLAGS));
}
-static int32_t getAxisByLabel(const char* label) {
+static inline int32_t getAxisByLabel(const char* label) {
return int32_t(lookupValueByLabel(label, AXES));
}
-static const char* getAxisLabel(int32_t axisId) {
+static inline const char* getAxisLabel(int32_t axisId) {
return lookupLabelByValue(axisId, AXES);
}
-static int32_t getLedByLabel(const char* label) {
+static inline int32_t getLedByLabel(const char* label) {
return int32_t(lookupValueByLabel(label, LEDS));
}
diff --git a/include/media/hardware/HardwareAPI.h b/include/media/hardware/HardwareAPI.h
index 2c50ad6..cecf715 100644
--- a/include/media/hardware/HardwareAPI.h
+++ b/include/media/hardware/HardwareAPI.h
@@ -270,7 +270,7 @@
// output: fill out the MediaImage fields
MediaImage sMediaImage;
- DescribeColorFormatParams(const DescribeColorFormat2Params&); // for internal use only
+ explicit DescribeColorFormatParams(const DescribeColorFormat2Params&); // for internal use only
};
// A pointer to this struct is passed to OMX_GetParameter when the extension
diff --git a/include/media/openmax/OMX_Core.h b/include/media/openmax/OMX_Core.h
index 88dd585..bb974b3 100644
--- a/include/media/openmax/OMX_Core.h
+++ b/include/media/openmax/OMX_Core.h
@@ -738,7 +738,7 @@
pComponentVersion, \
pSpecVersion, \
pComponentUUID) \
- ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->GetComponentVersion(\
hComponent, \
pComponentName, \
pComponentVersion, \
@@ -804,7 +804,7 @@
Cmd, \
nParam, \
pCmdData) \
- ((OMX_COMPONENTTYPE*)hComponent)->SendCommand( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->SendCommand( \
hComponent, \
Cmd, \
nParam, \
@@ -843,8 +843,8 @@
#define OMX_GetParameter( \
hComponent, \
nParamIndex, \
- pComponentParameterStructure) \
- ((OMX_COMPONENTTYPE*)hComponent)->GetParameter( \
+ pComponentParameterStructure) \
+ ((OMX_COMPONENTTYPE*)(hComponent))->GetParameter( \
hComponent, \
nParamIndex, \
pComponentParameterStructure) /* Macro End */
@@ -882,8 +882,8 @@
#define OMX_SetParameter( \
hComponent, \
nParamIndex, \
- pComponentParameterStructure) \
- ((OMX_COMPONENTTYPE*)hComponent)->SetParameter( \
+ pComponentParameterStructure) \
+ ((OMX_COMPONENTTYPE*)(hComponent))->SetParameter( \
hComponent, \
nParamIndex, \
pComponentParameterStructure) /* Macro End */
@@ -918,8 +918,8 @@
#define OMX_GetConfig( \
hComponent, \
nConfigIndex, \
- pComponentConfigStructure) \
- ((OMX_COMPONENTTYPE*)hComponent)->GetConfig( \
+ pComponentConfigStructure) \
+ ((OMX_COMPONENTTYPE*)(hComponent))->GetConfig( \
hComponent, \
nConfigIndex, \
pComponentConfigStructure) /* Macro End */
@@ -954,8 +954,8 @@
#define OMX_SetConfig( \
hComponent, \
nConfigIndex, \
- pComponentConfigStructure) \
- ((OMX_COMPONENTTYPE*)hComponent)->SetConfig( \
+ pComponentConfigStructure) \
+ ((OMX_COMPONENTTYPE*)(hComponent))->SetConfig( \
hComponent, \
nConfigIndex, \
pComponentConfigStructure) /* Macro End */
@@ -989,7 +989,7 @@
hComponent, \
cParameterName, \
pIndexType) \
- ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->GetExtensionIndex( \
hComponent, \
cParameterName, \
pIndexType) /* Macro End */
@@ -1015,7 +1015,7 @@
#define OMX_GetState( \
hComponent, \
pState) \
- ((OMX_COMPONENTTYPE*)hComponent)->GetState( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->GetState( \
hComponent, \
pState) /* Macro End */
@@ -1046,7 +1046,7 @@
pAppPrivate, \
nSizeBytes, \
pBuffer) \
- ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->UseBuffer( \
hComponent, \
ppBufferHdr, \
nPortIndex, \
@@ -1088,7 +1088,7 @@
nPortIndex, \
pAppPrivate, \
nSizeBytes) \
- ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->AllocateBuffer( \
hComponent, \
ppBuffer, \
nPortIndex, \
@@ -1122,7 +1122,7 @@
hComponent, \
nPortIndex, \
pBuffer) \
- ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->FreeBuffer( \
hComponent, \
nPortIndex, \
pBuffer) /* Macro End */
@@ -1153,7 +1153,7 @@
#define OMX_EmptyThisBuffer( \
hComponent, \
pBuffer) \
- ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->EmptyThisBuffer( \
hComponent, \
pBuffer) /* Macro End */
@@ -1183,7 +1183,7 @@
#define OMX_FillThisBuffer( \
hComponent, \
pBuffer) \
- ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->FillThisBuffer( \
hComponent, \
pBuffer) /* Macro End */
@@ -1225,7 +1225,7 @@
nPortIndex, \
pAppPrivate, \
eglImage) \
- ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage( \
+ ((OMX_COMPONENTTYPE*)(hComponent))->UseEGLImage( \
hComponent, \
ppBufferHdr, \
nPortIndex, \
diff --git a/include/powermanager/IPowerManager.h b/include/powermanager/IPowerManager.h
index 461fad7..3230189 100644
--- a/include/powermanager/IPowerManager.h
+++ b/include/powermanager/IPowerManager.h
@@ -50,7 +50,7 @@
CRASH = IBinder::FIRST_CALL_TRANSACTION + 16,
};
- DECLARE_META_INTERFACE(PowerManager);
+ DECLARE_META_INTERFACE(PowerManager)
// The parcels created by these methods must be kept in sync with the
// corresponding methods from IPowerManager.aidl.
diff --git a/include/private/binder/binder_module.h b/include/private/binder/binder_module.h
index a8dd64f..2f11622 100644
--- a/include/private/binder/binder_module.h
+++ b/include/private/binder/binder_module.h
@@ -24,7 +24,7 @@
/* obtain structures and constants from the kernel header */
#include <sys/ioctl.h>
-#include <linux/binder.h>
+#include <linux/android/binder.h>
#ifdef __cplusplus
} // namespace android
diff --git a/include/private/ui/RegionHelper.h b/include/private/ui/RegionHelper.h
index 84eb100..c7c3160 100644
--- a/include/private/ui/RegionHelper.h
+++ b/include/private/ui/RegionHelper.h
@@ -53,20 +53,20 @@
TYPE dy;
inline region(const region& rhs)
: rects(rhs.rects), count(rhs.count), dx(rhs.dx), dy(rhs.dy) { }
- inline region(RECT const* r, size_t c)
- : rects(r), count(c), dx(), dy() { }
- inline region(RECT const* r, size_t c, TYPE dx, TYPE dy)
- : rects(r), count(c), dx(dx), dy(dy) { }
+ inline region(RECT const* _r, size_t _c)
+ : rects(_r), count(_c), dx(), dy() { }
+ inline region(RECT const* _r, size_t _c, TYPE _dx, TYPE _dy)
+ : rects(_r), count(_c), dx(_dx), dy(_dy) { }
};
class region_rasterizer {
friend class region_operator;
virtual void operator()(const RECT& rect) = 0;
public:
- virtual ~region_rasterizer() { };
+ virtual ~region_rasterizer() { }
};
- inline region_operator(int op, const region& lhs, const region& rhs)
+ inline region_operator(uint32_t op, const region& lhs, const region& rhs)
: op_mask(op), spanner(lhs, rhs)
{
}
@@ -79,8 +79,8 @@
spannerInner.prepare(inside);
do {
TYPE left, right;
- int inside = spannerInner.next(current.left, current.right);
- if ((op_mask >> inside) & 1) {
+ int inner_inside = spannerInner.next(current.left, current.right);
+ if ((op_mask >> inner_inside) & 1) {
if (current.left < current.right &&
current.top < current.bottom) {
rasterizer(current);
@@ -162,8 +162,8 @@
region rhs;
public:
- inline Spanner(const region& lhs, const region& rhs)
- : lhs(lhs), rhs(rhs)
+ inline Spanner(const region& _lhs, const region& _rhs)
+ : lhs(_lhs), rhs(_rhs)
{
if (lhs.count) {
SpannerBase::lhs_head = lhs.rects->top + lhs.dy;
@@ -223,8 +223,8 @@
region rhs;
public:
- inline SpannerInner(const region& lhs, const region& rhs)
- : lhs(lhs), rhs(rhs)
+ inline SpannerInner(const region& _lhs, const region& _rhs)
+ : lhs(_lhs), rhs(_rhs)
{
}
diff --git a/include/ui/Fence.h b/include/ui/Fence.h
index 48a7aa3..1df15f8 100644
--- a/include/ui/Fence.h
+++ b/include/ui/Fence.h
@@ -55,7 +55,7 @@
// 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);
+ explicit 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
diff --git a/include/ui/FrameStats.h b/include/ui/FrameStats.h
index 6bfe635..bc9d3ec 100644
--- a/include/ui/FrameStats.h
+++ b/include/ui/FrameStats.h
@@ -25,7 +25,7 @@
class FrameStats : public LightFlattenable<FrameStats> {
public:
- FrameStats() : refreshPeriodNano(0) {};
+ FrameStats() : refreshPeriodNano(0) {}
/*
* Approximate refresh time, in nanoseconds.
diff --git a/include/ui/Gralloc1On0Adapter.h b/include/ui/Gralloc1On0Adapter.h
index 97c9a89..d523c4f 100644
--- a/include/ui/Gralloc1On0Adapter.h
+++ b/include/ui/Gralloc1On0Adapter.h
@@ -81,7 +81,7 @@
uint32_t* outCount,
int32_t* /*gralloc1_capability_t*/ outCapabilities) {
getAdapter(device)->doGetCapabilities(outCount, outCapabilities);
- };
+ }
// getFunction
@@ -104,7 +104,7 @@
// Buffer descriptor lifecycle functions
- class Descriptor;
+ struct Descriptor;
gralloc1_error_t createDescriptor(
gralloc1_buffer_descriptor_t* outDescriptor);
@@ -124,10 +124,10 @@
// Buffer descriptor modification functions
struct Descriptor : public std::enable_shared_from_this<Descriptor> {
- Descriptor(Gralloc1On0Adapter* adapter,
- gralloc1_buffer_descriptor_t id)
- : adapter(adapter),
- id(id),
+ Descriptor(Gralloc1On0Adapter* _adapter,
+ gralloc1_buffer_descriptor_t _id)
+ : adapter(_adapter),
+ id(_id),
width(0),
height(0),
format(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED),
@@ -416,10 +416,10 @@
if (!outData) {
const auto producerCpuUsage = GRALLOC1_PRODUCER_USAGE_CPU_READ |
GRALLOC1_PRODUCER_USAGE_CPU_WRITE;
- if (producerUsage & producerCpuUsage != 0) {
+ if ((producerUsage & producerCpuUsage) != 0) {
return static_cast<int32_t>(GRALLOC1_ERROR_BAD_VALUE);
}
- if (consumerUsage & GRALLOC1_CONSUMER_USAGE_CPU_READ != 0) {
+ if ((consumerUsage & GRALLOC1_CONSUMER_USAGE_CPU_READ) != 0) {
return static_cast<int32_t>(GRALLOC1_ERROR_BAD_VALUE);
}
}
diff --git a/include/ui/Point.h b/include/ui/Point.h
index 1d7f64d..d050ede 100644
--- a/include/ui/Point.h
+++ b/include/ui/Point.h
@@ -34,7 +34,7 @@
// Default constructor doesn't initialize the Point
inline Point() {
}
- inline Point(int x, int y) : x(x), y(y) {
+ inline Point(int _x, int _y) : x(_x), y(_y) {
}
inline bool operator == (const Point& rhs) const {
diff --git a/include/ui/Region.h b/include/ui/Region.h
index 810f098..7788452 100644
--- a/include/ui/Region.h
+++ b/include/ui/Region.h
@@ -147,21 +147,21 @@
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;
+ Region& operationSelf(const Rect& r, uint32_t op);
+ Region& operationSelf(const Region& r, uint32_t op);
+ Region& operationSelf(const Region& r, int dx, int dy, uint32_t op);
+ const Region operation(const Rect& rhs, uint32_t op) const;
+ const Region operation(const Region& rhs, uint32_t op) const;
+ const Region operation(const Region& rhs, int dx, int dy, uint32_t op) const;
- static void boolean_operation(int op, Region& dst,
+ static void boolean_operation(uint32_t op, Region& dst,
const Region& lhs, const Region& rhs, int dx, int dy);
- static void boolean_operation(int op, Region& dst,
+ static void boolean_operation(uint32_t op, Region& dst,
const Region& lhs, const Rect& rhs, int dx, int dy);
- static void boolean_operation(int op, Region& dst,
+ static void boolean_operation(uint32_t op, Region& dst,
const Region& lhs, const Region& rhs);
- static void boolean_operation(int op, Region& dst,
+ static void boolean_operation(uint32_t op, Region& dst,
const Region& lhs, const Rect& rhs);
static void translate(Region& reg, int dx, int dy);
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
new file mode 100644
index 0000000..4780757
--- /dev/null
+++ b/libs/binder/Android.bp
@@ -0,0 +1,76 @@
+// 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.
+
+cc_library {
+ name: "libbinder",
+
+ srcs: [
+ "AppOpsManager.cpp",
+ "Binder.cpp",
+ "BpBinder.cpp",
+ "BufferedTextOutput.cpp",
+ "Debug.cpp",
+ "IAppOpsCallback.cpp",
+ "IAppOpsService.cpp",
+ "IBatteryStats.cpp",
+ "IInterface.cpp",
+ "IMediaResourceMonitor.cpp",
+ "IMemory.cpp",
+ "IPCThreadState.cpp",
+ "IPermissionController.cpp",
+ "IProcessInfoService.cpp",
+ "IResultReceiver.cpp",
+ "IServiceManager.cpp",
+ "MemoryBase.cpp",
+ "MemoryDealer.cpp",
+ "MemoryHeapBase.cpp",
+ "Parcel.cpp",
+ "PermissionCache.cpp",
+ "PersistableBundle.cpp",
+ "ProcessInfoService.cpp",
+ "ProcessState.cpp",
+ "Static.cpp",
+ "Status.cpp",
+ "TextOutput.cpp",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ product_variables: {
+ binder32bit: {
+ cflags: ["-DBINDER_IPC_32BIT=1"],
+ },
+ },
+
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libutils",
+ ],
+ export_shared_lib_headers: [
+ "libbase",
+ "libutils",
+ ],
+
+ clang: true,
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+}
+
+subdirs = ["tests"]
diff --git a/libs/binder/Android.mk b/libs/binder/Android.mk
deleted file mode 100644
index 14be920..0000000
--- a/libs/binder/Android.mk
+++ /dev/null
@@ -1,72 +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.
-
-# we have the common sources, plus some device-specific stuff
-sources := \
- AppOpsManager.cpp \
- Binder.cpp \
- BpBinder.cpp \
- BufferedTextOutput.cpp \
- Debug.cpp \
- IAppOpsCallback.cpp \
- IAppOpsService.cpp \
- IBatteryStats.cpp \
- IInterface.cpp \
- IMediaResourceMonitor.cpp \
- IMemory.cpp \
- IPCThreadState.cpp \
- IPermissionController.cpp \
- IProcessInfoService.cpp \
- IResultReceiver.cpp \
- IServiceManager.cpp \
- MemoryBase.cpp \
- MemoryDealer.cpp \
- MemoryHeapBase.cpp \
- Parcel.cpp \
- PermissionCache.cpp \
- PersistableBundle.cpp \
- ProcessInfoService.cpp \
- ProcessState.cpp \
- Static.cpp \
- Status.cpp \
- TextOutput.cpp \
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbinder
-LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := integer
-LOCAL_SRC_FILES := $(sources)
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
-endif
-endif
-LOCAL_CFLAGS += -Werror
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libbinder
-LOCAL_STATIC_LIBRARIES += libutils
-LOCAL_SRC_FILES := $(sources)
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
-endif
-endif
-LOCAL_CFLAGS += -Werror
-include $(BUILD_STATIC_LIBRARY)
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp
index 9a061a0..f3b86ae 100644
--- a/libs/binder/AppOpsManager.cpp
+++ b/libs/binder/AppOpsManager.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <mutex>
#include <binder/AppOpsManager.h>
#include <binder/Binder.h>
#include <binder/IServiceManager.h>
@@ -22,6 +23,19 @@
namespace android {
+namespace {
+
+#if defined(__BRILLO__)
+// Because Brillo has no application model, security policy is managed
+// statically (at build time) with SELinux controls.
+// As a consequence, it also never runs the AppOpsManager service.
+const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_ALLOWED;
+#else
+const int APP_OPS_MANAGER_UNAVAILABLE_MODE = AppOpsManager::MODE_IGNORED;
+#endif // defined(__BRILLO__)
+
+} // namespace
+
static String16 _appops("appops");
static pthread_mutex_t gTokenMutex = PTHREAD_MUTEX_INITIALIZER;
static sp<IBinder> gToken;
@@ -39,10 +53,15 @@
{
}
+#if defined(__BRILLO__)
+// There is no AppOpsService on Brillo
+sp<IAppOpsService> AppOpsManager::getService() { return NULL; }
+#else
sp<IAppOpsService> AppOpsManager::getService()
{
+
+ std::lock_guard<Mutex> scoped_lock(mLock);
int64_t startTime = 0;
- mLock.lock();
sp<IAppOpsService> service = mService;
while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) {
sp<IBinder> binder = defaultServiceManager()->checkService(_appops);
@@ -53,7 +72,8 @@
ALOGI("Waiting for app ops service");
} else if ((uptimeMillis()-startTime) > 10000) {
ALOGW("Waiting too long for app ops service, giving up");
- return NULL;
+ service = NULL;
+ break;
}
sleep(1);
} else {
@@ -61,25 +81,30 @@
mService = service;
}
}
- mLock.unlock();
return service;
}
+#endif // defined(__BRILLO__)
int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
{
sp<IAppOpsService> service = getService();
- return service != NULL ? service->checkOperation(op, uid, callingPackage) : MODE_IGNORED;
+ return service != NULL
+ ? service->checkOperation(op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
sp<IAppOpsService> service = getService();
- return service != NULL ? service->noteOperation(op, uid, callingPackage) : MODE_IGNORED;
+ return service != NULL
+ ? service->noteOperation(op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
int32_t AppOpsManager::startOp(int32_t op, int32_t uid, const String16& callingPackage) {
sp<IAppOpsService> service = getService();
- return service != NULL ? service->startOperation(getToken(service), op, uid, callingPackage)
- : MODE_IGNORED;
+ return service != NULL
+ ? service->startOperation(getToken(service), op, uid, callingPackage)
+ : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) {
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp
index c4d47ca..7ce2a31 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -237,6 +237,10 @@
// XXX can't add virtuals until binaries are updated.
//return shellCommand(in, out, err, args, resultReceiver);
+ (void)in;
+ (void)out;
+ (void)err;
+
if (resultReceiver != NULL) {
resultReceiver->send(INVALID_OPERATION);
}
diff --git a/libs/binder/BufferedTextOutput.cpp b/libs/binder/BufferedTextOutput.cpp
index 1339a67..a2443c0 100644
--- a/libs/binder/BufferedTextOutput.cpp
+++ b/libs/binder/BufferedTextOutput.cpp
@@ -34,7 +34,7 @@
struct BufferedTextOutput::BufferState : public RefBase
{
- BufferState(int32_t _seq)
+ explicit BufferState(int32_t _seq)
: seq(_seq)
, buffer(NULL)
, bufferPos(0)
diff --git a/libs/binder/IAppOpsCallback.cpp b/libs/binder/IAppOpsCallback.cpp
index 2aaf566..f9ec593 100644
--- a/libs/binder/IAppOpsCallback.cpp
+++ b/libs/binder/IAppOpsCallback.cpp
@@ -31,7 +31,7 @@
class BpAppOpsCallback : public BpInterface<IAppOpsCallback>
{
public:
- BpAppOpsCallback(const sp<IBinder>& impl)
+ explicit BpAppOpsCallback(const sp<IBinder>& impl)
: BpInterface<IAppOpsCallback>(impl)
{
}
diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp
index 9558376..638ae5c 100644
--- a/libs/binder/IAppOpsService.cpp
+++ b/libs/binder/IAppOpsService.cpp
@@ -31,7 +31,7 @@
class BpAppOpsService : public BpInterface<IAppOpsService>
{
public:
- BpAppOpsService(const sp<IBinder>& impl)
+ explicit BpAppOpsService(const sp<IBinder>& impl)
: BpInterface<IAppOpsService>(impl)
{
}
diff --git a/libs/binder/IBatteryStats.cpp b/libs/binder/IBatteryStats.cpp
index e32c628..ad1e69f 100644
--- a/libs/binder/IBatteryStats.cpp
+++ b/libs/binder/IBatteryStats.cpp
@@ -29,7 +29,7 @@
class BpBatteryStats : public BpInterface<IBatteryStats>
{
public:
- BpBatteryStats(const sp<IBinder>& impl)
+ explicit BpBatteryStats(const sp<IBinder>& impl)
: BpInterface<IBatteryStats>(impl)
{
}
diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp
index 5f345cf..790fa8c 100644
--- a/libs/binder/IMemory.cpp
+++ b/libs/binder/IMemory.cpp
@@ -16,6 +16,7 @@
#define LOG_TAG "IMemory"
+#include <atomic>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -29,7 +30,6 @@
#include <cutils/log.h>
#include <utils/KeyedVector.h>
#include <utils/threads.h>
-#include <utils/Atomic.h>
#include <binder/Parcel.h>
#include <utils/CallStack.h>
@@ -56,12 +56,15 @@
struct heap_info_t {
sp<IMemoryHeap> heap;
int32_t count;
+ // Note that this cannot be meaningfully copied.
};
void free_heap(const wp<IBinder>& binder);
- Mutex mHeapCacheLock;
+ Mutex mHeapCacheLock; // Protects entire vector below.
KeyedVector< wp<IBinder>, heap_info_t > mHeapCache;
+ // We do not use the copy-on-write capabilities of KeyedVector.
+ // TODO: Reimplemement based on standard C++ container?
};
static sp<HeapCache> gHeapCache = new HeapCache();
@@ -75,7 +78,7 @@
class BpMemoryHeap : public BpInterface<IMemoryHeap>
{
public:
- BpMemoryHeap(const sp<IBinder>& impl);
+ explicit BpMemoryHeap(const sp<IBinder>& impl);
virtual ~BpMemoryHeap();
virtual int getHeapID() const;
@@ -105,7 +108,7 @@
void assertMapped() const;
void assertReallyMapped() const;
- mutable volatile int32_t mHeapId;
+ mutable std::atomic<int32_t> mHeapId;
mutable void* mBase;
mutable size_t mSize;
mutable uint32_t mFlags;
@@ -123,7 +126,7 @@
class BpMemory : public BpInterface<IMemory>
{
public:
- BpMemory(const sp<IBinder>& impl);
+ explicit BpMemory(const sp<IBinder>& impl);
virtual ~BpMemory();
virtual sp<IMemoryHeap> getMemory(ssize_t* offset=0, size_t* size=0) const;
@@ -248,8 +251,9 @@
}
BpMemoryHeap::~BpMemoryHeap() {
- if (mHeapId != -1) {
- close(mHeapId);
+ int32_t heapId = mHeapId.load(memory_order_relaxed);
+ if (heapId != -1) {
+ close(heapId);
if (mRealHeap) {
// by construction we're the last one
if (mBase != MAP_FAILED) {
@@ -257,7 +261,7 @@
if (VERBOSE) {
ALOGD("UNMAPPING binder=%p, heap=%p, size=%zu, fd=%d",
- binder.get(), this, mSize, mHeapId);
+ binder.get(), this, mSize, heapId);
CallStack stack(LOG_TAG);
}
@@ -273,17 +277,21 @@
void BpMemoryHeap::assertMapped() const
{
- if (mHeapId == -1) {
+ int32_t heapId = mHeapId.load(memory_order_acquire);
+ if (heapId == -1) {
sp<IBinder> binder(IInterface::asBinder(const_cast<BpMemoryHeap*>(this)));
sp<BpMemoryHeap> heap(static_cast<BpMemoryHeap*>(find_heap(binder).get()));
heap->assertReallyMapped();
if (heap->mBase != MAP_FAILED) {
Mutex::Autolock _l(mLock);
- if (mHeapId == -1) {
+ if (mHeapId.load(memory_order_relaxed) == -1) {
mBase = heap->mBase;
mSize = heap->mSize;
mOffset = heap->mOffset;
- android_atomic_write( dup( heap->mHeapId ), &mHeapId );
+ int fd = dup(heap->mHeapId.load(memory_order_relaxed));
+ ALOGE_IF(fd==-1, "cannot dup fd=%d",
+ heap->mHeapId.load(memory_order_relaxed));
+ mHeapId.store(fd, memory_order_release);
}
} else {
// something went wrong
@@ -294,7 +302,8 @@
void BpMemoryHeap::assertReallyMapped() const
{
- if (mHeapId == -1) {
+ int32_t heapId = mHeapId.load(memory_order_acquire);
+ if (heapId == -1) {
// remote call without mLock held, worse case scenario, we end up
// calling transact() from multiple threads, but that's not a problem,
@@ -313,7 +322,7 @@
parcel_fd, size, err, strerror(-err));
Mutex::Autolock _l(mLock);
- if (mHeapId == -1) {
+ if (mHeapId.load(memory_order_relaxed) == -1) {
int fd = dup( parcel_fd );
ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)",
parcel_fd, size, err, strerror(errno));
@@ -322,7 +331,6 @@
if (!(flags & READ_ONLY)) {
access |= PROT_WRITE;
}
-
mRealHeap = true;
mBase = mmap(0, size, access, MAP_SHARED, fd, offset);
if (mBase == MAP_FAILED) {
@@ -333,7 +341,7 @@
mSize = size;
mFlags = flags;
mOffset = offset;
- android_atomic_write(fd, &mHeapId);
+ mHeapId.store(fd, memory_order_release);
}
}
}
@@ -341,7 +349,8 @@
int BpMemoryHeap::getHeapID() const {
assertMapped();
- return mHeapId;
+ // We either stored mHeapId ourselves, or loaded it with acquire semantics.
+ return mHeapId.load(memory_order_relaxed);
}
void* BpMemoryHeap::getBase() const {
@@ -418,9 +427,10 @@
"found binder=%p, heap=%p, size=%zu, fd=%d, count=%d",
binder.get(), info.heap.get(),
static_cast<BpMemoryHeap*>(info.heap.get())->mSize,
- static_cast<BpMemoryHeap*>(info.heap.get())->mHeapId,
+ static_cast<BpMemoryHeap*>(info.heap.get())
+ ->mHeapId.load(memory_order_relaxed),
info.count);
- android_atomic_inc(&info.count);
+ ++info.count;
return info.heap;
} else {
heap_info_t info;
@@ -445,13 +455,13 @@
ssize_t i = mHeapCache.indexOfKey(binder);
if (i>=0) {
heap_info_t& info(mHeapCache.editValueAt(i));
- int32_t c = android_atomic_dec(&info.count);
- if (c == 1) {
+ if (--info.count == 0) {
ALOGD_IF(VERBOSE,
"removing binder=%p, heap=%p, size=%zu, fd=%d, count=%d",
binder.unsafe_get(), info.heap.get(),
static_cast<BpMemoryHeap*>(info.heap.get())->mSize,
- static_cast<BpMemoryHeap*>(info.heap.get())->mHeapId,
+ static_cast<BpMemoryHeap*>(info.heap.get())
+ ->mHeapId.load(memory_order_relaxed),
info.count);
rel = mHeapCache.valueAt(i).heap;
mHeapCache.removeItemsAt(i);
@@ -482,7 +492,7 @@
ALOGD("hey=%p, heap=%p, count=%d, (fd=%d, base=%p, size=%zu)",
mHeapCache.keyAt(i).unsafe_get(),
info.heap.get(), info.count,
- h->mHeapId, h->mBase, h->mSize);
+ h->mHeapId.load(memory_order_relaxed), h->mBase, h->mSize);
}
}
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index d90798f..02b4232 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -64,10 +64,6 @@
namespace android {
-static const char* getReturnString(size_t idx);
-static const void* printReturnCommand(TextOutput& out, const void* _cmd);
-static const void* printCommand(TextOutput& out, const void* _cmd);
-
// Static const and functions will be optimized out if not used,
// when LOG_NDEBUG and references in IF_LOG_COMMANDS() are optimized out.
static const char *kReturnStrings[] = {
@@ -111,8 +107,9 @@
"BC_DEAD_BINDER_DONE"
};
-static const char* getReturnString(size_t idx)
+static const char* getReturnString(uint32_t cmd)
{
+ size_t idx = cmd & 0xff;
if (idx < sizeof(kReturnStrings) / sizeof(kReturnStrings[0]))
return kReturnStrings[idx];
else
@@ -330,6 +327,7 @@
delete st;
pthread_setspecific(gTLS, NULL);
}
+ pthread_key_delete(gTLS);
gHaveTLS = false;
}
}
@@ -525,8 +523,8 @@
}
} while (result != -ECONNREFUSED && result != -EBADF);
- LOG_THREADPOOL("**** THREAD %p (PID %d) IS LEAVING THE THREAD POOL err=%p\n",
- (void*)pthread_self(), getpid(), (void*)result);
+ LOG_THREADPOOL("**** THREAD %p (PID %d) IS LEAVING THE THREAD POOL err=%d\n",
+ (void*)pthread_self(), getpid(), result);
mOut.writeInt32(BC_EXIT_LOOPER);
talkWithDriver(false);
@@ -668,7 +666,7 @@
waitForResponse(NULL, &result);
#if LOG_REFCOUNTS
- printf("IPCThreadState::attemptIncStrongHandle(%ld) = %s\n",
+ ALOGV("IPCThreadState::attemptIncStrongHandle(%ld) = %s\n",
handle, result == NO_ERROR ? "SUCCESS" : "FAILURE");
#endif
@@ -683,7 +681,7 @@
void IPCThreadState::expungeHandle(int32_t handle, IBinder* binder)
{
#if LOG_REFCOUNTS
- printf("IPCThreadState::expungeHandle(%ld)\n", handle);
+ ALOGV("IPCThreadState::expungeHandle(%ld)\n", handle);
#endif
self()->mProcess->expungeHandle(handle, binder);
}
@@ -1170,7 +1168,7 @@
break;
default:
- printf("*** BAD COMMAND %d received from Binder driver\n", cmd);
+ ALOGE("*** BAD COMMAND %d received from Binder driver\n", cmd);
result = UNKNOWN_ERROR;
break;
}
diff --git a/libs/binder/IPermissionController.cpp b/libs/binder/IPermissionController.cpp
index 6bba996..674bddf 100644
--- a/libs/binder/IPermissionController.cpp
+++ b/libs/binder/IPermissionController.cpp
@@ -31,7 +31,7 @@
class BpPermissionController : public BpInterface<IPermissionController>
{
public:
- BpPermissionController(const sp<IBinder>& impl)
+ explicit BpPermissionController(const sp<IBinder>& impl)
: BpInterface<IPermissionController>(impl)
{
}
diff --git a/libs/binder/IProcessInfoService.cpp b/libs/binder/IProcessInfoService.cpp
index 76508b8..96e1a8c 100644
--- a/libs/binder/IProcessInfoService.cpp
+++ b/libs/binder/IProcessInfoService.cpp
@@ -25,7 +25,7 @@
class BpProcessInfoService : public BpInterface<IProcessInfoService> {
public:
- BpProcessInfoService(const sp<IBinder>& impl)
+ explicit BpProcessInfoService(const sp<IBinder>& impl)
: BpInterface<IProcessInfoService>(impl) {}
virtual status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids,
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index 44d235f..3aeff2e 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -67,11 +67,6 @@
bool checkPermission(const String16& permission, pid_t pid, uid_t uid)
{
-#ifdef __BRILLO__
- // Brillo doesn't currently run ActivityManager or support framework permissions.
- return true;
-#endif
-
sp<IPermissionController> pc;
gDefaultServiceManagerLock.lock();
pc = gPermissionController;
@@ -131,7 +126,7 @@
class BpServiceManager : public BpInterface<IServiceManager>
{
public:
- BpServiceManager(const sp<IBinder>& impl)
+ explicit BpServiceManager(const sp<IBinder>& impl)
: BpInterface<IServiceManager>(impl)
{
}
diff --git a/libs/binder/MemoryDealer.cpp b/libs/binder/MemoryDealer.cpp
index 51eac11..2a15773 100644
--- a/libs/binder/MemoryDealer.cpp
+++ b/libs/binder/MemoryDealer.cpp
@@ -126,7 +126,7 @@
PAGE_ALIGNED = 0x00000001
};
public:
- SimpleBestFitAllocator(size_t size);
+ explicit SimpleBestFitAllocator(size_t size);
~SimpleBestFitAllocator();
size_t allocate(size_t size, uint32_t flags = 0);
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 19ce3eb..d753eb5 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -100,32 +100,6 @@
BLOB_ASHMEM_MUTABLE = 2,
};
-static dev_t ashmem_rdev()
-{
- static dev_t __ashmem_rdev;
- static pthread_mutex_t __ashmem_rdev_lock = PTHREAD_MUTEX_INITIALIZER;
-
- pthread_mutex_lock(&__ashmem_rdev_lock);
-
- dev_t rdev = __ashmem_rdev;
- if (!rdev) {
- int fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDONLY));
- if (fd >= 0) {
- struct stat st;
-
- int ret = TEMP_FAILURE_RETRY(fstat(fd, &st));
- close(fd);
- if ((ret >= 0) && S_ISCHR(st.st_mode)) {
- rdev = __ashmem_rdev = st.st_rdev;
- }
- }
- }
-
- pthread_mutex_unlock(&__ashmem_rdev_lock);
-
- return rdev;
-}
-
void acquire_object(const sp<ProcessState>& proc,
const flat_binder_object& obj, const void* who, size_t* outAshmemSize)
{
@@ -154,15 +128,11 @@
return;
}
case BINDER_TYPE_FD: {
- if ((obj.cookie != 0) && (outAshmemSize != NULL)) {
- struct stat st;
- int ret = fstat(obj.handle, &st);
- if (!ret && S_ISCHR(st.st_mode) && (st.st_rdev == ashmem_rdev())) {
- // If we own an ashmem fd, keep track of how much memory it refers to.
- int size = ashmem_get_size_region(obj.handle);
- if (size > 0) {
- *outAshmemSize += size;
- }
+ if ((obj.cookie != 0) && (outAshmemSize != NULL) && ashmem_valid(obj.handle)) {
+ // If we own an ashmem fd, keep track of how much memory it refers to.
+ int size = ashmem_get_size_region(obj.handle);
+ if (size > 0) {
+ *outAshmemSize += size;
}
}
return;
@@ -207,14 +177,10 @@
}
case BINDER_TYPE_FD: {
if (obj.cookie != 0) { // owned
- if (outAshmemSize != NULL) {
- struct stat st;
- int ret = fstat(obj.handle, &st);
- if (!ret && S_ISCHR(st.st_mode) && (st.st_rdev == ashmem_rdev())) {
- int size = ashmem_get_size_region(obj.handle);
- if (size > 0) {
- *outAshmemSize -= size;
- }
+ if ((outAshmemSize != NULL) && ashmem_valid(obj.handle)) {
+ int size = ashmem_get_size_region(obj.handle);
+ if (size > 0) {
+ *outAshmemSize -= size;
}
}
@@ -784,7 +750,7 @@
const uint8_t* strData = (uint8_t*)str.data();
const size_t strLen= str.length();
const ssize_t utf16Len = utf8_to_utf16_length(strData, strLen);
- if (utf16Len < 0 || utf16Len> std::numeric_limits<int32_t>::max()) {
+ if (utf16Len < 0 || utf16Len > std::numeric_limits<int32_t>::max()) {
return BAD_VALUE;
}
@@ -799,7 +765,7 @@
return NO_MEMORY;
}
- utf8_to_utf16(strData, strLen, (char16_t*)dst);
+ utf8_to_utf16(strData, strLen, (char16_t*)dst, (size_t) utf16Len + 1);
return NO_ERROR;
}
@@ -1112,7 +1078,7 @@
}
status_t Parcel::readStrongBinderVector(std::unique_ptr<std::vector<sp<IBinder>>>* val) const {
- return readNullableTypedVector(val, &Parcel::readStrongBinder);
+ return readNullableTypedVector(val, &Parcel::readNullableStrongBinder);
}
status_t Parcel::readStrongBinderVector(std::vector<sp<IBinder>>* val) const {
@@ -1187,15 +1153,15 @@
return err;
}
-status_t Parcel::writeUniqueFileDescriptor(const ScopedFd& fd) {
+status_t Parcel::writeUniqueFileDescriptor(const base::unique_fd& fd) {
return writeDupFileDescriptor(fd.get());
}
-status_t Parcel::writeUniqueFileDescriptorVector(const std::vector<ScopedFd>& val) {
+status_t Parcel::writeUniqueFileDescriptorVector(const std::vector<base::unique_fd>& val) {
return writeTypedVector(val, &Parcel::writeUniqueFileDescriptor);
}
-status_t Parcel::writeUniqueFileDescriptorVector(const std::unique_ptr<std::vector<ScopedFd>>& val) {
+status_t Parcel::writeUniqueFileDescriptorVector(const std::unique_ptr<std::vector<base::unique_fd>>& val) {
return writeNullableTypedVector(val, &Parcel::writeUniqueFileDescriptor);
}
@@ -1842,13 +1808,37 @@
String8 Parcel::readString8() const
{
- int32_t size = readInt32();
- // watch for potential int overflow adding 1 for trailing NUL
- if (size > 0 && size < INT32_MAX) {
- const char* str = (const char*)readInplace(size+1);
- if (str) return String8(str, size);
+ String8 retString;
+ status_t status = readString8(&retString);
+ if (status != OK) {
+ // We don't care about errors here, so just return an empty string.
+ return String8();
}
- return String8();
+ return retString;
+}
+
+status_t Parcel::readString8(String8* pArg) const
+{
+ int32_t size;
+ status_t status = readInt32(&size);
+ if (status != OK) {
+ return status;
+ }
+ // watch for potential int overflow from size+1
+ if (size < 0 || size >= INT32_MAX) {
+ return BAD_VALUE;
+ }
+ // |writeString8| writes nothing for empty string.
+ if (size == 0) {
+ *pArg = String8();
+ return OK;
+ }
+ const char* str = (const char*)readInplace(size + 1);
+ if (str == NULL) {
+ return BAD_VALUE;
+ }
+ pArg->setTo(str, size);
+ return OK;
}
String16 Parcel::readString16() const
@@ -1913,13 +1903,25 @@
status_t Parcel::readStrongBinder(sp<IBinder>* val) const
{
+ status_t status = readNullableStrongBinder(val);
+ if (status == OK && !val->get()) {
+ status = UNEXPECTED_NULL;
+ }
+ return status;
+}
+
+status_t Parcel::readNullableStrongBinder(sp<IBinder>* val) const
+{
return unflatten_binder(ProcessState::self(), *this, val);
}
sp<IBinder> Parcel::readStrongBinder() const
{
sp<IBinder> val;
- readStrongBinder(&val);
+ // Note that a lot of code in Android reads binders by hand with this
+ // method, and that code has historically been ok with getting nullptr
+ // back (while ignoring error codes).
+ readNullableStrongBinder(&val);
return val;
}
@@ -1994,7 +1996,7 @@
return BAD_TYPE;
}
-status_t Parcel::readUniqueFileDescriptor(ScopedFd* val) const
+status_t Parcel::readUniqueFileDescriptor(base::unique_fd* val) const
{
int got = readFileDescriptor();
@@ -2012,11 +2014,11 @@
}
-status_t Parcel::readUniqueFileDescriptorVector(std::unique_ptr<std::vector<ScopedFd>>* val) const {
+status_t Parcel::readUniqueFileDescriptorVector(std::unique_ptr<std::vector<base::unique_fd>>* val) const {
return readNullableTypedVector(val, &Parcel::readUniqueFileDescriptor);
}
-status_t Parcel::readUniqueFileDescriptorVector(std::vector<ScopedFd>* val) const {
+status_t Parcel::readUniqueFileDescriptorVector(std::vector<base::unique_fd>* val) const {
return readTypedVector(val, &Parcel::readUniqueFileDescriptor);
}
diff --git a/libs/binder/PersistableBundle.cpp b/libs/binder/PersistableBundle.cpp
index aef791c..e7078ba 100644
--- a/libs/binder/PersistableBundle.cpp
+++ b/libs/binder/PersistableBundle.cpp
@@ -32,6 +32,9 @@
using android::sp;
using android::status_t;
using android::UNEXPECTED_NULL;
+using std::map;
+using std::set;
+using std::vector;
enum {
// Keep in sync with BUNDLE_MAGIC in frameworks/base/core/java/android/os/BaseBundle.java.
@@ -55,12 +58,22 @@
namespace {
template <typename T>
-bool getValue(const android::String16& key, T* out, const std::map<android::String16, T>& map) {
+bool getValue(const android::String16& key, T* out, const map<android::String16, T>& map) {
const auto& it = map.find(key);
if (it == map.end()) return false;
*out = it->second;
return true;
}
+
+template <typename T>
+set<android::String16> getKeys(const map<android::String16, T>& map) {
+ if (map.empty()) return set<android::String16>();
+ set<android::String16> keys;
+ for (const auto& key_value_pair : map) {
+ keys.emplace(key_value_pair.first);
+ }
+ return keys;
+}
} // namespace
namespace android {
@@ -78,7 +91,7 @@
#define RETURN_IF_ENTRY_ERASED(map, key) \
{ \
- size_t num_erased = map.erase(key); \
+ size_t num_erased = (map).erase(key); \
if (num_erased) { \
ALOGE("Failed at %s:%d (%s)", __FILE__, __LINE__, __func__); \
return num_erased; \
@@ -188,27 +201,27 @@
mStringMap[key] = value;
}
-void PersistableBundle::putBooleanVector(const String16& key, const std::vector<bool>& value) {
+void PersistableBundle::putBooleanVector(const String16& key, const vector<bool>& value) {
erase(key);
mBoolVectorMap[key] = value;
}
-void PersistableBundle::putIntVector(const String16& key, const std::vector<int32_t>& value) {
+void PersistableBundle::putIntVector(const String16& key, const vector<int32_t>& value) {
erase(key);
mIntVectorMap[key] = value;
}
-void PersistableBundle::putLongVector(const String16& key, const std::vector<int64_t>& value) {
+void PersistableBundle::putLongVector(const String16& key, const vector<int64_t>& value) {
erase(key);
mLongVectorMap[key] = value;
}
-void PersistableBundle::putDoubleVector(const String16& key, const std::vector<double>& value) {
+void PersistableBundle::putDoubleVector(const String16& key, const vector<double>& value) {
erase(key);
mDoubleVectorMap[key] = value;
}
-void PersistableBundle::putStringVector(const String16& key, const std::vector<String16>& value) {
+void PersistableBundle::putStringVector(const String16& key, const vector<String16>& value) {
erase(key);
mStringVectorMap[key] = value;
}
@@ -238,23 +251,23 @@
return getValue(key, out, mStringMap);
}
-bool PersistableBundle::getBooleanVector(const String16& key, std::vector<bool>* out) const {
+bool PersistableBundle::getBooleanVector(const String16& key, vector<bool>* out) const {
return getValue(key, out, mBoolVectorMap);
}
-bool PersistableBundle::getIntVector(const String16& key, std::vector<int32_t>* out) const {
+bool PersistableBundle::getIntVector(const String16& key, vector<int32_t>* out) const {
return getValue(key, out, mIntVectorMap);
}
-bool PersistableBundle::getLongVector(const String16& key, std::vector<int64_t>* out) const {
+bool PersistableBundle::getLongVector(const String16& key, vector<int64_t>* out) const {
return getValue(key, out, mLongVectorMap);
}
-bool PersistableBundle::getDoubleVector(const String16& key, std::vector<double>* out) const {
+bool PersistableBundle::getDoubleVector(const String16& key, vector<double>* out) const {
return getValue(key, out, mDoubleVectorMap);
}
-bool PersistableBundle::getStringVector(const String16& key, std::vector<String16>* out) const {
+bool PersistableBundle::getStringVector(const String16& key, vector<String16>* out) const {
return getValue(key, out, mStringVectorMap);
}
@@ -262,6 +275,50 @@
return getValue(key, out, mPersistableBundleMap);
}
+set<String16> PersistableBundle::getBooleanKeys() const {
+ return getKeys(mBoolMap);
+}
+
+set<String16> PersistableBundle::getIntKeys() const {
+ return getKeys(mIntMap);
+}
+
+set<String16> PersistableBundle::getLongKeys() const {
+ return getKeys(mLongMap);
+}
+
+set<String16> PersistableBundle::getDoubleKeys() const {
+ return getKeys(mDoubleMap);
+}
+
+set<String16> PersistableBundle::getStringKeys() const {
+ return getKeys(mStringMap);
+}
+
+set<String16> PersistableBundle::getBooleanVectorKeys() const {
+ return getKeys(mBoolVectorMap);
+}
+
+set<String16> PersistableBundle::getIntVectorKeys() const {
+ return getKeys(mIntVectorMap);
+}
+
+set<String16> PersistableBundle::getLongVectorKeys() const {
+ return getKeys(mLongVectorMap);
+}
+
+set<String16> PersistableBundle::getDoubleVectorKeys() const {
+ return getKeys(mDoubleVectorMap);
+}
+
+set<String16> PersistableBundle::getStringVectorKeys() const {
+ return getKeys(mStringVectorMap);
+}
+
+set<String16> PersistableBundle::getPersistableBundleKeys() const {
+ return getKeys(mPersistableBundleMap);
+}
+
status_t PersistableBundle::writeToParcelInner(Parcel* parcel) const {
/*
* To keep this implementation in sync with writeArrayMapInternal() in
@@ -363,7 +420,6 @@
RETURN_IF_FAILED(parcel->readInt32(&num_entries));
for (; num_entries > 0; --num_entries) {
- size_t start_pos = parcel->dataPosition();
String16 key;
int32_t value_type;
RETURN_IF_FAILED(parcel->readString16(&key));
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index f13f49f..d42bb82 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -16,8 +16,6 @@
#define LOG_TAG "ProcessState"
-#include <cutils/process_name.h>
-
#include <binder/ProcessState.h>
#include <utils/Atomic.h>
@@ -52,7 +50,7 @@
class PoolThread : public Thread
{
public:
- PoolThread(bool isMain)
+ explicit PoolThread(bool isMain)
: mIsMain(isMain)
{
}
@@ -366,6 +364,13 @@
ProcessState::~ProcessState()
{
+ if (mDriverFD >= 0) {
+ if (mVMStart != MAP_FAILED) {
+ munmap(mVMStart, BINDER_VM_SIZE);
+ }
+ close(mDriverFD);
+ }
+ mDriverFD = -1;
}
}; // namespace android
diff --git a/libs/binder/Static.cpp b/libs/binder/Static.cpp
index cd9509f..f0613d1 100644
--- a/libs/binder/Static.cpp
+++ b/libs/binder/Static.cpp
@@ -48,7 +48,7 @@
class FdTextOutput : public BufferedTextOutput
{
public:
- FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { }
+ explicit FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { }
virtual ~FdTextOutput() { };
protected:
diff --git a/libs/binder/Status.cpp b/libs/binder/Status.cpp
index d3520d6..8466863 100644
--- a/libs/binder/Status.cpp
+++ b/libs/binder/Status.cpp
@@ -32,6 +32,11 @@
return Status(exceptionCode, OK, message);
}
+Status Status::fromExceptionCode(int32_t exceptionCode,
+ const char* message) {
+ return fromExceptionCode(exceptionCode, String8(message));
+}
+
Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode) {
return Status(EX_SERVICE_SPECIFIC, serviceSpecificErrorCode);
}
@@ -41,6 +46,11 @@
return Status(EX_SERVICE_SPECIFIC, serviceSpecificErrorCode, message);
}
+Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode,
+ const char* message) {
+ return fromServiceSpecificError(serviceSpecificErrorCode, String8(message));
+}
+
Status Status::fromStatusT(status_t status) {
Status ret;
ret.setFromStatusT(status);
@@ -158,5 +168,10 @@
return ret;
}
+std::stringstream& operator<< (std::stringstream& stream, const Status& s) {
+ stream << s.toString8().string();
+ return stream;
+}
+
} // namespace binder
} // namespace android
diff --git a/libs/binder/TextOutput.cpp b/libs/binder/TextOutput.cpp
index 2ed5188..101eba3 100644
--- a/libs/binder/TextOutput.cpp
+++ b/libs/binder/TextOutput.cpp
@@ -29,111 +29,14 @@
// ---------------------------------------------------------------------------
-TextOutput::TextOutput() {
+TextOutput::TextOutput() {
}
-TextOutput::~TextOutput() {
+TextOutput::~TextOutput() {
}
// ---------------------------------------------------------------------------
-TextOutput& operator<<(TextOutput& to, bool val)
-{
- if (val) to.print("true", 4);
- else to.print("false", 5);
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, int val)
-{
- char buf[16];
- sprintf(buf, "%d", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, long val)
-{
- char buf[16];
- sprintf(buf, "%ld", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, unsigned int val)
-{
- char buf[16];
- sprintf(buf, "%u", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, unsigned long val)
-{
- char buf[16];
- sprintf(buf, "%lu", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, long long val)
-{
- char buf[32];
- sprintf(buf, "%Ld", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, unsigned long long val)
-{
- char buf[32];
- sprintf(buf, "%Lu", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-static TextOutput& print_float(TextOutput& to, double value)
-{
- char buf[64];
- sprintf(buf, "%g", value);
- if( !strchr(buf, '.') && !strchr(buf, 'e') &&
- !strchr(buf, 'E') ) {
- strncat(buf, ".0", sizeof(buf)-1);
- }
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, float val)
-{
- return print_float(to,val);
-}
-
-TextOutput& operator<<(TextOutput& to, double val)
-{
- return print_float(to,val);
-}
-
-TextOutput& operator<<(TextOutput& to, const void* val)
-{
- char buf[32];
- snprintf(buf, sizeof(buf), "%p", val);
- to.print(buf, strlen(buf));
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, const String8& val)
-{
- to << val.string();
- return to;
-}
-
-TextOutput& operator<<(TextOutput& to, const String16& val)
-{
- to << String8(val).string();
- return to;
-}
-
static void textOutputPrinter(void* cookie, const char* txt)
{
((TextOutput*)cookie)->print(txt, strlen(txt));
diff --git a/libs/binder/tests/Android.bp b/libs/binder/tests/Android.bp
new file mode 100644
index 0000000..2152206
--- /dev/null
+++ b/libs/binder/tests/Android.bp
@@ -0,0 +1,63 @@
+//
+// 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.
+//
+
+cc_test {
+ product_variables: {
+ binder32bit: {
+ cflags: ["-DBINDER_IPC_32BIT=1"],
+ },
+ },
+
+ name: "binderDriverInterfaceTest",
+ srcs: ["binderDriverInterfaceTest.cpp"],
+}
+
+cc_test {
+ name: "binderLibTest",
+ srcs: ["binderLibTest.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libutils",
+ ],
+}
+
+cc_test {
+ name: "binderThroughputTest",
+ srcs: ["binderThroughputTest.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libutils",
+ ],
+ clang: true,
+ cflags: [
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
+ "-O3",
+ ],
+}
+
+cc_test {
+ name: "binderTextOutputTest",
+ srcs: ["binderTextOutputTest.cpp"],
+ shared_libs: [
+ "libbinder",
+ "libutils",
+ "libbase",
+ ],
+}
diff --git a/libs/binder/tests/Android.mk b/libs/binder/tests/Android.mk
deleted file mode 100644
index a40523d..0000000
--- a/libs/binder/tests/Android.mk
+++ /dev/null
@@ -1,42 +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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-ifneq ($(TARGET_USES_64_BIT_BINDER),true)
-ifneq ($(TARGET_IS_64_BIT),true)
-LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1
-endif
-endif
-
-LOCAL_MODULE := binderDriverInterfaceTest
-LOCAL_SRC_FILES := binderDriverInterfaceTest.cpp
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := binderLibTest
-LOCAL_SRC_FILES := binderLibTest.cpp
-LOCAL_SHARED_LIBRARIES := libbinder libutils
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := binderThroughputTest
-LOCAL_SRC_FILES := binderThroughputTest.cpp
-LOCAL_SHARED_LIBRARIES := libbinder libutils
-LOCAL_CLANG := true
-LOCAL_CFLAGS += -g -Wall -Werror -std=c++11 -Wno-missing-field-initializers -Wno-sign-compare -O3
-include $(BUILD_NATIVE_TEST)
diff --git a/libs/binder/tests/binderDriverInterfaceTest.cpp b/libs/binder/tests/binderDriverInterfaceTest.cpp
index 0277550..ff5912f 100644
--- a/libs/binder/tests/binderDriverInterfaceTest.cpp
+++ b/libs/binder/tests/binderDriverInterfaceTest.cpp
@@ -20,7 +20,7 @@
#include <stdlib.h>
#include <gtest/gtest.h>
-#include <linux/binder.h>
+#include <linux/android/binder.h>
#include <binder/IBinder.h>
#include <sys/mman.h>
#include <poll.h>
@@ -229,7 +229,9 @@
.sender_euid = 0,
.data_size = 0,
.offsets_size = 0,
- .data = {0, 0},
+ .data = {
+ .ptr = {0, 0},
+ },
},
};
struct {
@@ -350,4 +352,3 @@
return RUN_ALL_TESTS();
}
-
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp
index 3df3acf..54e12b6 100644
--- a/libs/binder/tests/binderLibTest.cpp
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -34,6 +34,7 @@
static testing::Environment* binder_env;
static char *binderservername;
+static char *binderserversuffix;
static char binderserverarg[] = "--binderserver";
static String16 binderLibTestServiceName = String16("test.binderLib");
@@ -70,6 +71,7 @@
binderserverarg,
stri,
strpipefd1,
+ binderserversuffix,
NULL
};
@@ -252,14 +254,10 @@
int ret;
pthread_mutex_lock(&m_waitMutex);
if (!m_eventTriggered) {
-#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE)
- pthread_cond_timeout_np(&m_waitCond, &m_waitMutex, timeout_s * 1000);
-#else
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += timeout_s;
pthread_cond_timedwait(&m_waitCond, &m_waitMutex, &ts);
-#endif
}
ret = m_eventTriggered ? NO_ERROR : TIMED_OUT;
pthread_mutex_unlock(&m_waitMutex);
@@ -739,14 +737,10 @@
}
if (ret > 0) {
if (m_serverStartRequested) {
-#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE)
- ret = pthread_cond_timeout_np(&m_serverWaitCond, &m_serverWaitMutex, 5000);
-#else
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += 5;
ret = pthread_cond_timedwait(&m_serverWaitCond, &m_serverWaitMutex, &ts);
-#endif
}
if (m_serverStartRequested) {
m_serverStartRequested = false;
@@ -906,6 +900,8 @@
int run_server(int index, int readypipefd)
{
+ binderLibTestServiceName += String16(binderserversuffix);
+
status_t ret;
sp<IServiceManager> sm = defaultServiceManager();
{
@@ -936,15 +932,19 @@
int main(int argc, char **argv) {
int ret;
- if (argc == 3 && !strcmp(argv[1], "--servername")) {
+ if (argc == 4 && !strcmp(argv[1], "--servername")) {
binderservername = argv[2];
} else {
binderservername = argv[0];
}
- if (argc == 4 && !strcmp(argv[1], binderserverarg)) {
+ if (argc == 5 && !strcmp(argv[1], binderserverarg)) {
+ binderserversuffix = argv[4];
return run_server(atoi(argv[2]), atoi(argv[3]));
}
+ binderserversuffix = new char[16];
+ snprintf(binderserversuffix, 16, "%d", getpid());
+ binderLibTestServiceName += String16(binderserversuffix);
::testing::InitGoogleTest(&argc, argv);
binder_env = AddGlobalTestEnvironment(new BinderLibTestEnv());
diff --git a/libs/binder/tests/binderTextOutputTest.cpp b/libs/binder/tests/binderTextOutputTest.cpp
new file mode 100644
index 0000000..f6dd22d
--- /dev/null
+++ b/libs/binder/tests/binderTextOutputTest.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits>
+#include <cstddef>
+
+#include "android-base/file.h"
+#include "android-base/test_utils.h"
+#include <gtest/gtest.h>
+
+#include <binder/Parcel.h>
+#include <binder/TextOutput.h>
+#include <binder/Debug.h>
+
+static void CheckMessage(const CapturedStderr& cap,
+ const char* expected,
+ bool singleline) {
+ std::string output;
+ ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
+ android::base::ReadFdToString(cap.fd(), &output);
+ if (singleline)
+ output.erase(std::remove(output.begin(), output.end(), '\n'));
+ ASSERT_STREQ(output.c_str(), expected);
+}
+
+#define CHECK_LOG_(input, expect, singleline) \
+{ \
+ CapturedStderr cap; \
+ android::aerr << input << android::endl; \
+ CheckMessage(cap, expect, singleline); \
+} \
+
+#define CHECK_VAL_(val, singleline) \
+{ \
+ std::stringstream ss; \
+ ss << val; \
+ std::string s = ss.str(); \
+ CHECK_LOG_(val, s.c_str(), singleline); \
+} \
+
+#define CHECK_LOG(input, expect) CHECK_LOG_(input, expect, true)
+#define CHECK_VAL(val) CHECK_VAL_(val, true)
+
+TEST(TextOutput, HandlesStdEndl) {
+ CapturedStderr cap;
+ android::aerr << "foobar" << std::endl;
+ std::string output;
+ ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
+ android::base::ReadFdToString(cap.fd(), &output);
+ ASSERT_STREQ(output.c_str(), "foobar\n");
+}
+
+TEST(TextOutput, HandlesCEndl) {
+ CapturedStderr cap;
+ android::aerr << "foobar" << "\n";
+ std::string output;
+ ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
+ android::base::ReadFdToString(cap.fd(), &output);
+ ASSERT_STREQ(output.c_str(), "foobar\n");
+}
+
+TEST(TextOutput, HandlesAndroidEndl) {
+ CapturedStderr cap;
+ android::aerr << "foobar" << android::endl;
+ std::string output;
+ ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
+ android::base::ReadFdToString(cap.fd(), &output);
+ ASSERT_STREQ(output.c_str(), "foobar\n");
+}
+
+TEST(TextOutput, HandleEmptyString) {
+ CHECK_LOG("", "");
+}
+
+TEST(TextOutput, HandleString) {
+ CHECK_LOG("foobar", "foobar");
+}
+
+TEST(TextOutput, HandleNum) {
+ CHECK_LOG(12345, "12345");
+}
+
+TEST(TextOutput, HandleBool) {
+ CHECK_LOG(false, "false");
+}
+
+TEST(TextOutput, HandleChar) {
+ CHECK_LOG('T', "T");
+}
+
+TEST(TextOutput, HandleParcel) {
+ android::Parcel val;
+ CHECK_LOG(val, "Parcel(NULL)");
+}
+
+TEST(TextOutput, HandleHexDump) {
+ const char buf[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+ android::HexDump val(buf, sizeof(buf));
+ CHECK_LOG(val, "03020100 07060504 0b0a0908 0f0e0d0c '................'");
+}
+
+TEST(TextOutput, HandleHexDumpCustom) {
+ const char buf[4] = {0x11,0x22,0x33,0x44};
+ android::HexDump val(buf, sizeof(buf), 4);
+ CHECK_LOG(val, "11 22 33 44 '.\"3D'");
+}
+
+TEST(TextOutput, HandleTypeCode) {
+ android::TypeCode val(1234);
+ CHECK_LOG(val, "'\\x04\\xd2'");
+}
+
+TEST(TextOutput, HandleCookie) {
+ int32_t val = 321; //0x141
+ CHECK_LOG((void*)(long)val, "0x141");
+}
+
+TEST(TextOutput, HandleString8) {
+ android::String8 val("foobar");
+ CHECK_LOG(val, "foobar");
+}
+
+TEST(TextOutput, HandleString16) {
+ android::String16 val("foobar");
+ CHECK_LOG(val, "foobar");
+}
+
+template <typename T>
+class TextTest : public testing::Test {};
+
+typedef testing::Types<short, unsigned short,
+ int, unsigned int,
+ long, unsigned long,
+ long long, unsigned long long,
+ float, double, long double> TestTypes;
+TYPED_TEST_CASE(TextTest, TestTypes);
+
+TYPED_TEST(TextTest, TextMax)
+{
+ TypeParam max = std::numeric_limits<TypeParam>::max();
+ CHECK_VAL(max);
+}
+
+TYPED_TEST(TextTest, TestMin)
+{
+ TypeParam min = std::numeric_limits<TypeParam>::min();
+ CHECK_VAL(min);
+}
+
+TYPED_TEST(TextTest, TestDenom)
+{
+ TypeParam min = std::numeric_limits<TypeParam>::denorm_min();
+ CHECK_VAL(min);
+}
+
+TYPED_TEST(TextTest, TestEpsilon)
+{
+ TypeParam eps = std::numeric_limits<TypeParam>::epsilon();
+ CHECK_VAL(eps);
+}
diff --git a/libs/diskusage/Android.bp b/libs/diskusage/Android.bp
new file mode 100644
index 0000000..156ddff
--- /dev/null
+++ b/libs/diskusage/Android.bp
@@ -0,0 +1,18 @@
+// 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.
+
+cc_library_static {
+ name: "libdiskusage",
+ srcs: ["dirsize.c"],
+}
diff --git a/libs/diskusage/Android.mk b/libs/diskusage/Android.mk
deleted file mode 100644
index d54f8ad..0000000
--- a/libs/diskusage/Android.mk
+++ /dev/null
@@ -1,24 +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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libdiskusage
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := dirsize.c
-
-include $(BUILD_STATIC_LIBRARY)
\ No newline at end of file
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
new file mode 100644
index 0000000..8e8bb80
--- /dev/null
+++ b/libs/gui/Android.bp
@@ -0,0 +1,111 @@
+// Copyright 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.
+
+cc_library_shared {
+ name: "libgui",
+
+ clang: true,
+ cppflags: [
+ "-Weverything",
+ "-Werror",
+
+ // The static constructors and destructors in this library have not been noted to
+ // introduce significant overheads
+ "-Wno-exit-time-destructors",
+ "-Wno-global-constructors",
+
+ // We only care about compiling as C++14
+ "-Wno-c++98-compat-pedantic",
+
+ // We don't need to enumerate every case in a switch as long as a default case
+ // is present
+ "-Wno-switch-enum",
+
+ // Allow calling variadic macros without a __VA_ARGS__ list
+ "-Wno-gnu-zero-variadic-macro-arguments",
+
+ // Don't warn about struct padding
+ "-Wno-padded",
+
+ // android/sensors.h uses nested anonymous unions and anonymous structs
+ "-Wno-nested-anon-types",
+ "-Wno-gnu-anonymous-struct",
+
+ "-DDEBUG_ONLY_CODE=0",
+ ],
+
+ product_variables: {
+ brillo: {
+ cflags: ["-DHAVE_NO_SURFACE_FLINGER"],
+ },
+ debuggable: {
+ cppflags: [
+ "-UDEBUG_ONLY_CODE",
+ "-DDEBUG_ONLY_CODE=1",
+ ],
+ },
+ },
+
+ srcs: [
+ "IGraphicBufferConsumer.cpp",
+ "IConsumerListener.cpp",
+ "BitTube.cpp",
+ "BufferItem.cpp",
+ "BufferItemConsumer.cpp",
+ "BufferQueue.cpp",
+ "BufferQueueConsumer.cpp",
+ "BufferQueueCore.cpp",
+ "BufferQueueProducer.cpp",
+ "BufferSlot.cpp",
+ "ConsumerBase.cpp",
+ "CpuConsumer.cpp",
+ "DisplayEventReceiver.cpp",
+ "GLConsumer.cpp",
+ "GraphicBufferAlloc.cpp",
+ "GuiConfig.cpp",
+ "IDisplayEventConnection.cpp",
+ "IGraphicBufferAlloc.cpp",
+ "IGraphicBufferProducer.cpp",
+ "IProducerListener.cpp",
+ "ISensorEventConnection.cpp",
+ "ISensorServer.cpp",
+ "ISurfaceComposer.cpp",
+ "ISurfaceComposerClient.cpp",
+ "LayerState.cpp",
+ "OccupancyTracker.cpp",
+ "Sensor.cpp",
+ "SensorEventQueue.cpp",
+ "SensorManager.cpp",
+ "StreamSplitter.cpp",
+ "Surface.cpp",
+ "SurfaceControl.cpp",
+ "SurfaceComposerClient.cpp",
+ "SyncFeatures.cpp",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ "libcutils",
+ "libEGL",
+ "libGLESv2",
+ "libsync",
+ "libui",
+ "libutils",
+ "liblog",
+ ],
+
+ export_shared_lib_headers: ["libbinder"],
+}
+
+subdirs = ["tests"]
diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk
deleted file mode 100644
index 46feb1c..0000000
--- a/libs/gui/Android.mk
+++ /dev/null
@@ -1,101 +0,0 @@
-# Copyright 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.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CLANG := true
-LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror
-
-# The static constructors and destructors in this library have not been noted to
-# introduce significant overheads
-LOCAL_CPPFLAGS += -Wno-exit-time-destructors
-LOCAL_CPPFLAGS += -Wno-global-constructors
-
-# We only care about compiling as C++14
-LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic
-
-# We don't need to enumerate every case in a switch as long as a default case
-# is present
-LOCAL_CPPFLAGS += -Wno-switch-enum
-
-# Allow calling variadic macros without a __VA_ARGS__ list
-LOCAL_CPPFLAGS += -Wno-gnu-zero-variadic-macro-arguments
-
-# Don't warn about struct padding
-LOCAL_CPPFLAGS += -Wno-padded
-
-LOCAL_CPPFLAGS += -DDEBUG_ONLY_CODE=$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),1,0)
-
-LOCAL_SRC_FILES := \
- IGraphicBufferConsumer.cpp \
- IConsumerListener.cpp \
- BitTube.cpp \
- BufferItem.cpp \
- BufferItemConsumer.cpp \
- BufferQueue.cpp \
- BufferQueueConsumer.cpp \
- BufferQueueCore.cpp \
- BufferQueueProducer.cpp \
- BufferSlot.cpp \
- ConsumerBase.cpp \
- CpuConsumer.cpp \
- DisplayEventReceiver.cpp \
- GLConsumer.cpp \
- GraphicBufferAlloc.cpp \
- GuiConfig.cpp \
- IDisplayEventConnection.cpp \
- IGraphicBufferAlloc.cpp \
- IGraphicBufferProducer.cpp \
- IProducerListener.cpp \
- ISensorEventConnection.cpp \
- ISensorServer.cpp \
- ISurfaceComposer.cpp \
- ISurfaceComposerClient.cpp \
- LayerState.cpp \
- OccupancyTracker.cpp \
- Sensor.cpp \
- SensorEventQueue.cpp \
- SensorManager.cpp \
- StreamSplitter.cpp \
- Surface.cpp \
- SurfaceControl.cpp \
- SurfaceComposerClient.cpp \
- SyncFeatures.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libcutils \
- libEGL \
- libGLESv2 \
- libsync \
- libui \
- libutils \
- liblog
-
-
-LOCAL_MODULE := libgui
-
-ifeq ($(TARGET_BOARD_PLATFORM), tegra)
- LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC
-endif
-ifeq ($(TARGET_BOARD_PLATFORM), tegra3)
- LOCAL_CFLAGS += -DDONT_USE_FENCE_SYNC
-endif
-
-include $(BUILD_SHARED_LIBRARY)
-
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/libs/gui/BufferItem.cpp b/libs/gui/BufferItem.cpp
index 5e3924a..1357a4a 100644
--- a/libs/gui/BufferItem.cpp
+++ b/libs/gui/BufferItem.cpp
@@ -23,6 +23,21 @@
namespace android {
+template<typename T>
+static inline constexpr uint32_t low32(const T n) {
+ return static_cast<uint32_t>(static_cast<uint64_t>(n));
+}
+
+template<typename T>
+static inline constexpr uint32_t high32(const T n) {
+ return static_cast<uint32_t>(static_cast<uint64_t>(n)>>32);
+}
+
+template<typename T>
+static inline constexpr T to64(const uint32_t lo, const uint32_t hi) {
+ return static_cast<T>(static_cast<uint64_t>(hi)<<32 | lo);
+}
+
BufferItem::BufferItem() :
mGraphicBuffer(NULL),
mFence(NULL),
@@ -56,12 +71,12 @@
addAligned(size, mCrop);
addAligned(size, mTransform);
addAligned(size, mScalingMode);
- addAligned(size, mTimestampLo);
- addAligned(size, mTimestampHi);
+ addAligned(size, low32(mTimestamp));
+ addAligned(size, high32(mTimestamp));
addAligned(size, mIsAutoTimestamp);
addAligned(size, mDataSpace);
- addAligned(size, mFrameNumberLo);
- addAligned(size, mFrameNumberHi);
+ addAligned(size, low32(mFrameNumber));
+ addAligned(size, high32(mFrameNumber));
addAligned(size, mSlot);
addAligned(size, mIsDroppable);
addAligned(size, mAcquireCalled);
@@ -141,12 +156,12 @@
writeAligned(buffer, size, mCrop);
writeAligned(buffer, size, mTransform);
writeAligned(buffer, size, mScalingMode);
- writeAligned(buffer, size, mTimestampLo);
- writeAligned(buffer, size, mTimestampHi);
+ writeAligned(buffer, size, low32(mTimestamp));
+ writeAligned(buffer, size, high32(mTimestamp));
writeAligned(buffer, size, mIsAutoTimestamp);
writeAligned(buffer, size, mDataSpace);
- writeAligned(buffer, size, mFrameNumberLo);
- writeAligned(buffer, size, mFrameNumberHi);
+ writeAligned(buffer, size, low32(mFrameNumber));
+ writeAligned(buffer, size, high32(mFrameNumber));
writeAligned(buffer, size, mSlot);
writeAligned(buffer, size, mIsDroppable);
writeAligned(buffer, size, mAcquireCalled);
@@ -194,15 +209,20 @@
return NO_MEMORY;
}
+ uint32_t timestampLo = 0, timestampHi = 0;
+ uint32_t frameNumberLo = 0, frameNumberHi = 0;
+
readAligned(buffer, size, mCrop);
readAligned(buffer, size, mTransform);
readAligned(buffer, size, mScalingMode);
- readAligned(buffer, size, mTimestampLo);
- readAligned(buffer, size, mTimestampHi);
+ readAligned(buffer, size, timestampLo);
+ readAligned(buffer, size, timestampHi);
+ mTimestamp = to64<int64_t>(timestampLo, timestampHi);
readAligned(buffer, size, mIsAutoTimestamp);
readAligned(buffer, size, mDataSpace);
- readAligned(buffer, size, mFrameNumberLo);
- readAligned(buffer, size, mFrameNumberHi);
+ readAligned(buffer, size, frameNumberLo);
+ readAligned(buffer, size, frameNumberHi);
+ mFrameNumber = to64<uint64_t>(frameNumberLo, frameNumberHi);
readAligned(buffer, size, mSlot);
readAligned(buffer, size, mIsDroppable);
readAligned(buffer, size, mAcquireCalled);
diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp
index 73d2042..ee4c58c 100644
--- a/libs/gui/BufferQueueConsumer.cpp
+++ b/libs/gui/BufferQueueConsumer.cpp
@@ -259,7 +259,8 @@
// decrease.
mCore->mDequeueCondition.broadcast();
- ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
+ ATRACE_INT(mCore->mConsumerName.string(),
+ static_cast<int32_t>(mCore->mQueue.size()));
mCore->mOccupancyTracker.registerOccupancyChange(mCore->mQueue.size());
VALIDATE_CONSISTENCY();
@@ -732,7 +733,7 @@
return NO_ERROR;
}
-void BufferQueueConsumer::dump(String8& result, const char* prefix) const {
+void BufferQueueConsumer::dumpState(String8& result, const char* prefix) const {
const IPCThreadState* ipc = IPCThreadState::self();
const pid_t pid = ipc->getCallingPid();
const uid_t uid = ipc->getCallingUid();
@@ -741,9 +742,10 @@
"android.permission.DUMP"), pid, uid)) {
result.appendFormat("Permission Denial: can't dump BufferQueueConsumer "
"from pid=%d, uid=%d\n", pid, uid);
- android_errorWriteWithInfoLog(0x534e4554, "27046057", uid, NULL, 0);
+ android_errorWriteWithInfoLog(0x534e4554, "27046057",
+ static_cast<int32_t>(uid), NULL, 0);
} else {
- mCore->dump(result, prefix);
+ mCore->dumpState(result, prefix);
}
}
diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp
index c4714e3..6e6cce2 100644
--- a/libs/gui/BufferQueueCore.cpp
+++ b/libs/gui/BufferQueueCore.cpp
@@ -28,8 +28,11 @@
#include <inttypes.h>
+#include <cutils/properties.h>
+
#include <gui/BufferItem.h>
#include <gui/BufferQueueCore.h>
+#include <gui/GraphicBufferAlloc.h>
#include <gui/IConsumerListener.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/IProducerListener.h>
@@ -94,8 +97,24 @@
mUniqueId(getUniqueId())
{
if (allocator == NULL) {
- sp<ISurfaceComposer> composer(ComposerService::getComposerService());
- mAllocator = composer->createGraphicBufferAlloc();
+
+#ifdef HAVE_NO_SURFACE_FLINGER
+ // Without a SurfaceFlinger, allocate in-process. This only makes
+ // sense in systems with static SELinux configurations and no
+ // applications (since applications need dynamic SELinux policy).
+ mAllocator = new GraphicBufferAlloc();
+#else
+ // Run time check for headless, where we also allocate in-process.
+ char value[PROPERTY_VALUE_MAX];
+ property_get("config.headless", value, "0");
+ if (atoi(value) == 1) {
+ mAllocator = new GraphicBufferAlloc();
+ } else {
+ sp<ISurfaceComposer> composer(ComposerService::getComposerService());
+ mAllocator = composer->createGraphicBufferAlloc();
+ }
+#endif // HAVE_NO_SURFACE_FLINGER
+
if (mAllocator == NULL) {
BQ_LOGE("createGraphicBufferAlloc failed");
}
@@ -113,7 +132,7 @@
BufferQueueCore::~BufferQueueCore() {}
-void BufferQueueCore::dump(String8& result, const char* prefix) const {
+void BufferQueueCore::dumpState(String8& result, const char* prefix) const {
Mutex::Autolock lock(mMutex);
String8 fifo;
diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp
index b2169c8..13b900c 100644
--- a/libs/gui/BufferQueueProducer.cpp
+++ b/libs/gui/BufferQueueProducer.cpp
@@ -905,7 +905,8 @@
static_cast<uint32_t>(mCore->mQueue.size()),
mCore->mFrameCounter + 1);
- ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
+ ATRACE_INT(mCore->mConsumerName.string(),
+ static_cast<int32_t>(mCore->mQueue.size()));
mCore->mOccupancyTracker.registerOccupancyChange(mCore->mQueue.size());
// Take a ticket for the callback functions
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp
index 65e4fee..3cf3078 100644
--- a/libs/gui/ConsumerBase.cpp
+++ b/libs/gui/ConsumerBase.cpp
@@ -254,11 +254,11 @@
return mConsumer->discardFreeBuffers();
}
-void ConsumerBase::dump(String8& result) const {
- dump(result, "");
+void ConsumerBase::dumpState(String8& result) const {
+ dumpState(result, "");
}
-void ConsumerBase::dump(String8& result, const char* prefix) const {
+void ConsumerBase::dumpState(String8& result, const char* prefix) const {
Mutex::Autolock _l(mMutex);
dumpLocked(result, prefix);
}
@@ -267,7 +267,7 @@
result.appendFormat("%smAbandoned=%d\n", prefix, int(mAbandoned));
if (!mAbandoned) {
- mConsumer->dump(result, prefix);
+ mConsumer->dumpState(result, prefix);
}
}
diff --git a/libs/gui/IConsumerListener.cpp b/libs/gui/IConsumerListener.cpp
index 9a06011..ff7b83a 100644
--- a/libs/gui/IConsumerListener.cpp
+++ b/libs/gui/IConsumerListener.cpp
@@ -37,7 +37,7 @@
class BpConsumerListener : public BpInterface<IConsumerListener>
{
public:
- BpConsumerListener(const sp<IBinder>& impl)
+ explicit BpConsumerListener(const sp<IBinder>& impl)
: BpInterface<IConsumerListener>(impl) {
}
@@ -153,6 +153,7 @@
return BBinder::onTransact(code, data, reply, flags);
}
+ConsumerListener::~ConsumerListener() = default;
// ---------------------------------------------------------------------------
}; // namespace android
diff --git a/libs/gui/IDisplayEventConnection.cpp b/libs/gui/IDisplayEventConnection.cpp
index 9890f44..b1d3b00 100644
--- a/libs/gui/IDisplayEventConnection.cpp
+++ b/libs/gui/IDisplayEventConnection.cpp
@@ -39,7 +39,7 @@
class BpDisplayEventConnection : public BpInterface<IDisplayEventConnection>
{
public:
- BpDisplayEventConnection(const sp<IBinder>& impl)
+ explicit BpDisplayEventConnection(const sp<IBinder>& impl)
: BpInterface<IDisplayEventConnection>(impl)
{
}
diff --git a/libs/gui/IGraphicBufferAlloc.cpp b/libs/gui/IGraphicBufferAlloc.cpp
index 7b3b7c1..2fb380c 100644
--- a/libs/gui/IGraphicBufferAlloc.cpp
+++ b/libs/gui/IGraphicBufferAlloc.cpp
@@ -37,7 +37,7 @@
class BpGraphicBufferAlloc : public BpInterface<IGraphicBufferAlloc>
{
public:
- BpGraphicBufferAlloc(const sp<IBinder>& impl)
+ explicit BpGraphicBufferAlloc(const sp<IBinder>& impl)
: BpInterface<IGraphicBufferAlloc>(impl)
{
}
@@ -96,7 +96,7 @@
class BufferReference : public BBinder {
sp<GraphicBuffer> mBuffer;
public:
- BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
+ explicit BufferReference(const sp<GraphicBuffer>& buffer) : mBuffer(buffer) {}
};
diff --git a/libs/gui/IGraphicBufferConsumer.cpp b/libs/gui/IGraphicBufferConsumer.cpp
index c8eff00..2401464 100644
--- a/libs/gui/IGraphicBufferConsumer.cpp
+++ b/libs/gui/IGraphicBufferConsumer.cpp
@@ -60,7 +60,7 @@
class BpGraphicBufferConsumer : public BpInterface<IGraphicBufferConsumer>
{
public:
- BpGraphicBufferConsumer(const sp<IBinder>& impl)
+ explicit BpGraphicBufferConsumer(const sp<IBinder>& impl)
: BpInterface<IGraphicBufferConsumer>(impl)
{
}
@@ -302,7 +302,7 @@
return result;
}
- virtual void dump(String8& result, const char* prefix) const {
+ virtual void dumpState(String8& result, const char* prefix) const {
Parcel data, reply;
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
data.writeString8(result);
@@ -480,7 +480,7 @@
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
String8 result = data.readString8();
String8 prefix = data.readString8();
- static_cast<IGraphicBufferConsumer*>(this)->dump(result, prefix);
+ static_cast<IGraphicBufferConsumer*>(this)->dumpState(result, prefix);
reply->writeString8(result);
return NO_ERROR;
}
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp
index f4ba3bf..846c205 100644
--- a/libs/gui/IGraphicBufferProducer.cpp
+++ b/libs/gui/IGraphicBufferProducer.cpp
@@ -61,7 +61,7 @@
class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
{
public:
- BpGraphicBufferProducer(const sp<IBinder>& impl)
+ explicit BpGraphicBufferProducer(const sp<IBinder>& impl)
: BpInterface<IGraphicBufferProducer>(impl)
{
}
diff --git a/libs/gui/IProducerListener.cpp b/libs/gui/IProducerListener.cpp
index da54ce1..62abfa8 100644
--- a/libs/gui/IProducerListener.cpp
+++ b/libs/gui/IProducerListener.cpp
@@ -28,7 +28,7 @@
class BpProducerListener : public BpInterface<IProducerListener>
{
public:
- BpProducerListener(const sp<IBinder>& impl)
+ explicit BpProducerListener(const sp<IBinder>& impl)
: BpInterface<IProducerListener>(impl) {}
virtual ~BpProducerListener();
@@ -78,6 +78,10 @@
return BBinder::onTransact(code, data, reply, flags);
}
+ProducerListener::~ProducerListener() = default;
+
+DummyProducerListener::~DummyProducerListener() = default;
+
bool BnProducerListener::needsReleaseNotify() {
return true;
}
diff --git a/libs/gui/ISensorEventConnection.cpp b/libs/gui/ISensorEventConnection.cpp
index dc7a35c..59ecee7 100644
--- a/libs/gui/ISensorEventConnection.cpp
+++ b/libs/gui/ISensorEventConnection.cpp
@@ -40,7 +40,7 @@
class BpSensorEventConnection : public BpInterface<ISensorEventConnection>
{
public:
- BpSensorEventConnection(const sp<IBinder>& impl)
+ explicit BpSensorEventConnection(const sp<IBinder>& impl)
: BpInterface<ISensorEventConnection>(impl)
{
}
diff --git a/libs/gui/ISensorServer.cpp b/libs/gui/ISensorServer.cpp
index 3a4c7e4..07c507a 100644
--- a/libs/gui/ISensorServer.cpp
+++ b/libs/gui/ISensorServer.cpp
@@ -42,7 +42,7 @@
class BpSensorServer : public BpInterface<ISensorServer>
{
public:
- BpSensorServer(const sp<IBinder>& impl)
+ explicit BpSensorServer(const sp<IBinder>& impl)
: BpInterface<ISensorServer>(impl)
{
}
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index f0b0ada..0a8e6a5 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -49,7 +49,7 @@
class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
{
public:
- BpSurfaceComposer(const sp<IBinder>& impl)
+ explicit BpSurfaceComposer(const sp<IBinder>& impl)
: BpInterface<ISurfaceComposer>(impl)
{
}
diff --git a/libs/gui/ISurfaceComposerClient.cpp b/libs/gui/ISurfaceComposerClient.cpp
index dd5b169..47cb047 100644
--- a/libs/gui/ISurfaceComposerClient.cpp
+++ b/libs/gui/ISurfaceComposerClient.cpp
@@ -48,7 +48,7 @@
class BpSurfaceComposerClient : public BpInterface<ISurfaceComposerClient>
{
public:
- BpSurfaceComposerClient(const sp<IBinder>& impl)
+ explicit BpSurfaceComposerClient(const sp<IBinder>& impl)
: BpInterface<ISurfaceComposerClient>(impl) {
}
diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp
index 9fcf9ab..57c3073 100644
--- a/libs/gui/SensorManager.cpp
+++ b/libs/gui/SensorManager.cpp
@@ -139,7 +139,7 @@
mSensorManager.sensorManagerDied();
}
public:
- DeathObserver(SensorManager& mgr) : mSensorManager(mgr) { }
+ explicit DeathObserver(SensorManager& mgr) : mSensorManager(mgr) { }
};
LOG_ALWAYS_FATAL_IF(mSensorServer.get() == NULL, "getService(SensorService) NULL");
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 0838290..8e6ab1c 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -408,7 +408,7 @@
timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
isAutoTimestamp = true;
ALOGV("Surface::queueBuffer making up timestamp: %.2f ms",
- timestamp / 1000000.f);
+ timestamp / 1000000.0);
} else {
timestamp = mTimestamp;
}
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index b78de2e..43506e9 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -69,7 +69,7 @@
mComposerService.composerServiceDied();
}
public:
- DeathObserver(ComposerService& mgr) : mComposerService(mgr) { }
+ explicit DeathObserver(ComposerService& mgr) : mComposerService(mgr) { }
};
mDeathObserver = new DeathObserver(*const_cast<ComposerService*>(this));
diff --git a/libs/gui/tests/Android.bp b/libs/gui/tests/Android.bp
new file mode 100644
index 0000000..3c7958f
--- /dev/null
+++ b/libs/gui/tests/Android.bp
@@ -0,0 +1,42 @@
+// Build the unit tests,
+
+// Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+// to integrate with auto-test framework.
+cc_test {
+ name: "libgui_test",
+
+ clang: true,
+
+ srcs: [
+ "BufferQueue_test.cpp",
+ "CpuConsumer_test.cpp",
+ "FillBuffer.cpp",
+ "GLTest.cpp",
+ "IGraphicBufferProducer_test.cpp",
+ "MultiTextureConsumer_test.cpp",
+ "Sensor_test.cpp",
+ "SRGB_test.cpp",
+ "StreamSplitter_test.cpp",
+ "SurfaceTextureClient_test.cpp",
+ "SurfaceTextureFBO_test.cpp",
+ "SurfaceTextureGLThreadToGL_test.cpp",
+ "SurfaceTextureGLToGL_test.cpp",
+ "SurfaceTextureGL_test.cpp",
+ "SurfaceTextureMultiContextGL_test.cpp",
+ "Surface_test.cpp",
+ "TextureRenderer.cpp",
+ ],
+
+ shared_libs: [
+ "liblog",
+ "libEGL",
+ "libGLESv1_CM",
+ "libGLESv2",
+ "libbinder",
+ "libcutils",
+ "libgui",
+ "libsync",
+ "libui",
+ "libutils",
+ ],
+}
diff --git a/libs/gui/tests/Android.mk b/libs/gui/tests/Android.mk
deleted file mode 100644
index 6ad9986..0000000
--- a/libs/gui/tests/Android.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-# Build the unit tests,
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_CLANG := true
-
-LOCAL_MODULE := libgui_test
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := \
- BufferQueue_test.cpp \
- CpuConsumer_test.cpp \
- FillBuffer.cpp \
- GLTest.cpp \
- IGraphicBufferProducer_test.cpp \
- MultiTextureConsumer_test.cpp \
- SRGB_test.cpp \
- StreamSplitter_test.cpp \
- SurfaceTextureClient_test.cpp \
- SurfaceTextureFBO_test.cpp \
- SurfaceTextureGLThreadToGL_test.cpp \
- SurfaceTextureGLToGL_test.cpp \
- SurfaceTextureGL_test.cpp \
- SurfaceTextureMultiContextGL_test.cpp \
- Surface_test.cpp \
- TextureRenderer.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
- libEGL \
- libGLESv1_CM \
- libGLESv2 \
- libbinder \
- libcutils \
- libgui \
- libsync \
- libui \
- libutils \
-
-# Build the binary to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
-# to integrate with auto-test framework.
-include $(BUILD_NATIVE_TEST)
-
-# Include subdirectory makefiles
-# ============================================================
-
-# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
-# team really wants is to build the stuff defined by this makefile.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/libs/gui/tests/BufferQueue_test.cpp b/libs/gui/tests/BufferQueue_test.cpp
index 8a9eeee..65df7dc 100644
--- a/libs/gui/tests/BufferQueue_test.cpp
+++ b/libs/gui/tests/BufferQueue_test.cpp
@@ -1044,7 +1044,7 @@
// Check no free buffers in dump
String8 dumpString;
- mConsumer->dump(dumpString, nullptr);
+ mConsumer->dumpState(dumpString, nullptr);
// Parse the dump to ensure that all buffer slots that are FREE also
// have a null GraphicBuffer
diff --git a/libs/gui/tests/CpuConsumer_test.cpp b/libs/gui/tests/CpuConsumer_test.cpp
index 289cc74..9c2e838 100644
--- a/libs/gui/tests/CpuConsumer_test.cpp
+++ b/libs/gui/tests/CpuConsumer_test.cpp
@@ -160,7 +160,7 @@
};
#define ASSERT_NO_ERROR(err, msg) \
- ASSERT_EQ(NO_ERROR, err) << msg << strerror(-err)
+ ASSERT_EQ(NO_ERROR, err) << (msg) << strerror(-(err))
void checkPixel(const CpuConsumer::LockedBuffer &buf,
uint32_t x, uint32_t y, uint32_t r, uint32_t g=0, uint32_t b=0) {
diff --git a/libs/gui/tests/Sensor_test.cpp b/libs/gui/tests/Sensor_test.cpp
new file mode 100644
index 0000000..fbf282d
--- /dev/null
+++ b/libs/gui/tests/Sensor_test.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "Sensor_test"
+
+#include <gui/Sensor.h>
+#include <hardware/sensors.h>
+#include <utils/Errors.h>
+
+#include <gtest/gtest.h>
+
+namespace android {
+
+// Returns true if the two sensors have the same attributes. Does not compare
+// UUID since that should not be transmitted via flatten/unflatten.
+static bool sensorsMatch(const Sensor& a, const Sensor& b) {
+ return a.getName() == b.getName () &&
+ a.getVendor() == b.getVendor () &&
+ a.getHandle() == b.getHandle () &&
+ a.getType() == b.getType () &&
+ a.getMinValue() == b.getMinValue () &&
+ a.getMaxValue() == b.getMaxValue () &&
+ a.getResolution() == b.getResolution () &&
+ a.getPowerUsage() == b.getPowerUsage () &&
+ a.getMinDelay() == b.getMinDelay () &&
+ a.getMinDelayNs() == b.getMinDelayNs () &&
+ a.getVersion() == b.getVersion () &&
+ a.getFifoReservedEventCount() == b.getFifoReservedEventCount () &&
+ a.getFifoMaxEventCount() == b.getFifoMaxEventCount () &&
+ a.getStringType() == b.getStringType () &&
+ a.getRequiredPermission() == b.getRequiredPermission () &&
+ a.isRequiredPermissionRuntime() == b.isRequiredPermissionRuntime () &&
+ a.getRequiredAppOp() == b.getRequiredAppOp () &&
+ a.getMaxDelay() == b.getMaxDelay () &&
+ a.getFlags() == b.getFlags () &&
+ a.isWakeUpSensor() == b.isWakeUpSensor () &&
+ a.isDynamicSensor() == b.isDynamicSensor () &&
+ a.hasAdditionalInfo() == b.hasAdditionalInfo () &&
+ a.getReportingMode() == b.getReportingMode();
+}
+
+// Creates and returns a sensor_t struct with some default values filled in.
+static sensor_t getTestSensorT() {
+ sensor_t hwSensor = {};
+ hwSensor.name = "Test Sensor";
+ hwSensor.vendor = "Test Vendor";
+ hwSensor.version = 1;
+ hwSensor.handle = 2;
+ hwSensor.type = SENSOR_TYPE_ACCELEROMETER;
+ hwSensor.maxRange = 10.f;
+ hwSensor.resolution = 1.f;
+ hwSensor.power = 5.f;
+ hwSensor.minDelay = 1000;
+ hwSensor.fifoReservedEventCount = 50;
+ hwSensor.fifoMaxEventCount = 100;
+ hwSensor.stringType = SENSOR_STRING_TYPE_ACCELEROMETER;
+ hwSensor.requiredPermission = "";
+ hwSensor.maxDelay = 5000;
+ hwSensor.flags = SENSOR_FLAG_CONTINUOUS_MODE;
+ return hwSensor;
+}
+
+TEST(SensorTest, FlattenAndUnflatten) {
+ sensor_t hwSensor = getTestSensorT();
+ Sensor sensor1(&hwSensor, SENSORS_DEVICE_API_VERSION_1_4);
+ Sensor sensor2;
+
+ std::vector<uint8_t> buffer(sensor1.getFlattenedSize());
+ ASSERT_EQ(OK, sensor1.flatten(buffer.data(), buffer.size()));
+ ASSERT_EQ(OK, sensor2.unflatten(buffer.data(), buffer.size()));
+
+ EXPECT_TRUE(sensorsMatch(sensor1, sensor2));
+}
+
+} // namespace android
diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp
index a1578f6..b10d4eb 100644
--- a/libs/gui/tests/SurfaceTextureClient_test.cpp
+++ b/libs/gui/tests/SurfaceTextureClient_test.cpp
@@ -535,7 +535,7 @@
return false;
}
public:
- MyThread(const sp<GLConsumer>& mST)
+ explicit MyThread(const sp<GLConsumer>& mST)
: mST(mST), mBufferRetired(false) {
ctx = eglGetCurrentContext();
sur = eglGetCurrentSurface(EGL_DRAW);
diff --git a/libs/gui/tests/SurfaceTextureGL_test.cpp b/libs/gui/tests/SurfaceTextureGL_test.cpp
index 5311c59..308bd7d 100644
--- a/libs/gui/tests/SurfaceTextureGL_test.cpp
+++ b/libs/gui/tests/SurfaceTextureGL_test.cpp
@@ -437,7 +437,7 @@
class ProducerThread : public Thread {
public:
- ProducerThread(const sp<ANativeWindow>& anw):
+ explicit ProducerThread(const sp<ANativeWindow>& anw):
mANW(anw) {
}
@@ -620,7 +620,7 @@
TEST_F(SurfaceTextureGLTest, AbandonUnblocksDequeueBuffer) {
class ProducerThread : public Thread {
public:
- ProducerThread(const sp<ANativeWindow>& anw):
+ explicit ProducerThread(const sp<ANativeWindow>& anw):
mANW(anw),
mDequeueError(NO_ERROR) {
}
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
new file mode 100644
index 0000000..bd28af1
--- /dev/null
+++ b/libs/input/Android.bp
@@ -0,0 +1,62 @@
+// 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.
+
+// libinput is partially built for the host (used by build time keymap validation tool)
+
+cc_library {
+ name: "libinput",
+ host_supported: true,
+
+ srcs: [
+ "Input.cpp",
+ "InputDevice.cpp",
+ "Keyboard.cpp",
+ "KeyCharacterMap.cpp",
+ "KeyLayoutMap.cpp",
+ "VirtualKeyMap.cpp",
+ ],
+
+ clang: true,
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+
+ shared_libs: [
+ "liblog",
+ "libcutils",
+ ],
+
+ target: {
+ android: {
+ srcs: [
+ "IInputFlinger.cpp",
+ "InputTransport.cpp",
+ "VelocityControl.cpp",
+ "VelocityTracker.cpp",
+ ],
+
+ shared_libs: [
+ "libutils",
+ "libbinder",
+ ],
+ },
+ host: {
+ shared: {
+ enabled: false,
+ },
+ },
+ },
+}
+
+subdirs = ["tests"]
diff --git a/libs/input/Android.mk b/libs/input/Android.mk
deleted file mode 100644
index 746de66..0000000
--- a/libs/input/Android.mk
+++ /dev/null
@@ -1,82 +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.
-
-LOCAL_PATH:= $(call my-dir)
-
-# libinput is partially built for the host (used by build time keymap validation tool)
-# These files are common to host and target builds.
-
-commonSources := \
- Input.cpp \
- InputDevice.cpp \
- Keyboard.cpp \
- KeyCharacterMap.cpp \
- KeyLayoutMap.cpp \
- VirtualKeyMap.cpp
-
-deviceSources := \
- $(commonSources) \
- IInputFlinger.cpp \
- InputTransport.cpp \
- VelocityControl.cpp \
- VelocityTracker.cpp
-
-hostSources := \
- $(commonSources)
-
-# For the host
-# =====================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= $(hostSources)
-
-LOCAL_MODULE:= libinput
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-
-# For the device
-# =====================================================
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= $(deviceSources)
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := integer
-
-LOCAL_SHARED_LIBRARIES := \
- liblog \
- libcutils \
- libutils \
- libbinder
-
-LOCAL_MODULE:= libinput
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-# Include subdirectory makefiles
-# ============================================================
-
-# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
-# team really wants is to build the stuff defined by this makefile.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/libs/input/IInputFlinger.cpp b/libs/input/IInputFlinger.cpp
index e009731..003e73d 100644
--- a/libs/input/IInputFlinger.cpp
+++ b/libs/input/IInputFlinger.cpp
@@ -28,7 +28,7 @@
class BpInputFlinger : public BpInterface<IInputFlinger> {
public:
- BpInputFlinger(const sp<IBinder>& impl) :
+ explicit BpInputFlinger(const sp<IBinder>& impl) :
BpInterface<IInputFlinger>(impl) { }
virtual status_t doSomething() {
diff --git a/libs/input/tests/Android.bp b/libs/input/tests/Android.bp
new file mode 100644
index 0000000..029a420
--- /dev/null
+++ b/libs/input/tests/Android.bp
@@ -0,0 +1,28 @@
+// Build the unit tests.
+cc_test {
+ name: "libinput_tests",
+ test_per_src: true,
+ srcs: [
+ "InputChannel_test.cpp",
+ "InputEvent_test.cpp",
+ "InputPublisherAndConsumer_test.cpp",
+ ],
+ shared_libs: [
+ "libinput",
+ "libcutils",
+ "libutils",
+ "libbinder",
+ "libui",
+ ]
+}
+
+// NOTE: This is a compile time test, and does not need to be
+// run. All assertions are static_asserts and will fail during
+// buildtime if something's wrong.
+cc_library_static {
+ name: "StructLayout_test",
+ srcs: ["StructLayout_test.cpp"],
+ cflags: [
+ "-O0",
+ ],
+}
diff --git a/libs/input/tests/Android.mk b/libs/input/tests/Android.mk
deleted file mode 100644
index 5bfa3d4..0000000
--- a/libs/input/tests/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Build the unit tests.
-LOCAL_PATH:= $(call my-dir)
-
-# Build the unit tests.
-test_src_files := \
- InputChannel_test.cpp \
- InputEvent_test.cpp \
- InputPublisherAndConsumer_test.cpp
-
-shared_libraries := \
- libinput \
- libcutils \
- libutils \
- libbinder \
- libui \
-
-$(foreach file,$(test_src_files), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk) \
- $(eval LOCAL_SHARED_LIBRARIES := $(shared_libraries)) \
- $(eval LOCAL_STATIC_LIBRARIES := $(static_libraries)) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
- $(eval include $(BUILD_NATIVE_TEST)) \
-)
-
-# NOTE: This is a compile time test, and does not need to be
-# run. All assertions are static_asserts and will fail during
-# buildtime if something's wrong.
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SRC_FILES := StructLayout_test.cpp
-LOCAL_MODULE := StructLayout_test
-LOCAL_CFLAGS := -std=c++11 -O0
-LOCAL_MULTILIB := both
-include $(BUILD_STATIC_LIBRARY)
-
-
-# Build the manual test programs.
-include $(call all-makefiles-under, $(LOCAL_PATH))
diff --git a/libs/input/tests/StructLayout_test.cpp b/libs/input/tests/StructLayout_test.cpp
index 8d73f45..81b9953 100644
--- a/libs/input/tests/StructLayout_test.cpp
+++ b/libs/input/tests/StructLayout_test.cpp
@@ -20,7 +20,7 @@
namespace android {
#define CHECK_OFFSET(type, member, expected_offset) \
- static_assert((offsetof(type, member) == expected_offset), "")
+ static_assert((offsetof(type, member) == (expected_offset)), "")
struct Foo {
uint32_t dummy;
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
new file mode 100644
index 0000000..d5ff753
--- /dev/null
+++ b/libs/ui/Android.bp
@@ -0,0 +1,68 @@
+// 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.
+
+cc_library_shared {
+ name: "libui",
+
+ clang: true,
+ cppflags: [
+ "-Weverything",
+ "-Werror",
+
+ // The static constructors and destructors in this library have not been noted to
+ // introduce significant overheads
+ "-Wno-exit-time-destructors",
+ "-Wno-global-constructors",
+
+ // We only care about compiling as C++14
+ "-Wno-c++98-compat-pedantic",
+
+ // We use four-character constants for the GraphicBuffer header, and don't care
+ // that they're non-portable as long as they're consistent within one execution
+ "-Wno-four-char-constants",
+
+ // Don't warn about struct padding
+ "-Wno-padded",
+ ],
+
+ sanitize: {
+ //misc_undefined: ["integer"],
+ },
+
+ srcs: [
+ "Fence.cpp",
+ "FrameStats.cpp",
+ "Gralloc1.cpp",
+ "Gralloc1On0Adapter.cpp",
+ "GraphicBuffer.cpp",
+ "GraphicBufferAllocator.cpp",
+ "GraphicBufferMapper.cpp",
+ "HdrCapabilities.cpp",
+ "PixelFormat.cpp",
+ "Rect.cpp",
+ "Region.cpp",
+ "UiConfig.cpp",
+ ],
+
+ shared_libs: [
+ "libbinder",
+ "libcutils",
+ "libhardware",
+ "libsync",
+ "libutils",
+ "liblog",
+ ],
+}
+
+subdirs = ["tests"]
diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk
deleted file mode 100644
index e690ede..0000000
--- a/libs/ui/Android.mk
+++ /dev/null
@@ -1,75 +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.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CLANG := true
-LOCAL_CPPFLAGS := -std=c++1y -Weverything -Werror
-# LOCAL_SANITIZE := integer
-
-# The static constructors and destructors in this library have not been noted to
-# introduce significant overheads
-LOCAL_CPPFLAGS += -Wno-exit-time-destructors
-LOCAL_CPPFLAGS += -Wno-global-constructors
-
-# We only care about compiling as C++14
-LOCAL_CPPFLAGS += -Wno-c++98-compat-pedantic
-
-# We use four-character constants for the GraphicBuffer header, and don't care
-# that they're non-portable as long as they're consistent within one execution
-LOCAL_CPPFLAGS += -Wno-four-char-constants
-
-# Don't warn about struct padding
-LOCAL_CPPFLAGS += -Wno-padded
-
-LOCAL_SRC_FILES := \
- Fence.cpp \
- FrameStats.cpp \
- Gralloc1.cpp \
- Gralloc1On0Adapter.cpp \
- GraphicBuffer.cpp \
- GraphicBufferAllocator.cpp \
- GraphicBufferMapper.cpp \
- HdrCapabilities.cpp \
- PixelFormat.cpp \
- Rect.cpp \
- Region.cpp \
- UiConfig.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libbinder \
- libcutils \
- libhardware \
- libsync \
- libutils \
- liblog
-
-ifneq ($(BOARD_FRAMEBUFFER_FORCE_FORMAT),)
-LOCAL_CFLAGS += -DFRAMEBUFFER_FORCE_FORMAT=$(BOARD_FRAMEBUFFER_FORCE_FORMAT)
-endif
-
-LOCAL_MODULE := libui
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-# Include subdirectory makefiles
-# ============================================================
-
-# If we're building with ONE_SHOT_MAKEFILE (mm, mmm), then what the framework
-# team really wants is to build the stuff defined by this makefile.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call first-makefiles-under,$(LOCAL_PATH))
-endif
diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp
index ee152bf..b53c563 100644
--- a/libs/ui/Region.cpp
+++ b/libs/ui/Region.cpp
@@ -294,7 +294,7 @@
Region& Region::subtractSelf(const Rect& r) {
return operationSelf(r, op_nand);
}
-Region& Region::operationSelf(const Rect& r, int op) {
+Region& Region::operationSelf(const Rect& r, uint32_t op) {
Region lhs(*this);
boolean_operation(op, *this, lhs, r);
return *this;
@@ -314,7 +314,7 @@
Region& Region::subtractSelf(const Region& rhs) {
return operationSelf(rhs, op_nand);
}
-Region& Region::operationSelf(const Region& rhs, int op) {
+Region& Region::operationSelf(const Region& rhs, uint32_t op) {
Region lhs(*this);
boolean_operation(op, *this, lhs, rhs);
return *this;
@@ -339,7 +339,7 @@
const Region Region::subtract(const Rect& rhs) const {
return operation(rhs, op_nand);
}
-const Region Region::operation(const Rect& rhs, int op) const {
+const Region Region::operation(const Rect& rhs, uint32_t op) const {
Region result;
boolean_operation(op, result, *this, rhs);
return result;
@@ -359,7 +359,7 @@
const Region Region::subtract(const Region& rhs) const {
return operation(rhs, op_nand);
}
-const Region Region::operation(const Region& rhs, int op) const {
+const Region Region::operation(const Region& rhs, uint32_t op) const {
Region result;
boolean_operation(op, result, *this, rhs);
return result;
@@ -385,7 +385,7 @@
Region& Region::subtractSelf(const Region& rhs, int dx, int dy) {
return operationSelf(rhs, dx, dy, op_nand);
}
-Region& Region::operationSelf(const Region& rhs, int dx, int dy, int op) {
+Region& Region::operationSelf(const Region& rhs, int dx, int dy, uint32_t op) {
Region lhs(*this);
boolean_operation(op, *this, lhs, rhs, dx, dy);
return *this;
@@ -405,7 +405,7 @@
const Region Region::subtract(const Region& rhs, int dx, int dy) const {
return operation(rhs, dx, dy, op_nand);
}
-const Region Region::operation(const Region& rhs, int dx, int dy, int op) const {
+const Region Region::operation(const Region& rhs, int dx, int dy, uint32_t op) const {
Region result;
boolean_operation(op, result, *this, rhs, dx, dy);
return result;
@@ -424,7 +424,7 @@
Vector<Rect> span;
Rect* cur;
public:
- rasterizer(Region& reg)
+ explicit rasterizer(Region& reg)
: bounds(INT_MAX, 0, INT_MIN, 0), storage(reg.mStorage), head(), tail(), cur() {
storage.clear();
}
@@ -489,7 +489,8 @@
merge = false;
break;
}
- p++, q++;
+ p++;
+ q++;
}
}
}
@@ -582,7 +583,7 @@
return result;
}
-void Region::boolean_operation(int op, Region& dst,
+void Region::boolean_operation(uint32_t op, Region& dst,
const Region& lhs,
const Region& rhs, int dx, int dy)
{
@@ -692,7 +693,7 @@
#endif
}
-void Region::boolean_operation(int op, Region& dst,
+void Region::boolean_operation(uint32_t op, Region& dst,
const Region& lhs,
const Rect& rhs, int dx, int dy)
{
@@ -721,13 +722,13 @@
#endif
}
-void Region::boolean_operation(int op, Region& dst,
+void Region::boolean_operation(uint32_t op, Region& dst,
const Region& lhs, const Region& rhs)
{
boolean_operation(op, dst, lhs, rhs, 0, 0);
}
-void Region::boolean_operation(int op, Region& dst,
+void Region::boolean_operation(uint32_t op, Region& dst,
const Region& lhs, const Rect& rhs)
{
boolean_operation(op, dst, lhs, rhs, 0, 0);
diff --git a/libs/ui/UiConfig.cpp b/libs/ui/UiConfig.cpp
index 9e7ba8e..7730690 100644
--- a/libs/ui/UiConfig.cpp
+++ b/libs/ui/UiConfig.cpp
@@ -18,20 +18,10 @@
namespace android {
-#ifdef FRAMEBUFFER_FORCE_FORMAT
-// We need the two-level macro to stringify the contents of a macro argument
-#define STRINGIFY(x) #x
-#define TOSTRING(x) STRINGIFY(x)
-#endif
-
void appendUiConfigString(String8& configStr)
{
static const char* config =
- " [libui"
-#ifdef FRAMEBUFFER_FORCE_FORMAT
- " FRAMEBUFFER_FORCE_FORMAT=" TOSTRING(FRAMEBUFFER_FORCE_FORMAT)
-#endif
- "]";
+ " [libui]";
configStr.append(config);
}
diff --git a/libs/ui/tests/Android.bp b/libs/ui/tests/Android.bp
new file mode 100644
index 0000000..8cdab8c
--- /dev/null
+++ b/libs/ui/tests/Android.bp
@@ -0,0 +1,31 @@
+//
+// 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.
+//
+
+cc_test {
+ name: "Region_test",
+ shared_libs: ["libui"],
+ srcs: ["Region_test.cpp"],
+}
+
+cc_test {
+ name: "vec_test",
+ srcs: ["vec_test.cpp"],
+}
+
+cc_test {
+ name: "mat_test",
+ srcs: ["mat_test.cpp"],
+}
diff --git a/libs/ui/tests/Android.mk b/libs/ui/tests/Android.mk
deleted file mode 100644
index 6438b1f..0000000
--- a/libs/ui/tests/Android.mk
+++ /dev/null
@@ -1,36 +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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SHARED_LIBRARIES := libui
-LOCAL_SRC_FILES := Region_test.cpp
-LOCAL_MODULE := Region_test
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SRC_FILES := vec_test.cpp
-LOCAL_MODULE := vec_test
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_SRC_FILES := mat_test.cpp
-LOCAL_MODULE := mat_test
-include $(BUILD_NATIVE_TEST)
diff --git a/opengl/Android.bp b/opengl/Android.bp
new file mode 100644
index 0000000..c520bda
--- /dev/null
+++ b/opengl/Android.bp
@@ -0,0 +1,57 @@
+// Copyright (C) 2016 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.
+
+ndk_headers {
+ name: "libEGL_headers",
+ from: "include",
+ to: "",
+ srcs: ["include/EGL/**/*.h"],
+ license: "include/EGL/NOTICE",
+}
+
+ndk_headers {
+ name: "libGLESv1_CM_headers",
+ from: "include",
+ to: "",
+ srcs: ["include/GLES/**/*.h"],
+ license: "include/GLES/NOTICE",
+}
+
+ndk_headers {
+ name: "libGLESv2_headers",
+ from: "include",
+ to: "",
+ srcs: ["include/GLES2/**/*.h"],
+ license: "include/GLES2/NOTICE",
+}
+
+ndk_headers {
+ name: "libGLESv3_headers",
+ from: "include",
+ to: "",
+ srcs: ["include/GLES3/**/*.h"],
+ license: "include/GLES3/NOTICE",
+}
+
+ndk_headers {
+ name: "khr_headers",
+ from: "include",
+ to: "",
+ srcs: ["include/KHR/**/*.h"],
+ license: "include/KHR/NOTICE",
+}
+
+subdirs = [
+ "*",
+]
diff --git a/opengl/include/EGL/NOTICE b/opengl/include/EGL/NOTICE
new file mode 100644
index 0000000..55f5efa
--- /dev/null
+++ b/opengl/include/EGL/NOTICE
@@ -0,0 +1,20 @@
+Copyright (c) 2007-2009 The Khronos Group Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and/or associated documentation files (the
+"Materials"), to deal in the Materials without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Materials, and to
+permit persons to whom the Materials are furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Materials.
+
+THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
diff --git a/opengl/include/EGL/egl.h b/opengl/include/EGL/egl.h
index 99ea342..ccb54ea 100644
--- a/opengl/include/EGL/egl.h
+++ b/opengl/include/EGL/egl.h
@@ -65,13 +65,13 @@
#define EGL_TRUE 1
/* Out-of-band handle values */
-#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0)
-#define EGL_NO_CONTEXT ((EGLContext)0)
-#define EGL_NO_DISPLAY ((EGLDisplay)0)
-#define EGL_NO_SURFACE ((EGLSurface)0)
+#define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType, 0)
+#define EGL_NO_CONTEXT EGL_CAST(EGLContext, 0)
+#define EGL_NO_DISPLAY EGL_CAST(EGLDisplay, 0)
+#define EGL_NO_SURFACE EGL_CAST(EGLSurface, 0)
/* Out-of-band attribute value */
-#define EGL_DONT_CARE ((EGLint)-1)
+#define EGL_DONT_CARE EGL_CAST(EGLint, -1)
/* Errors / GetError return values */
#define EGL_SUCCESS 0x3000
@@ -198,7 +198,7 @@
#define EGL_DISPLAY_SCALING 10000
/* Unknown display resolution/aspect ratio */
-#define EGL_UNKNOWN ((EGLint)-1)
+#define EGL_UNKNOWN EGL_CAST(EGLint, -1)
/* Back buffer swap behaviors */
#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */
diff --git a/opengl/include/EGL/eglext.h b/opengl/include/EGL/eglext.h
index 2e18698..c7bdadb 100644
--- a/opengl/include/EGL/eglext.h
+++ b/opengl/include/EGL/eglext.h
@@ -79,7 +79,7 @@
#define EGL_KHR_image 1
#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */
typedef void *EGLImageKHR;
-#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
+#define EGL_NO_IMAGE_KHR EGL_CAST(EGLImageKHR, 0)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
@@ -115,6 +115,13 @@
#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */
#endif
+#ifndef EGL_KHR_gl_colorspace
+#define EGL_KHR_gl_colorspace 1
+#define EGL_GL_COLORSPACE_KHR 0x309D
+#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
+#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A
+#endif
+
#ifndef EGL_KHR_gl_renderbuffer_image
#define EGL_KHR_gl_renderbuffer_image 1
#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */
@@ -136,7 +143,7 @@
#define EGL_SYNC_REUSABLE_KHR 0x30FA
#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR <flags> bitfield */
#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
-#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
+#define EGL_NO_SYNC_KHR EGL_CAST(EGLSyncKHR, 0)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
@@ -213,7 +220,7 @@
#define EGL_SYNC_TYPE_NV 0x30ED
#define EGL_SYNC_CONDITION_NV 0x30EE
#define EGL_SYNC_FENCE_NV 0x30EF
-#define EGL_NO_SYNC_NV ((EGLSyncNV)0)
+#define EGL_NO_SYNC_NV EGL_CAST(EGLSyncNV, 0)
typedef void* EGLSyncNV;
typedef khronos_utime_nanoseconds_t EGLTimeNV;
#ifdef EGL_EGLEXT_PROTOTYPES
@@ -339,7 +346,7 @@
#define EGL_KHR_stream 1
typedef void* EGLStreamKHR;
typedef khronos_uint64_t EGLuint64KHR;
-#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0)
+#define EGL_NO_STREAM_KHR EGL_CAST(EGLStreamKHR, 0)
#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210
#define EGL_PRODUCER_FRAME_KHR 0x3212
#define EGL_CONSUMER_FRAME_KHR 0x3213
@@ -466,7 +473,7 @@
#ifndef EGL_KHR_stream_cross_process_fd
#define EGL_KHR_stream_cross_process_fd 1
typedef int EGLNativeFileDescriptorKHR;
-#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1))
+#define EGL_NO_FILE_DESCRIPTOR_KHR EGL_CAST(EGLNativeFileDescriptorKHR, -1)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream);
EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor);
@@ -545,7 +552,7 @@
#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146
-#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
+#define EGL_NO_NATIVE_FENCE_FD_ANDROID (-1)
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR);
#endif /* EGL_EGLEXT_PROTOTYPES */
@@ -607,7 +614,7 @@
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLClientBuffer eglCreateNativeClientBufferANDROID (const EGLint *attrib_list);
#else
-typedef EGLAPI EGLClientBuffer (EGLAPIENTRYP PFNEGLCREATENATIVECLIENTBUFFERANDROID) (const EGLint *attrib_list);
+typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLCREATENATIVECLIENTBUFFERANDROID) (const EGLint *attrib_list);
#endif
#endif
diff --git a/opengl/include/EGL/eglplatform.h b/opengl/include/EGL/eglplatform.h
index 354ac22..54011c8 100644
--- a/opengl/include/EGL/eglplatform.h
+++ b/opengl/include/EGL/eglplatform.h
@@ -121,4 +121,10 @@
*/
typedef khronos_int32_t EGLint;
+#if defined(__cplusplus)
+#define EGL_CAST(type, value) (static_cast<type>(value))
+#else
+#define EGL_CAST(type, value) ((type) (value))
+#endif
+
#endif /* __eglplatform_h */
diff --git a/opengl/include/GLES/NOTICE b/opengl/include/GLES/NOTICE
new file mode 100644
index 0000000..4dc6614
--- /dev/null
+++ b/opengl/include/GLES/NOTICE
@@ -0,0 +1,2 @@
+This document is licensed under the SGI Free Software B License Version 2.0.
+For details, see http://oss.sgi.com/projects/FreeB/ .
diff --git a/opengl/include/GLES2/NOTICE b/opengl/include/GLES2/NOTICE
new file mode 100644
index 0000000..7a94373
--- /dev/null
+++ b/opengl/include/GLES2/NOTICE
@@ -0,0 +1,20 @@
+Copyright (c) 2013-2015 The Khronos Group Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and/or associated documentation files (the
+"Materials"), to deal in the Materials without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Materials, and to
+permit persons to whom the Materials are furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Materials.
+
+THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
diff --git a/opengl/include/GLES3/NOTICE b/opengl/include/GLES3/NOTICE
new file mode 100644
index 0000000..7a94373
--- /dev/null
+++ b/opengl/include/GLES3/NOTICE
@@ -0,0 +1,20 @@
+Copyright (c) 2013-2015 The Khronos Group Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and/or associated documentation files (the
+"Materials"), to deal in the Materials without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Materials, and to
+permit persons to whom the Materials are furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Materials.
+
+THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
diff --git a/opengl/include/KHR/NOTICE b/opengl/include/KHR/NOTICE
new file mode 100644
index 0000000..36796e8
--- /dev/null
+++ b/opengl/include/KHR/NOTICE
@@ -0,0 +1,20 @@
+Copyright (c) 2008-2009 The Khronos Group Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and/or associated documentation files (the
+"Materials"), to deal in the Materials without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Materials, and to
+permit persons to whom the Materials are furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Materials.
+
+THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
diff --git a/opengl/libagl/arch-mips/fixed_asm.S b/opengl/libagl/arch-mips/fixed_asm.S
index e1a53bc..a30ffc5 100644
--- a/opengl/libagl/arch-mips/fixed_asm.S
+++ b/opengl/libagl/arch-mips/fixed_asm.S
@@ -17,7 +17,7 @@
.text
- .align
+ .align 4
/*
* this version rounds-to-nearest and saturates numbers
diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp
new file mode 100644
index 0000000..6a8aac8
--- /dev/null
+++ b/opengl/libs/Android.bp
@@ -0,0 +1,160 @@
+// Build the ETC1 library
+cc_library {
+ name: "libETC1",
+ srcs: ["ETC1/etc1.cpp"],
+ host_supported: true,
+
+ target: {
+ android: {
+ static: {
+ enabled: false,
+ },
+ },
+ host: {
+ shared: {
+ enabled: false,
+ },
+ },
+ windows: {
+ enabled: true,
+ },
+ },
+}
+
+// The headers modules are in frameworks/native/opengl/Android.bp.
+ndk_library {
+ name: "libEGL.ndk",
+ symbol_file: "libEGL.map.txt",
+ first_version: "9",
+}
+
+ndk_library {
+ name: "libGLESv1_CM.ndk",
+ symbol_file: "libGLESv1_CM.map.txt",
+ first_version: "9",
+}
+
+ndk_library {
+ name: "libGLESv2.ndk",
+ symbol_file: "libGLESv2.map.txt",
+ first_version: "9",
+}
+
+ndk_library {
+ name: "libGLESv3.ndk",
+ symbol_file: "libGLESv3.map.txt",
+ first_version: "18",
+}
+
+cc_defaults {
+ name: "gl_libs_defaults",
+ cflags: [
+ "-DGL_GLEXT_PROTOTYPES",
+ "-DEGL_EGLEXT_PROTOTYPES",
+ "-fvisibility=hidden",
+ ],
+ shared_libs: [
+ "libcutils",
+ "liblog",
+ "libdl",
+ ],
+
+ // we need to access the private Bionic header <bionic_tls.h>
+ include_dirs: ["bionic/libc/private"],
+}
+
+//##############################################################################
+// Build META EGL library
+//
+cc_defaults {
+ name: "egl_libs_defaults",
+ defaults: ["gl_libs_defaults"],
+ cflags: [
+ "-DLOG_TAG=\"libEGL\"",
+ ],
+ shared_libs: [
+ "libbinder",
+ "libutils",
+ "libui",
+ ],
+}
+
+cc_library_static {
+ name: "libEGL_getProcAddress",
+ defaults: ["egl_libs_defaults"],
+ srcs: ["EGL/getProcAddress.cpp"],
+ arch: {
+ arm: {
+ instruction_set: "arm",
+ },
+ },
+}
+
+cc_library_shared {
+ name: "libEGL",
+ defaults: ["egl_libs_defaults"],
+ srcs: [
+ "EGL/egl_tls.cpp",
+ "EGL/egl_cache.cpp",
+ "EGL/egl_display.cpp",
+ "EGL/egl_object.cpp",
+ "EGL/egl.cpp",
+ "EGL/eglApi.cpp",
+ "EGL/Loader.cpp",
+ ],
+ static_libs: ["libEGL_getProcAddress"],
+ ldflags: ["-Wl,--exclude-libs=ALL"],
+
+ required: ["egl.cfg"],
+}
+
+cc_defaults {
+ name: "gles_libs_defaults",
+ defaults: ["gl_libs_defaults"],
+ arch: {
+ arm: {
+ instruction_set: "arm",
+
+ // TODO: This is to work around b/20093774. Remove after root cause is fixed
+ ldflags: ["-Wl,--hash-style,both"],
+ },
+ },
+ shared_libs: ["libEGL"],
+}
+
+//##############################################################################
+// Build the wrapper OpenGL ES 1.x library
+//
+cc_library_shared {
+ name: "libGLESv1_CM",
+ defaults: ["gles_libs_defaults"],
+ srcs: ["GLES_CM/gl.cpp"],
+
+ cflags: ["-DLOG_TAG=\"libGLESv1\""],
+}
+
+//##############################################################################
+// Build the wrapper OpenGL ES 2.x library
+//
+cc_library_shared {
+ name: "libGLESv2",
+ defaults: ["gles_libs_defaults"],
+ srcs: ["GLES2/gl2.cpp"],
+
+ shared_libs: ["libutils"],
+
+ cflags: ["-DLOG_TAG=\"libGLESv2\""],
+}
+
+//##############################################################################
+// Build the wrapper OpenGL ES 3.x library (this is just different name for v2)
+//
+cc_library_shared {
+ name: "libGLESv3",
+ defaults: ["gles_libs_defaults"],
+ srcs: ["GLES2/gl2.cpp"],
+
+ shared_libs: ["libutils"],
+
+ cflags: ["-DLOG_TAG=\"libGLESv3\""],
+}
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index 24e4c19..21e76f5 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -1,13 +1,7 @@
LOCAL_PATH:= $(call my-dir)
-###############################################################################
-# Build META EGL library
-#
-
-egl.cfg_config_module :=
# OpenGL drivers config file
ifneq ($(BOARD_EGL_CFG),)
-
include $(CLEAR_VARS)
LOCAL_MODULE := egl.cfg
LOCAL_MODULE_TAGS := optional
@@ -15,168 +9,4 @@
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/egl
LOCAL_SRC_FILES := ../../../../$(BOARD_EGL_CFG)
include $(BUILD_PREBUILT)
-egl.cfg_config_module := $(LOCAL_MODULE)
endif
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- EGL/egl_tls.cpp \
- EGL/egl_cache.cpp \
- EGL/egl_display.cpp \
- EGL/egl_object.cpp \
- EGL/egl.cpp \
- EGL/eglApi.cpp \
- EGL/getProcAddress.cpp.arm \
- EGL/Loader.cpp \
-#
-
-LOCAL_SHARED_LIBRARIES += libbinder libcutils libutils liblog libui
-LOCAL_MODULE:= libEGL
-LOCAL_LDFLAGS += -Wl,--exclude-libs=ALL
-LOCAL_SHARED_LIBRARIES += libdl
-# we need to access the private Bionic header <bionic_tls.h>
-LOCAL_C_INCLUDES += bionic/libc/private
-
-LOCAL_CFLAGS += -DLOG_TAG=\"libEGL\"
-LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-LOCAL_CFLAGS += -fvisibility=hidden
-
-ifeq ($(BOARD_ALLOW_EGL_HIBERNATION),true)
- LOCAL_CFLAGS += -DBOARD_ALLOW_EGL_HIBERNATION
-endif
-ifneq ($(MAX_EGL_CACHE_ENTRY_SIZE),)
- LOCAL_CFLAGS += -DMAX_EGL_CACHE_ENTRY_SIZE=$(MAX_EGL_CACHE_ENTRY_SIZE)
-endif
-
-ifneq ($(MAX_EGL_CACHE_KEY_SIZE),)
- LOCAL_CFLAGS += -DMAX_EGL_CACHE_KEY_SIZE=$(MAX_EGL_CACHE_KEY_SIZE)
-endif
-
-ifneq ($(MAX_EGL_CACHE_SIZE),)
- LOCAL_CFLAGS += -DMAX_EGL_CACHE_SIZE=$(MAX_EGL_CACHE_SIZE)
-endif
-
-ifneq ($(filter address,$(SANITIZE_TARGET)),)
- LOCAL_CFLAGS_32 += -DEGL_WRAPPER_DIR=\"/$(TARGET_COPY_OUT_DATA)/lib\"
- LOCAL_CFLAGS_64 += -DEGL_WRAPPER_DIR=\"/$(TARGET_COPY_OUT_DATA)/lib64\"
-endif
-
-LOCAL_REQUIRED_MODULES := $(egl.cfg_config_module)
-egl.cfg_config_module :=
-
-include $(BUILD_SHARED_LIBRARY)
-
-###############################################################################
-# Build the wrapper OpenGL ES 1.x library
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- GLES_CM/gl.cpp.arm \
-#
-
-LOCAL_CLANG := false
-LOCAL_SHARED_LIBRARIES += libcutils liblog libEGL
-LOCAL_MODULE:= libGLESv1_CM
-
-LOCAL_SHARED_LIBRARIES += libdl
-# we need to access the private Bionic header <bionic_tls.h>
-LOCAL_C_INCLUDES += bionic/libc/private
-
-LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv1\"
-LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-LOCAL_CFLAGS += -fvisibility=hidden
-
-# TODO: This is to work around b/20093774. Remove after root cause is fixed
-LOCAL_LDFLAGS_arm += -Wl,--hash-style,both
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-###############################################################################
-# Build the wrapper OpenGL ES 2.x library
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- GLES2/gl2.cpp \
-#
-
-LOCAL_CLANG := false
-LOCAL_ARM_MODE := arm
-LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libEGL
-LOCAL_MODULE:= libGLESv2
-
-LOCAL_SHARED_LIBRARIES += libdl
-# we need to access the private Bionic header <bionic_tls.h>
-LOCAL_C_INCLUDES += bionic/libc/private
-
-LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv2\"
-LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-LOCAL_CFLAGS += -fvisibility=hidden
-
-# TODO: This is to work around b/20093774. Remove after root cause is fixed
-LOCAL_LDFLAGS_arm += -Wl,--hash-style,both
-
-include $(BUILD_SHARED_LIBRARY)
-
-###############################################################################
-# Build the wrapper OpenGL ES 3.x library (this is just different name for v2)
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- GLES2/gl2.cpp \
-#
-
-LOCAL_CLANG := false
-LOCAL_ARM_MODE := arm
-LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libEGL
-LOCAL_MODULE:= libGLESv3
-LOCAL_SHARED_LIBRARIES += libdl
-# we need to access the private Bionic header <bionic_tls.h>
-LOCAL_C_INCLUDES += bionic/libc/private
-
-LOCAL_CFLAGS += -DLOG_TAG=\"libGLESv3\"
-LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-LOCAL_CFLAGS += -fvisibility=hidden
-
-# TODO: This is to work around b/20093774. Remove after root cause is fixed
-LOCAL_LDFLAGS_arm += -Wl,--hash-style,both
-
-include $(BUILD_SHARED_LIBRARY)
-
-###############################################################################
-# Build the ETC1 host static library
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- ETC1/etc1.cpp \
-#
-
-LOCAL_MODULE:= libETC1
-LOCAL_MODULE_HOST_OS := darwin linux windows
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-###############################################################################
-# Build the ETC1 device library
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- ETC1/etc1.cpp \
-#
-
-LOCAL_MODULE:= libETC1
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/opengl/libs/EGL/Loader.h b/opengl/libs/EGL/Loader.h
index 8cefe32..94f680e 100644
--- a/opengl/libs/EGL/Loader.h
+++ b/opengl/libs/EGL/Loader.h
@@ -46,7 +46,7 @@
GLESv2 = 0x04
};
struct driver_t {
- driver_t(void* gles);
+ explicit driver_t(void* gles);
~driver_t();
status_t set(void* hnd, int32_t api);
void* dso[3];
diff --git a/opengl/libs/EGL/eglApi.cpp b/opengl/libs/EGL/eglApi.cpp
index 4a07648..d4f47b8 100644
--- a/opengl/libs/EGL/eglApi.cpp
+++ b/opengl/libs/EGL/eglApi.cpp
@@ -56,10 +56,6 @@
using namespace android;
-// This extension has not been ratified yet, so can't be shipped.
-// Implementation is incomplete and untested.
-#define ENABLE_EGL_KHR_GL_COLORSPACE 0
-
#define ENABLE_EGL_ANDROID_GET_FRAME_TIMESTAMPS 0
// ----------------------------------------------------------------------------
@@ -101,9 +97,7 @@
"EGL_KHR_image_base " // mandatory
"EGL_KHR_image_pixmap "
"EGL_KHR_lock_surface "
-#if (ENABLE_EGL_KHR_GL_COLORSPACE != 0)
"EGL_KHR_gl_colorspace "
-#endif
"EGL_KHR_gl_texture_2D_image "
"EGL_KHR_gl_texture_3D_image "
"EGL_KHR_gl_texture_cubemap_image "
@@ -442,12 +436,6 @@
// surfaces
// ----------------------------------------------------------------------------
-// The EGL_KHR_gl_colorspace spec hasn't been ratified yet, so these haven't
-// been added to the Khronos egl.h.
-#define EGL_GL_COLORSPACE_KHR EGL_VG_COLORSPACE
-#define EGL_GL_COLORSPACE_SRGB_KHR EGL_VG_COLORSPACE_sRGB
-#define EGL_GL_COLORSPACE_LINEAR_KHR EGL_VG_COLORSPACE_LINEAR
-
// Turn linear formats into corresponding sRGB formats when colorspace is
// EGL_GL_COLORSPACE_SRGB_KHR, or turn sRGB formats into corresponding linear
// formats when colorspace is EGL_GL_COLORSPACE_LINEAR_KHR. In any cases where
@@ -514,17 +502,7 @@
if (attrib_list && dp->haveExtension("EGL_KHR_gl_colorspace")) {
for (const EGLint* attr = attrib_list; *attr != EGL_NONE; attr += 2) {
if (*attr == EGL_GL_COLORSPACE_KHR) {
- if (ENABLE_EGL_KHR_GL_COLORSPACE) {
- dataSpace = modifyBufferDataspace(dataSpace, *(attr+1));
- } else {
- // Normally we'd pass through unhandled attributes to
- // the driver. But in case the driver implements this
- // extension but we're disabling it, we want to prevent
- // it getting through -- support will be broken without
- // our help.
- ALOGE("sRGB window surfaces not supported");
- return setError(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
- }
+ dataSpace = modifyBufferDataspace(dataSpace, *(attr+1));
}
}
}
@@ -1352,13 +1330,14 @@
{
clearError();
- // If there is context bound to the thread, release it
- egl_display_t::loseCurrent(get_context(getContext()));
-
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglReleaseThread) {
cnx->egl.eglReleaseThread();
}
+
+ // If there is context bound to the thread, release it
+ egl_display_t::loseCurrent(get_context(getContext()));
+
egl_tls_t::clearTLS();
return EGL_TRUE;
}
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index 8c135c8..1fe322d 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -27,22 +27,10 @@
#include <sys/types.h>
#include <unistd.h>
-#ifndef MAX_EGL_CACHE_ENTRY_SIZE
-#define MAX_EGL_CACHE_ENTRY_SIZE (16 * 1024);
-#endif
-
-#ifndef MAX_EGL_CACHE_KEY_SIZE
-#define MAX_EGL_CACHE_KEY_SIZE (1024);
-#endif
-
-#ifndef MAX_EGL_CACHE_SIZE
-#define MAX_EGL_CACHE_SIZE (64 * 1024);
-#endif
-
// Cache size limits.
-static const size_t maxKeySize = MAX_EGL_CACHE_KEY_SIZE;
-static const size_t maxValueSize = MAX_EGL_CACHE_ENTRY_SIZE;
-static const size_t maxTotalSize = MAX_EGL_CACHE_SIZE;
+static const size_t maxKeySize = 12 * 1024;
+static const size_t maxValueSize = 64 * 1024;
+static const size_t maxTotalSize = 2 * 1024 * 1024;
// Cache file header
static const char* cacheFileMagic = "EGL$";
diff --git a/opengl/libs/EGL/egl_display.cpp b/opengl/libs/EGL/egl_display.cpp
index 1e39aae..a32f037 100644
--- a/opengl/libs/EGL/egl_display.cpp
+++ b/opengl/libs/EGL/egl_display.cpp
@@ -215,8 +215,6 @@
*major = VERSION_MAJOR;
if (minor != NULL)
*minor = VERSION_MINOR;
-
- mHibernation.setDisplayValid(true);
}
{
@@ -265,8 +263,6 @@
res = EGL_TRUE;
}
- mHibernation.setDisplayValid(false);
-
// Reset the extension string since it will be regenerated if we get
// reinitialized.
mExtensionString.setTo("");
@@ -345,16 +341,12 @@
disp.dpy, impl_draw, impl_read, impl_ctx);
if (result == EGL_TRUE) {
c->onMakeCurrent(draw, read);
- if (!cur_c) {
- mHibernation.incWakeCount(HibernationMachine::STRONG);
- }
}
} else {
result = cur_c->cnx->egl.eglMakeCurrent(
disp.dpy, impl_draw, impl_read, impl_ctx);
if (result == EGL_TRUE) {
cur_c->onLooseCurrent();
- mHibernation.decWakeCount(HibernationMachine::STRONG);
}
}
}
@@ -379,63 +371,5 @@
}
// ----------------------------------------------------------------------------
-
-bool egl_display_t::HibernationMachine::incWakeCount(WakeRefStrength strength) {
- Mutex::Autolock _l(mLock);
- ALOGE_IF(mWakeCount < 0 || mWakeCount == INT32_MAX,
- "Invalid WakeCount (%d) on enter\n", mWakeCount);
-
- mWakeCount++;
- if (strength == STRONG)
- mAttemptHibernation = false;
-
- if (CC_UNLIKELY(mHibernating)) {
- ALOGV("Awakening\n");
- egl_connection_t* const cnx = &gEGLImpl;
-
- // These conditions should be guaranteed before entering hibernation;
- // we don't want to get into a state where we can't wake up.
- ALOGD_IF(!mDpyValid || !cnx->egl.eglAwakenProcessIMG,
- "Invalid hibernation state, unable to awaken\n");
-
- if (!cnx->egl.eglAwakenProcessIMG()) {
- ALOGE("Failed to awaken EGL implementation\n");
- return false;
- }
- mHibernating = false;
- }
- return true;
-}
-
-void egl_display_t::HibernationMachine::decWakeCount(WakeRefStrength strength) {
- Mutex::Autolock _l(mLock);
- ALOGE_IF(mWakeCount <= 0, "Invalid WakeCount (%d) on leave\n", mWakeCount);
-
- mWakeCount--;
- if (strength == STRONG)
- mAttemptHibernation = true;
-
- if (mWakeCount == 0 && CC_UNLIKELY(mAttemptHibernation)) {
- egl_connection_t* const cnx = &gEGLImpl;
- mAttemptHibernation = false;
- if (mAllowHibernation && mDpyValid &&
- cnx->egl.eglHibernateProcessIMG &&
- cnx->egl.eglAwakenProcessIMG) {
- ALOGV("Hibernating\n");
- if (!cnx->egl.eglHibernateProcessIMG()) {
- ALOGE("Failed to hibernate EGL implementation\n");
- return;
- }
- mHibernating = true;
- }
- }
-}
-
-void egl_display_t::HibernationMachine::setDisplayValid(bool valid) {
- Mutex::Autolock _l(mLock);
- mDpyValid = valid;
-}
-
-// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------
diff --git a/opengl/libs/EGL/egl_display.h b/opengl/libs/EGL/egl_display.h
index 2d86295..e17558c 100644
--- a/opengl/libs/EGL/egl_display.h
+++ b/opengl/libs/EGL/egl_display.h
@@ -68,20 +68,6 @@
// add reference to this object. returns true if this is a valid object.
bool getObject(egl_object_t* object) const;
- // These notifications allow the display to keep track of how many window
- // surfaces exist, which it uses to decide whether to hibernate the
- // underlying EGL implementation. They can be called by any thread without
- // holding a lock, but must be called via egl_display_ptr to ensure
- // proper hibernate/wakeup sequencing. If a surface destruction triggers
- // hibernation, hibernation will be delayed at least until the calling
- // thread's egl_display_ptr is destroyed.
- void onWindowSurfaceCreated() {
- mHibernation.incWakeCount(HibernationMachine::STRONG);
- }
- void onWindowSurfaceDestroyed() {
- mHibernation.decWakeCount(HibernationMachine::STRONG);
- }
-
static egl_display_t* get(EGLDisplay dpy);
static EGLDisplay getFromNativeDisplay(EGLNativeDisplayType disp);
@@ -127,8 +113,6 @@
private:
friend class egl_display_ptr;
- bool enter() { return mHibernation.incWakeCount(HibernationMachine::WEAK); }
- void leave() { return mHibernation.decWakeCount(HibernationMachine::WEAK); }
uint32_t refs;
bool eglIsInitialized;
@@ -139,47 +123,6 @@
String8 mVersionString;
String8 mClientApiString;
String8 mExtensionString;
-
- // HibernationMachine uses its own internal mutex to protect its own data.
- // The owning egl_display_t's lock may be but is not required to be held
- // when calling HibernationMachine methods. As a result, nothing in this
- // class may call back up to egl_display_t directly or indirectly.
- class HibernationMachine {
- public:
- // STRONG refs cancel (inc) or initiate (dec) a hibernation attempt
- // the next time the wakecount reaches zero. WEAK refs don't affect
- // whether a hibernation attempt will be made. Use STRONG refs only
- // for infrequent/heavy changes that are likely to indicate the
- // EGLDisplay is entering or leaving a long-term idle state.
- enum WakeRefStrength {
- WEAK = 0,
- STRONG = 1,
- };
-
- HibernationMachine(): mWakeCount(0), mHibernating(false),
- mAttemptHibernation(false), mDpyValid(false),
-#if BOARD_ALLOW_EGL_HIBERNATION
- mAllowHibernation(true)
-#else
- mAllowHibernation(false)
-#endif
- {}
- ~HibernationMachine() {}
-
- bool incWakeCount(WakeRefStrength strenth);
- void decWakeCount(WakeRefStrength strenth);
-
- void setDisplayValid(bool valid);
-
- private:
- Mutex mLock;
- int32_t mWakeCount;
- bool mHibernating;
- bool mAttemptHibernation;
- bool mDpyValid;
- const bool mAllowHibernation;
- };
- HibernationMachine mHibernation;
};
// ----------------------------------------------------------------------------
@@ -190,13 +133,7 @@
// as the egl_display_ptr exists.
class egl_display_ptr {
public:
- explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) {
- if (mDpy) {
- if (CC_UNLIKELY(!mDpy->enter())) {
- mDpy = NULL;
- }
- }
- }
+ explicit egl_display_ptr(egl_display_t* dpy): mDpy(dpy) {}
// We only really need a C++11 move constructor, not a copy constructor.
// A move constructor would save an enter()/leave() pair on every EGL API
@@ -208,17 +145,9 @@
// other.mDpy = NULL;
// }
//
- egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) {
- if (mDpy) {
- mDpy->enter();
- }
- }
+ egl_display_ptr(const egl_display_ptr& other): mDpy(other.mDpy) {}
- ~egl_display_ptr() {
- if (mDpy) {
- mDpy->leave();
- }
- }
+ ~egl_display_ptr() {}
const egl_display_t* operator->() const { return mDpy; }
egl_display_t* operator->() { return mDpy; }
diff --git a/opengl/libs/EGL/egl_object.cpp b/opengl/libs/EGL/egl_object.cpp
index cfecf77..6a76737 100644
--- a/opengl/libs/EGL/egl_object.cpp
+++ b/opengl/libs/EGL/egl_object.cpp
@@ -69,17 +69,12 @@
egl_connection_t const* cnx) :
egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx),
enableTimestamps(false), connected(true)
-{
- if (win) {
- getDisplay()->onWindowSurfaceCreated();
- }
-}
+{}
egl_surface_t::~egl_surface_t() {
ANativeWindow* const window = win.get();
if (window != NULL) {
disconnect();
- getDisplay()->onWindowSurfaceDestroyed();
}
}
diff --git a/opengl/libs/EGL/egl_object.h b/opengl/libs/EGL/egl_object.h
index 97eda4c..3150ba6 100644
--- a/opengl/libs/EGL/egl_object.h
+++ b/opengl/libs/EGL/egl_object.h
@@ -48,7 +48,7 @@
virtual void terminate();
public:
- egl_object_t(egl_display_t* display);
+ explicit egl_object_t(egl_display_t* display);
void destroy();
inline void incRef() { count.fetch_add(1, std::memory_order_relaxed); }
@@ -63,7 +63,7 @@
class LocalRef {
egl_object_t* ref;
LocalRef();
- LocalRef(const LocalRef* rhs);
+ explicit LocalRef(const LocalRef* rhs);
public:
~LocalRef();
explicit LocalRef(egl_object_t* rhs);
diff --git a/opengl/libs/GLES2/gl2.cpp b/opengl/libs/GLES2/gl2.cpp
index 6034a8e..6dd87c2 100644
--- a/opengl/libs/GLES2/gl2.cpp
+++ b/opengl/libs/GLES2/gl2.cpp
@@ -34,39 +34,65 @@
#undef API_ENTRY
#undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
#undef CALL_GL_API_RETURN
#if USE_SLOW_BINDING
#define API_ENTRY(_api) _api
- #define CALL_GL_API(_api, ...) \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
if (_c) return _c->_api(__VA_ARGS__);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE return 0;
+
+ // This stays blank, since void functions will implicitly return, and
+ // all of the other functions will return 0 based on the previous macro.
+ #define CALL_GL_API_INTERNAL_DO_RETURN
+
#elif defined(__arm__)
#define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- asm volatile( \
- GET_TLS(r12) \
- "ldr r12, [r12, %[tls]] \n" \
- "cmp r12, #0 \n" \
- "ldrne pc, [r12, %[api]] \n" \
- : \
- : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
- [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "r12" \
- );
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ asm volatile( \
+ GET_TLS(r12) \
+ "ldr r12, [r12, %[tls]] \n" \
+ "cmp r12, #0 \n" \
+ "ldrne pc, [r12, %[api]] \n" \
+ : \
+ : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
+ [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "r0", "r1", "r2", "r3", "r12" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ asm volatile( \
+ "mov r0, #0 \n" \
+ : \
+ : \
+ : "r0" \
+ );
+
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ asm volatile( \
+ "bx lr \n" \
+ : \
+ : \
+ : "r0" \
+ );
#elif defined(__aarch64__)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
asm volatile( \
"mrs x16, tpidr_el0\n" \
"ldr x16, [x16, %[tls]]\n" \
@@ -77,121 +103,173 @@
: \
: [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "x16" \
+ : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x16" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ asm volatile( \
+ "mov w0, wzr \n" \
+ : \
+ : \
+ : "w0" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ asm volatile( \
+ "ret \n" \
+ : \
+ : \
+ : \
);
#elif defined(__i386__)
- #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register void** fn; \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
__asm__ volatile( \
- "mov %%gs:0, %[fn]\n" \
- "mov %P[tls](%[fn]), %[fn]\n" \
- "test %[fn], %[fn]\n" \
+ "mov %%gs:0, %%eax\n" \
+ "mov %P[tls](%%eax), %%eax\n" \
+ "test %%eax, %%eax\n" \
"je 1f\n" \
- "jmp *%P[api](%[fn])\n" \
+ "jmp *%P[api](%%eax)\n" \
"1:\n" \
- : [fn] "=r" (fn) \
+ : \
: [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "cc" \
+ : "cc", "%eax" \
);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ __asm__ volatile( \
+ "xor %%eax, %%eax\n" \
+ : \
+ : \
+ : "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ __asm__ volatile( \
+ "ret\n" \
+ : \
+ : \
+ : \
+ );
+
#elif defined(__x86_64__)
- #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register void** fn; \
- __asm__ volatile( \
- "mov %%fs:0, %[fn]\n" \
- "mov %P[tls](%[fn]), %[fn]\n" \
- "test %[fn], %[fn]\n" \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ __asm__ volatile( \
+ "mov %%fs:0, %%rax\n" \
+ "mov %P[tls](%%rax), %%rax\n" \
+ "test %%rax, %%rax\n" \
"je 1f\n" \
- "jmp *%P[api](%[fn])\n" \
+ "jmp *%P[api](%%rax)\n" \
"1:\n" \
- : [fn] "=r" (fn) \
+ : \
: [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "cc" \
- );
+ : "cc", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", \
+ "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", \
+ "%xmm6", "%xmm7" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ __asm__ volatile( \
+ "xor %%eax, %%eax\n" \
+ : \
+ : \
+ : "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ __asm__ volatile( \
+ "retq\n" \
+ : \
+ : \
+ : \
+ );
#elif defined(__mips64)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register unsigned long _t0 asm("$12"); \
- register unsigned long _fn asm("$25"); \
- register unsigned long _tls asm("$3"); \
- register unsigned long _v0 asm("$2"); \
- asm volatile( \
- ".set push\n\t" \
- ".set noreorder\n\t" \
- "rdhwr %[tls], $29\n\t" \
- "ld %[t0], %[OPENGL_API](%[tls])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " move %[fn], $ra\n\t" \
- "ld %[t0], %[API](%[t0])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " nop\n\t" \
- "move %[fn], %[t0]\n\t" \
- "1:\n\t" \
- "jalr $0, %[fn]\n\t" \
- " move %[v0], $0\n\t" \
- ".set pop\n\t" \
- : [fn] "=c"(_fn), \
- [tls] "=&r"(_tls), \
- [t0] "=&r"(_t0), \
- [v0] "=&r"(_v0) \
- : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
- [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
+ // t0: $12
+ // fn: $25
+ // tls: $3
+ // v0: $2
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ asm volatile( \
+ ".set push\n\t" \
+ ".set noreorder\n\t" \
+ "rdhwr $3, $29\n\t" \
+ "ld $12, %[OPENGL_API]($3)\n\t" \
+ "beqz $12, 1f\n\t" \
+ " move $25, $ra\n\t" \
+ "ld $12, %[API]($12)\n\t" \
+ "beqz $12, 1f\n\t" \
+ " nop\n\t" \
+ "move $25, $12\n\t" \
+ "1:\n\t" \
+ "jalr $0, $25\n\t" \
+ " move $2, $0\n\t" \
+ ".set pop\n\t" \
+ : \
+ : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
+ [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", \
+ "$10", "$11", "$12", "$25" \
);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+ #define CALL_GL_API_INTERNAL_DO_RETURN
+
#elif defined(__mips__)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register unsigned int _t0 asm("$8"); \
- register unsigned int _fn asm("$25"); \
- register unsigned int _tls asm("$3"); \
- register unsigned int _v0 asm("$2"); \
+ // t0: $8
+ // fn: $25
+ // tls: $3
+ // v0: $2
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
asm volatile( \
".set push\n\t" \
".set noreorder\n\t" \
".set mips32r2\n\t" \
- "rdhwr %[tls], $29\n\t" \
- "lw %[t0], %[OPENGL_API](%[tls])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " move %[fn],$ra\n\t" \
- "lw %[t0], %[API](%[t0])\n\t" \
- "beqz %[t0], 1f\n\t" \
+ "rdhwr $3, $29\n\t" \
+ "lw $3, %[OPENGL_API]($3)\n\t" \
+ "beqz $3, 1f\n\t" \
+ " move $25,$ra\n\t" \
+ "lw $3, %[API]($3)\n\t" \
+ "beqz $3, 1f\n\t" \
" nop\n\t" \
- "move %[fn], %[t0]\n\t" \
+ "move $25, $3\n\t" \
"1:\n\t" \
- "jalr $0, %[fn]\n\t" \
- " move %[v0], $0\n\t" \
+ "jalr $0, $25\n\t" \
+ " move $2, $0\n\t" \
".set pop\n\t" \
- : [fn] "=c"(_fn), \
- [tls] "=&r"(_tls), \
- [t0] "=&r"(_t0), \
- [v0] "=&r"(_v0) \
+ : \
: [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \
[API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
- );
+ : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$25" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+ #define CALL_GL_API_INTERNAL_DO_RETURN
#endif
+#define CALL_GL_API(_api, ...) \
+ CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+ CALL_GL_API_INTERNAL_DO_RETURN
+
#define CALL_GL_API_RETURN(_api, ...) \
- CALL_GL_API(_api, __VA_ARGS__) \
- return 0;
-
-
+ CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+ CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ CALL_GL_API_INTERNAL_DO_RETURN
extern "C" {
#pragma GCC diagnostic ignored "-Wunused-parameter"
@@ -202,6 +280,9 @@
#undef API_ENTRY
#undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
#undef CALL_GL_API_RETURN
/*
diff --git a/opengl/libs/GLES_CM/gl.cpp b/opengl/libs/GLES_CM/gl.cpp
index b1b31f8..8bde4e5 100644
--- a/opengl/libs/GLES_CM/gl.cpp
+++ b/opengl/libs/GLES_CM/gl.cpp
@@ -90,39 +90,65 @@
#undef API_ENTRY
#undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
#undef CALL_GL_API_RETURN
#if USE_SLOW_BINDING
#define API_ENTRY(_api) _api
- #define CALL_GL_API(_api, ...) \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
gl_hooks_t::gl_t const * const _c = &getGlThreadSpecific()->gl; \
if (_c) return _c->_api(__VA_ARGS__);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE return 0;
+
+ // This stays blank, since void functions will implicitly return, and
+ // all of the other functions will return 0 based on the previous macro.
+ #define CALL_GL_API_INTERNAL_DO_RETURN
+
#elif defined(__arm__)
#define GET_TLS(reg) "mrc p15, 0, " #reg ", c13, c0, 3 \n"
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- asm volatile( \
- GET_TLS(r12) \
- "ldr r12, [r12, %[tls]] \n" \
- "cmp r12, #0 \n" \
- "ldrne pc, [r12, %[api]] \n" \
- : \
- : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
- [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "r12" \
- );
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ asm volatile( \
+ GET_TLS(r12) \
+ "ldr r12, [r12, %[tls]] \n" \
+ "cmp r12, #0 \n" \
+ "ldrne pc, [r12, %[api]] \n" \
+ : \
+ : [tls] "J"(TLS_SLOT_OPENGL_API*4), \
+ [api] "J"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "r0", "r1", "r2", "r3", "r12" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ asm volatile( \
+ "mov r0, #0 \n" \
+ : \
+ : \
+ : "r0" \
+ );
+
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ asm volatile( \
+ "bx lr \n" \
+ : \
+ : \
+ : "r0" \
+ );
#elif defined(__aarch64__)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
asm volatile( \
"mrs x16, tpidr_el0\n" \
"ldr x16, [x16, %[tls]]\n" \
@@ -133,120 +159,173 @@
: \
: [tls] "i" (TLS_SLOT_OPENGL_API * sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "x16" \
+ : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x16" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ asm volatile( \
+ "mov w0, wzr \n" \
+ : \
+ : \
+ : "w0" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ asm volatile( \
+ "ret \n" \
+ : \
+ : \
+ : \
);
#elif defined(__i386__)
- #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register void* fn; \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
__asm__ volatile( \
- "mov %%gs:0, %[fn]\n" \
- "mov %P[tls](%[fn]), %[fn]\n" \
- "test %[fn], %[fn]\n" \
+ "mov %%gs:0, %%eax\n" \
+ "mov %P[tls](%%eax), %%eax\n" \
+ "test %%eax, %%eax\n" \
"je 1f\n" \
- "jmp *%P[api](%[fn])\n" \
+ "jmp *%P[api](%%eax)\n" \
"1:\n" \
- : [fn] "=r" (fn) \
+ : \
: [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "cc" \
- );
+ : "cc", "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ __asm__ volatile( \
+ "xor %%eax, %%eax\n" \
+ : \
+ : \
+ : "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ __asm__ volatile( \
+ "ret\n" \
+ : \
+ : \
+ : \
+ );
#elif defined(__x86_64__)
- #define API_ENTRY(_api) __attribute__((noinline,optimize("omit-frame-pointer"))) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register void** fn; \
- __asm__ volatile( \
- "mov %%fs:0, %[fn]\n" \
- "mov %P[tls](%[fn]), %[fn]\n" \
- "test %[fn], %[fn]\n" \
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ __asm__ volatile( \
+ "mov %%fs:0, %%rax\n" \
+ "mov %P[tls](%%rax), %%rax\n" \
+ "test %%rax, %%rax\n" \
"je 1f\n" \
- "jmp *%P[api](%[fn])\n" \
+ "jmp *%P[api](%%rax)\n" \
"1:\n" \
- : [fn] "=r" (fn) \
+ : \
: [tls] "i" (TLS_SLOT_OPENGL_API*sizeof(void*)), \
[api] "i" (__builtin_offsetof(gl_hooks_t, gl._api)) \
- : "cc" \
- );
+ : "cc", "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9", \
+ "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", \
+ "%xmm6", "%xmm7" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ __asm__ volatile( \
+ "xor %%eax, %%eax\n" \
+ : \
+ : \
+ : "%eax" \
+ );
+
+ #define CALL_GL_API_INTERNAL_DO_RETURN \
+ __asm__ volatile( \
+ "retq\n" \
+ : \
+ : \
+ : \
+ );
#elif defined(__mips64)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register unsigned long _t0 asm("$12"); \
- register unsigned long _fn asm("$25"); \
- register unsigned long _tls asm("$3"); \
- register unsigned long _v0 asm("$2"); \
- asm volatile( \
- ".set push\n\t" \
- ".set noreorder\n\t" \
- "rdhwr %[tls], $29\n\t" \
- "ld %[t0], %[OPENGL_API](%[tls])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " move %[fn], $ra\n\t" \
- "ld %[t0], %[API](%[t0])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " nop\n\t" \
- "move %[fn], %[t0]\n\t" \
- "1:\n\t" \
- "jalr $0, %[fn]\n\t" \
- " move %[v0], $0\n\t" \
- ".set pop\n\t" \
- : [fn] "=c"(_fn), \
- [tls] "=&r"(_tls), \
- [t0] "=&r"(_t0), \
- [v0] "=&r"(_v0) \
- : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
- [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
+ // t0: $12
+ // fn: $25
+ // tls: $3
+ // v0: $2
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
+ asm volatile( \
+ ".set push\n\t" \
+ ".set noreorder\n\t" \
+ "rdhwr $3, $29\n\t" \
+ "ld $12, %[OPENGL_API]($3)\n\t" \
+ "beqz $12, 1f\n\t" \
+ " move $25, $ra\n\t" \
+ "ld $12, %[API]($12)\n\t" \
+ "beqz $12, 1f\n\t" \
+ " nop\n\t" \
+ "move $25, $12\n\t" \
+ "1:\n\t" \
+ "jalr $0, $25\n\t" \
+ " move $2, $0\n\t" \
+ ".set pop\n\t" \
+ : \
+ : [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*sizeof(void*)),\
+ [API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
+ : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", \
+ "$10", "$11", "$12", "$25" \
);
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+ #define CALL_GL_API_INTERNAL_DO_RETURN
+
#elif defined(__mips__)
- #define API_ENTRY(_api) __attribute__((noinline)) _api
+ #define API_ENTRY(_api) __attribute__((naked,noinline)) _api
- #define CALL_GL_API(_api, ...) \
- register unsigned int _t0 asm("$8"); \
- register unsigned int _fn asm("$25"); \
- register unsigned int _tls asm("$3"); \
- register unsigned int _v0 asm("$2"); \
+ // t0: $8
+ // fn: $25
+ // tls: $3
+ // v0: $2
+ #define CALL_GL_API_INTERNAL_CALL(_api, ...) \
asm volatile( \
".set push\n\t" \
".set noreorder\n\t" \
".set mips32r2\n\t" \
- "rdhwr %[tls], $29\n\t" \
- "lw %[t0], %[OPENGL_API](%[tls])\n\t" \
- "beqz %[t0], 1f\n\t" \
- " move %[fn], $ra\n\t" \
- "lw %[t0], %[API](%[t0])\n\t" \
- "beqz %[t0], 1f\n\t" \
+ "rdhwr $3, $29\n\t" \
+ "lw $3, %[OPENGL_API]($3)\n\t" \
+ "beqz $3, 1f\n\t" \
+ " move $25,$ra\n\t" \
+ "lw $3, %[API]($3)\n\t" \
+ "beqz $3, 1f\n\t" \
" nop\n\t" \
- "move %[fn], %[t0]\n\t" \
+ "move $25, $3\n\t" \
"1:\n\t" \
- "jalr $0, %[fn]\n\t" \
- " move %[v0], $0\n\t" \
+ "jalr $0, $25\n\t" \
+ " move $2, $0\n\t" \
".set pop\n\t" \
- : [fn] "=c"(_fn), \
- [tls] "=&r"(_tls), \
- [t0] "=&r"(_t0), \
- [v0] "=&r"(_v0) \
+ : \
: [OPENGL_API] "I"(TLS_SLOT_OPENGL_API*4), \
[API] "I"(__builtin_offsetof(gl_hooks_t, gl._api)) \
- : \
- );
+ : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$25" \
+ );
+
+ #define CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+ #define CALL_GL_API_INTERNAL_DO_RETURN
#endif
-#define CALL_GL_API_RETURN(_api, ...) \
- CALL_GL_API(_api, __VA_ARGS__) \
- return 0;
+#define CALL_GL_API(_api, ...) \
+ CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+ CALL_GL_API_INTERNAL_DO_RETURN
+#define CALL_GL_API_RETURN(_api, ...) \
+ CALL_GL_API_INTERNAL_CALL(_api, __VA_ARGS__) \
+ CALL_GL_API_INTERNAL_SET_RETURN_VALUE \
+ CALL_GL_API_INTERNAL_DO_RETURN
extern "C" {
#pragma GCC diagnostic ignored "-Wunused-parameter"
@@ -257,6 +336,9 @@
#undef API_ENTRY
#undef CALL_GL_API
+#undef CALL_GL_API_INTERNAL_CALL
+#undef CALL_GL_API_INTERNAL_SET_RETURN_VALUE
+#undef CALL_GL_API_INTERNAL_DO_RETURN
#undef CALL_GL_API_RETURN
/*
diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h
index e14075c..81dbe0e 100644
--- a/opengl/libs/hooks.h
+++ b/opengl/libs/hooks.h
@@ -56,8 +56,8 @@
#undef GL_ENTRY
#undef EGL_ENTRY
-#define GL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
-#define EGL_ENTRY(_r, _api, ...) _r (*_api)(__VA_ARGS__);
+#define GL_ENTRY(_r, _api, ...) _r (*(_api))(__VA_ARGS__);
+#define EGL_ENTRY(_r, _api, ...) _r (*(_api))(__VA_ARGS__);
struct egl_t {
#include "EGL/egl_entries.in"
diff --git a/opengl/libs/libEGL.map.txt b/opengl/libs/libEGL.map.txt
new file mode 100644
index 0000000..c8b83f5
--- /dev/null
+++ b/opengl/libs/libEGL.map.txt
@@ -0,0 +1,67 @@
+LIBEGL {
+ global:
+ eglBindAPI;
+ eglBindTexImage;
+ eglChooseConfig;
+ eglClientWaitSyncKHR; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+ eglCopyBuffers;
+ eglCreateContext;
+ eglCreateImageKHR;
+ eglCreateNativeClientBufferANDROID; # introduced=24
+ eglCreatePbufferFromClientBuffer;
+ eglCreatePbufferSurface;
+ eglCreatePixmapSurface;
+ eglCreateStreamFromFileDescriptorKHR; # introduced=23
+ eglCreateStreamKHR; # introduced=23
+ eglCreateStreamProducerSurfaceKHR; # introduced=23
+ eglCreateSyncKHR; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+ eglCreateWindowSurface;
+ eglDestroyContext;
+ eglDestroyImageKHR;
+ eglDestroyStreamKHR; # introduced=23
+ eglDestroySurface;
+ eglDestroySyncKHR; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+ eglGetConfigAttrib;
+ eglGetConfigs;
+ eglGetCurrentContext;
+ eglGetCurrentDisplay;
+ eglGetCurrentSurface;
+ eglGetDisplay;
+ eglGetError;
+ eglGetProcAddress;
+ eglGetStreamFileDescriptorKHR; # introduced=23
+ eglGetSyncAttribKHR; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+ eglGetSystemTimeFrequencyNV; # introduced-arm=14 introduced-arm64=21 introduced-mips=14 introduced-mips64=21 introduced-x86=14 introduced-x86_64=21
+ eglGetSystemTimeNV; # introduced-arm=14 introduced-arm64=21 introduced-mips=14 introduced-mips64=21 introduced-x86=14 introduced-x86_64=21
+ eglInitialize;
+ eglLockSurfaceKHR;
+ eglMakeCurrent;
+ eglPresentationTimeANDROID; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+ eglQueryAPI;
+ eglQueryContext;
+ eglQueryStreamKHR; # introduced=23
+ eglQueryStreamTimeKHR; # introduced=23
+ eglQueryStreamu64KHR; # introduced=23
+ eglQueryString;
+ eglQuerySurface;
+ eglReleaseTexImage;
+ eglReleaseThread;
+ eglSetDamageRegionKHR; # introduced=23
+ eglSignalSyncKHR; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+ eglStreamAttribKHR; # introduced=23
+ eglStreamConsumerAcquireKHR; # introduced=23
+ eglStreamConsumerGLTextureExternalKHR; # introduced=23
+ eglStreamConsumerReleaseKHR; # introduced=23
+ eglSurfaceAttrib;
+ eglSwapBuffers;
+ eglSwapBuffersWithDamageKHR; # introduced=23
+ eglSwapInterval;
+ eglTerminate;
+ eglUnlockSurfaceKHR;
+ eglWaitClient;
+ eglWaitGL;
+ eglWaitNative;
+ eglWaitSyncKHR; # introduced-arm=18 introduced-arm64=21 introduced-mips=18 introduced-mips64=21 introduced-x86=18 introduced-x86_64=21
+ local:
+ *;
+};
diff --git a/opengl/libs/libGLESv1_CM.map.txt b/opengl/libs/libGLESv1_CM.map.txt
new file mode 100644
index 0000000..8ba91e6
--- /dev/null
+++ b/opengl/libs/libGLESv1_CM.map.txt
@@ -0,0 +1,283 @@
+LIBGLESV1_CM {
+ global:
+ glActiveTexture;
+ glAlphaFunc;
+ glAlphaFuncx;
+ glAlphaFuncxOES;
+ glBindBuffer;
+ glBindFramebufferOES;
+ glBindRenderbufferOES;
+ glBindTexture;
+ glBindVertexArrayOES; # introduced-mips=9 introduced-x86=9
+ glBlendEquationOES;
+ glBlendEquationSeparateOES;
+ glBlendFunc;
+ glBlendFuncSeparateOES;
+ glBufferData;
+ glBufferSubData;
+ glCheckFramebufferStatusOES;
+ glClear;
+ glClearColor;
+ glClearColorx;
+ glClearColorxOES;
+ glClearDepthf;
+ glClearDepthfOES;
+ glClearDepthx;
+ glClearDepthxOES;
+ glClearStencil;
+ glClientActiveTexture;
+ glClipPlanef;
+ glClipPlanefIMG; # introduced-mips=9 introduced-x86=9
+ glClipPlanefOES;
+ glClipPlanex;
+ glClipPlanexIMG; # introduced-mips=9 introduced-x86=9
+ glClipPlanexOES;
+ glColor4f;
+ glColor4ub;
+ glColor4x;
+ glColor4xOES;
+ glColorMask;
+ glColorPointer;
+ glColorPointerBounds;
+ glCompressedTexImage2D;
+ glCompressedTexSubImage2D;
+ glCopyTexImage2D;
+ glCopyTexSubImage2D;
+ glCullFace;
+ glCurrentPaletteMatrixOES;
+ glDeleteBuffers;
+ glDeleteFencesNV; # introduced-mips=9 introduced-x86=9
+ glDeleteFramebuffersOES;
+ glDeleteRenderbuffersOES;
+ glDeleteTextures;
+ glDeleteVertexArraysOES; # introduced-mips=9 introduced-x86=9
+ glDepthFunc;
+ glDepthMask;
+ glDepthRangef;
+ glDepthRangefOES;
+ glDepthRangex;
+ glDepthRangexOES;
+ glDisable;
+ glDisableClientState;
+ glDisableDriverControlQCOM; # introduced-mips=9 introduced-x86=9
+ glDiscardFramebufferEXT; # introduced-mips=9 introduced-x86=9
+ glDrawArrays;
+ glDrawElements;
+ glDrawTexfOES;
+ glDrawTexfvOES;
+ glDrawTexiOES;
+ glDrawTexivOES;
+ glDrawTexsOES;
+ glDrawTexsvOES;
+ glDrawTexxOES;
+ glDrawTexxvOES;
+ glEGLImageTargetRenderbufferStorageOES;
+ glEGLImageTargetTexture2DOES;
+ glEnable;
+ glEnableClientState;
+ glEnableDriverControlQCOM; # introduced-mips=9 introduced-x86=9
+ glEndTilingQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetBufferPointervQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetBuffersQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetFramebuffersQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetProgramBinarySourceQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetProgramsQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetRenderbuffersQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetShadersQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetTexLevelParameterivQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetTexSubImageQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetTexturesQCOM; # introduced-mips=9 introduced-x86=9
+ glExtIsProgramBinaryQCOM; # introduced-mips=9 introduced-x86=9
+ glExtTexObjectStateOverrideiQCOM; # introduced-mips=9 introduced-x86=9
+ glFinish;
+ glFinishFenceNV; # introduced-mips=9 introduced-x86=9
+ glFlush;
+ glFogf;
+ glFogfv;
+ glFogx;
+ glFogxOES;
+ glFogxv;
+ glFogxvOES;
+ glFramebufferRenderbufferOES;
+ glFramebufferTexture2DMultisampleIMG; # introduced-mips=9 introduced-x86=9
+ glFramebufferTexture2DOES;
+ glFrontFace;
+ glFrustumf;
+ glFrustumfOES;
+ glFrustumx;
+ glFrustumxOES;
+ glGenBuffers;
+ glGenFencesNV; # introduced-mips=9 introduced-x86=9
+ glGenFramebuffersOES;
+ glGenRenderbuffersOES;
+ glGenTextures;
+ glGenVertexArraysOES; # introduced-mips=9 introduced-x86=9
+ glGenerateMipmapOES;
+ glGetBooleanv;
+ glGetBufferParameteriv;
+ glGetBufferPointervOES;
+ glGetClipPlanef;
+ glGetClipPlanefOES;
+ glGetClipPlanex;
+ glGetClipPlanexOES;
+ glGetDriverControlStringQCOM; # introduced-mips=9 introduced-x86=9
+ glGetDriverControlsQCOM; # introduced-mips=9 introduced-x86=9
+ glGetError;
+ glGetFenceivNV; # introduced-mips=9 introduced-x86=9
+ glGetFixedv;
+ glGetFixedvOES;
+ glGetFloatv;
+ glGetFramebufferAttachmentParameterivOES;
+ glGetIntegerv;
+ glGetLightfv;
+ glGetLightxv;
+ glGetLightxvOES;
+ glGetMaterialfv;
+ glGetMaterialxv;
+ glGetMaterialxvOES;
+ glGetPointerv;
+ glGetRenderbufferParameterivOES;
+ glGetString;
+ glGetTexEnvfv;
+ glGetTexEnviv;
+ glGetTexEnvxv;
+ glGetTexEnvxvOES;
+ glGetTexGenfvOES;
+ glGetTexGenivOES;
+ glGetTexGenxvOES;
+ glGetTexParameterfv;
+ glGetTexParameteriv;
+ glGetTexParameterxv;
+ glGetTexParameterxvOES;
+ glHint;
+ glIsBuffer;
+ glIsEnabled;
+ glIsFenceNV; # introduced-mips=9 introduced-x86=9
+ glIsFramebufferOES;
+ glIsRenderbufferOES;
+ glIsTexture;
+ glIsVertexArrayOES; # introduced-mips=9 introduced-x86=9
+ glLightModelf;
+ glLightModelfv;
+ glLightModelx;
+ glLightModelxOES;
+ glLightModelxv;
+ glLightModelxvOES;
+ glLightf;
+ glLightfv;
+ glLightx;
+ glLightxOES;
+ glLightxv;
+ glLightxvOES;
+ glLineWidth;
+ glLineWidthx;
+ glLineWidthxOES;
+ glLoadIdentity;
+ glLoadMatrixf;
+ glLoadMatrixx;
+ glLoadMatrixxOES;
+ glLoadPaletteFromModelViewMatrixOES;
+ glLogicOp;
+ glMapBufferOES;
+ glMaterialf;
+ glMaterialfv;
+ glMaterialx;
+ glMaterialxOES;
+ glMaterialxv;
+ glMaterialxvOES;
+ glMatrixIndexPointerOES;
+ glMatrixIndexPointerOESBounds; # introduced-mips=9 introduced-x86=9
+ glMatrixMode;
+ glMultMatrixf;
+ glMultMatrixx;
+ glMultMatrixxOES;
+ glMultiDrawArraysEXT; # introduced-mips=9 introduced-x86=9
+ glMultiDrawElementsEXT; # introduced-mips=9 introduced-x86=9
+ glMultiTexCoord4f;
+ glMultiTexCoord4x;
+ glMultiTexCoord4xOES;
+ glNormal3f;
+ glNormal3x;
+ glNormal3xOES;
+ glNormalPointer;
+ glNormalPointerBounds;
+ glOrthof;
+ glOrthofOES;
+ glOrthox;
+ glOrthoxOES;
+ glPixelStorei;
+ glPointParameterf;
+ glPointParameterfv;
+ glPointParameterx;
+ glPointParameterxOES;
+ glPointParameterxv;
+ glPointParameterxvOES;
+ glPointSize;
+ glPointSizePointerOES;
+ glPointSizePointerOESBounds; # introduced-mips=9 introduced-x86=9
+ glPointSizex;
+ glPointSizexOES;
+ glPolygonOffset;
+ glPolygonOffsetx;
+ glPolygonOffsetxOES;
+ glPopMatrix;
+ glPushMatrix;
+ glQueryMatrixxOES;
+ glReadPixels;
+ glRenderbufferStorageMultisampleIMG; # introduced-mips=9 introduced-x86=9
+ glRenderbufferStorageOES;
+ glRotatef;
+ glRotatex;
+ glRotatexOES;
+ glSampleCoverage;
+ glSampleCoveragex;
+ glSampleCoveragexOES;
+ glScalef;
+ glScalex;
+ glScalexOES;
+ glScissor;
+ glSetFenceNV; # introduced-mips=9 introduced-x86=9
+ glShadeModel;
+ glStartTilingQCOM; # introduced-mips=9 introduced-x86=9
+ glStencilFunc;
+ glStencilMask;
+ glStencilOp;
+ glTestFenceNV; # introduced-mips=9 introduced-x86=9
+ glTexCoordPointer;
+ glTexCoordPointerBounds;
+ glTexEnvf;
+ glTexEnvfv;
+ glTexEnvi;
+ glTexEnviv;
+ glTexEnvx;
+ glTexEnvxOES;
+ glTexEnvxv;
+ glTexEnvxvOES;
+ glTexGenfOES;
+ glTexGenfvOES;
+ glTexGeniOES;
+ glTexGenivOES;
+ glTexGenxOES;
+ glTexGenxvOES;
+ glTexImage2D;
+ glTexParameterf;
+ glTexParameterfv;
+ glTexParameteri;
+ glTexParameteriv;
+ glTexParameterx;
+ glTexParameterxOES;
+ glTexParameterxv;
+ glTexParameterxvOES;
+ glTexSubImage2D;
+ glTranslatef;
+ glTranslatex;
+ glTranslatexOES;
+ glUnmapBufferOES;
+ glVertexPointer;
+ glVertexPointerBounds;
+ glViewport;
+ glWeightPointerOES;
+ glWeightPointerOESBounds; # introduced-mips=9 introduced-x86=9
+ local:
+ *;
+};
diff --git a/opengl/libs/libGLESv2.map.txt b/opengl/libs/libGLESv2.map.txt
new file mode 100644
index 0000000..1b0042a
--- /dev/null
+++ b/opengl/libs/libGLESv2.map.txt
@@ -0,0 +1,207 @@
+LIBGLESV2 {
+ global:
+ glActiveTexture;
+ glAttachShader;
+ glBeginPerfMonitorAMD;
+ glBindAttribLocation;
+ glBindBuffer;
+ glBindFramebuffer;
+ glBindRenderbuffer;
+ glBindTexture;
+ glBindVertexArrayOES; # introduced-mips=9 introduced-x86=9
+ glBlendColor;
+ glBlendEquation;
+ glBlendEquationSeparate;
+ glBlendFunc;
+ glBlendFuncSeparate;
+ glBufferData;
+ glBufferSubData;
+ glCheckFramebufferStatus;
+ glClear;
+ glClearColor;
+ glClearDepthf;
+ glClearStencil;
+ glColorMask;
+ glCompileShader;
+ glCompressedTexImage2D;
+ glCompressedTexImage3DOES;
+ glCompressedTexSubImage2D;
+ glCompressedTexSubImage3DOES;
+ glCopyTexImage2D;
+ glCopyTexSubImage2D;
+ glCopyTexSubImage3DOES;
+ glCoverageMaskNV; # introduced-mips=9 introduced-x86=9
+ glCoverageOperationNV; # introduced-mips=9 introduced-x86=9
+ glCreateProgram;
+ glCreateShader;
+ glCullFace;
+ glDeleteBuffers;
+ glDeleteFencesNV;
+ glDeleteFramebuffers;
+ glDeletePerfMonitorsAMD;
+ glDeleteProgram;
+ glDeleteRenderbuffers;
+ glDeleteShader;
+ glDeleteTextures;
+ glDeleteVertexArraysOES; # introduced-mips=9 introduced-x86=9
+ glDepthFunc;
+ glDepthMask;
+ glDepthRangef;
+ glDetachShader;
+ glDisable;
+ glDisableDriverControlQCOM;
+ glDisableVertexAttribArray;
+ glDiscardFramebufferEXT; # introduced-mips=9 introduced-x86=9
+ glDrawArrays;
+ glDrawElements;
+ glEGLImageTargetRenderbufferStorageOES;
+ glEGLImageTargetTexture2DOES;
+ glEnable;
+ glEnableDriverControlQCOM;
+ glEnableVertexAttribArray;
+ glEndPerfMonitorAMD;
+ glEndTilingQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetBufferPointervQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetBuffersQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetFramebuffersQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetProgramBinarySourceQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetProgramsQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetRenderbuffersQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetShadersQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetTexLevelParameterivQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetTexSubImageQCOM; # introduced-mips=9 introduced-x86=9
+ glExtGetTexturesQCOM; # introduced-mips=9 introduced-x86=9
+ glExtIsProgramBinaryQCOM; # introduced-mips=9 introduced-x86=9
+ glExtTexObjectStateOverrideiQCOM; # introduced-mips=9 introduced-x86=9
+ glFinish;
+ glFinishFenceNV;
+ glFlush;
+ glFramebufferRenderbuffer;
+ glFramebufferTexture2D;
+ glFramebufferTexture2DMultisampleIMG; # introduced-mips=9 introduced-x86=9
+ glFramebufferTexture3DOES;
+ glFrontFace;
+ glGenBuffers;
+ glGenFencesNV;
+ glGenFramebuffers;
+ glGenPerfMonitorsAMD;
+ glGenRenderbuffers;
+ glGenTextures;
+ glGenVertexArraysOES; # introduced-mips=9 introduced-x86=9
+ glGenerateMipmap;
+ glGetActiveAttrib;
+ glGetActiveUniform;
+ glGetAttachedShaders;
+ glGetAttribLocation;
+ glGetBooleanv;
+ glGetBufferParameteriv;
+ glGetBufferPointervOES;
+ glGetDriverControlStringQCOM;
+ glGetDriverControlsQCOM;
+ glGetError;
+ glGetFenceivNV;
+ glGetFloatv;
+ glGetFramebufferAttachmentParameteriv;
+ glGetIntegerv;
+ glGetPerfMonitorCounterDataAMD;
+ glGetPerfMonitorCounterInfoAMD;
+ glGetPerfMonitorCounterStringAMD;
+ glGetPerfMonitorCountersAMD;
+ glGetPerfMonitorGroupStringAMD;
+ glGetPerfMonitorGroupsAMD;
+ glGetProgramBinaryOES;
+ glGetProgramInfoLog;
+ glGetProgramiv;
+ glGetRenderbufferParameteriv;
+ glGetShaderInfoLog;
+ glGetShaderPrecisionFormat;
+ glGetShaderSource;
+ glGetShaderiv;
+ glGetString;
+ glGetTexParameterfv;
+ glGetTexParameteriv;
+ glGetUniformLocation;
+ glGetUniformfv;
+ glGetUniformiv;
+ glGetVertexAttribPointerv;
+ glGetVertexAttribfv;
+ glGetVertexAttribiv;
+ glHint;
+ glIsBuffer;
+ glIsEnabled;
+ glIsFenceNV;
+ glIsFramebuffer;
+ glIsProgram;
+ glIsRenderbuffer;
+ glIsShader;
+ glIsTexture;
+ glIsVertexArrayOES; # introduced-mips=9 introduced-x86=9
+ glLineWidth;
+ glLinkProgram;
+ glMapBufferOES;
+ glMultiDrawArraysEXT; # introduced-mips=9 introduced-x86=9
+ glMultiDrawElementsEXT; # introduced-mips=9 introduced-x86=9
+ glPixelStorei;
+ glPolygonOffset;
+ glProgramBinaryOES;
+ glReadPixels;
+ glReleaseShaderCompiler;
+ glRenderbufferStorage;
+ glRenderbufferStorageMultisampleIMG; # introduced-mips=9 introduced-x86=9
+ glSampleCoverage;
+ glScissor;
+ glSelectPerfMonitorCountersAMD;
+ glSetFenceNV;
+ glShaderBinary;
+ glShaderSource;
+ glStartTilingQCOM; # introduced-mips=9 introduced-x86=9
+ glStencilFunc;
+ glStencilFuncSeparate;
+ glStencilMask;
+ glStencilMaskSeparate;
+ glStencilOp;
+ glStencilOpSeparate;
+ glTestFenceNV;
+ glTexImage2D;
+ glTexImage3DOES;
+ glTexParameterf;
+ glTexParameterfv;
+ glTexParameteri;
+ glTexParameteriv;
+ glTexSubImage2D;
+ glTexSubImage3DOES;
+ glUniform1f;
+ glUniform1fv;
+ glUniform1i;
+ glUniform1iv;
+ glUniform2f;
+ glUniform2fv;
+ glUniform2i;
+ glUniform2iv;
+ glUniform3f;
+ glUniform3fv;
+ glUniform3i;
+ glUniform3iv;
+ glUniform4f;
+ glUniform4fv;
+ glUniform4i;
+ glUniform4iv;
+ glUniformMatrix2fv;
+ glUniformMatrix3fv;
+ glUniformMatrix4fv;
+ glUnmapBufferOES;
+ glUseProgram;
+ glValidateProgram;
+ glVertexAttrib1f;
+ glVertexAttrib1fv;
+ glVertexAttrib2f;
+ glVertexAttrib2fv;
+ glVertexAttrib3f;
+ glVertexAttrib3fv;
+ glVertexAttrib4f;
+ glVertexAttrib4fv;
+ glVertexAttribPointer;
+ glViewport;
+ local:
+ *;
+};
diff --git a/opengl/libs/libGLESv3.map.txt b/opengl/libs/libGLESv3.map.txt
new file mode 100644
index 0000000..21f6cb6
--- /dev/null
+++ b/opengl/libs/libGLESv3.map.txt
@@ -0,0 +1,416 @@
+LIBGLESV3 {
+ global:
+ glActiveShaderProgram; # introduced=21
+ glActiveTexture;
+ glAttachShader;
+ glBeginQuery;
+ glBeginTransformFeedback;
+ glBindAttribLocation;
+ glBindBuffer;
+ glBindBufferBase;
+ glBindBufferRange;
+ glBindFramebuffer;
+ glBindImageTexture; # introduced=21
+ glBindProgramPipeline; # introduced=21
+ glBindRenderbuffer;
+ glBindSampler;
+ glBindTexture;
+ glBindTransformFeedback;
+ glBindVertexArray;
+ glBindVertexArrayOES;
+ glBindVertexBuffer; # introduced=21
+ glBlendBarrier; # introduced=24
+ glBlendBarrierKHR; # introduced=21
+ glBlendColor;
+ glBlendEquation;
+ glBlendEquationSeparate;
+ glBlendEquationSeparatei; # introduced=24
+ glBlendEquationSeparateiEXT; # introduced=21
+ glBlendEquationi; # introduced=24
+ glBlendEquationiEXT; # introduced=21
+ glBlendFunc;
+ glBlendFuncSeparate;
+ glBlendFuncSeparatei; # introduced=24
+ glBlendFuncSeparateiEXT; # introduced=21
+ glBlendFunci; # introduced=24
+ glBlendFunciEXT; # introduced=21
+ glBlitFramebuffer;
+ glBufferData;
+ glBufferSubData;
+ glCheckFramebufferStatus;
+ glClear;
+ glClearBufferfi;
+ glClearBufferfv;
+ glClearBufferiv;
+ glClearBufferuiv;
+ glClearColor;
+ glClearDepthf;
+ glClearStencil;
+ glClientWaitSync;
+ glColorMask;
+ glColorMaski; # introduced=24
+ glColorMaskiEXT; # introduced=21
+ glCompileShader;
+ glCompressedTexImage2D;
+ glCompressedTexImage3D;
+ glCompressedTexImage3DOES;
+ glCompressedTexSubImage2D;
+ glCompressedTexSubImage3D;
+ glCompressedTexSubImage3DOES;
+ glCopyBufferSubData;
+ glCopyImageSubData; # introduced=24
+ glCopyImageSubDataEXT; # introduced=21
+ glCopyTexImage2D;
+ glCopyTexSubImage2D;
+ glCopyTexSubImage3D;
+ glCopyTexSubImage3DOES;
+ glCreateProgram;
+ glCreateShader;
+ glCreateShaderProgramv; # introduced=21
+ glCullFace;
+ glDebugMessageCallback; # introduced=24
+ glDebugMessageCallbackKHR; # introduced=21
+ glDebugMessageControl; # introduced=24
+ glDebugMessageControlKHR; # introduced=21
+ glDebugMessageInsert; # introduced=24
+ glDebugMessageInsertKHR; # introduced=21
+ glDeleteBuffers;
+ glDeleteFramebuffers;
+ glDeleteProgram;
+ glDeleteProgramPipelines; # introduced=21
+ glDeleteQueries;
+ glDeleteRenderbuffers;
+ glDeleteSamplers;
+ glDeleteShader;
+ glDeleteSync;
+ glDeleteTextures;
+ glDeleteTransformFeedbacks;
+ glDeleteVertexArrays;
+ glDeleteVertexArraysOES;
+ glDepthFunc;
+ glDepthMask;
+ glDepthRangef;
+ glDetachShader;
+ glDisable;
+ glDisableVertexAttribArray;
+ glDisablei; # introduced=24
+ glDisableiEXT; # introduced=21
+ glDispatchCompute; # introduced=21
+ glDispatchComputeIndirect; # introduced=21
+ glDrawArrays;
+ glDrawArraysIndirect; # introduced=21
+ glDrawArraysInstanced;
+ glDrawBuffers;
+ glDrawElements;
+ glDrawElementsBaseVertex; # introduced=24
+ glDrawElementsIndirect; # introduced=21
+ glDrawElementsInstanced;
+ glDrawElementsInstancedBaseVertex; # introduced=24
+ glDrawRangeElements;
+ glDrawRangeElementsBaseVertex; # introduced=24
+ glEGLImageTargetRenderbufferStorageOES;
+ glEGLImageTargetTexture2DOES;
+ glEnable;
+ glEnableVertexAttribArray;
+ glEnablei; # introduced=24
+ glEnableiEXT; # introduced=21
+ glEndQuery;
+ glEndTransformFeedback;
+ glFenceSync;
+ glFinish;
+ glFlush;
+ glFlushMappedBufferRange;
+ glFramebufferParameteri; # introduced=21
+ glFramebufferRenderbuffer;
+ glFramebufferTexture; # introduced=24
+ glFramebufferTexture2D;
+ glFramebufferTexture3DOES;
+ glFramebufferTextureEXT; # introduced=21
+ glFramebufferTextureLayer;
+ glFrontFace;
+ glGenBuffers;
+ glGenFramebuffers;
+ glGenProgramPipelines; # introduced=21
+ glGenQueries;
+ glGenRenderbuffers;
+ glGenSamplers;
+ glGenTextures;
+ glGenTransformFeedbacks;
+ glGenVertexArrays;
+ glGenVertexArraysOES;
+ glGenerateMipmap;
+ glGetActiveAttrib;
+ glGetActiveUniform;
+ glGetActiveUniformBlockName;
+ glGetActiveUniformBlockiv;
+ glGetActiveUniformsiv;
+ glGetAttachedShaders;
+ glGetAttribLocation;
+ glGetBooleani_v; # introduced=21
+ glGetBooleanv;
+ glGetBufferParameteri64v;
+ glGetBufferParameteriv;
+ glGetBufferPointerv;
+ glGetBufferPointervOES;
+ glGetDebugMessageLog; # introduced=24
+ glGetDebugMessageLogKHR; # introduced=21
+ glGetError;
+ glGetFloatv;
+ glGetFragDataLocation;
+ glGetFramebufferAttachmentParameteriv;
+ glGetFramebufferParameteriv; # introduced=21
+ glGetGraphicsResetStatus; # introduced=24
+ glGetInteger64i_v;
+ glGetInteger64v;
+ glGetIntegeri_v;
+ glGetIntegerv;
+ glGetInternalformativ;
+ glGetMultisamplefv; # introduced=21
+ glGetObjectLabel; # introduced=24
+ glGetObjectLabelKHR; # introduced=21
+ glGetObjectPtrLabel; # introduced=24
+ glGetObjectPtrLabelKHR; # introduced=21
+ glGetPointerv; # introduced=24
+ glGetPointervKHR; # introduced=21
+ glGetProgramBinary;
+ glGetProgramBinaryOES;
+ glGetProgramInfoLog;
+ glGetProgramInterfaceiv; # introduced=21
+ glGetProgramPipelineInfoLog; # introduced=21
+ glGetProgramPipelineiv; # introduced=21
+ glGetProgramResourceIndex; # introduced=21
+ glGetProgramResourceLocation; # introduced=21
+ glGetProgramResourceName; # introduced=21
+ glGetProgramResourceiv; # introduced=21
+ glGetProgramiv;
+ glGetQueryObjectuiv;
+ glGetQueryiv;
+ glGetRenderbufferParameteriv;
+ glGetSamplerParameterIiv; # introduced=24
+ glGetSamplerParameterIivEXT; # introduced=21
+ glGetSamplerParameterIuiv; # introduced=24
+ glGetSamplerParameterIuivEXT; # introduced=21
+ glGetSamplerParameterfv;
+ glGetSamplerParameteriv;
+ glGetShaderInfoLog;
+ glGetShaderPrecisionFormat;
+ glGetShaderSource;
+ glGetShaderiv;
+ glGetString;
+ glGetStringi;
+ glGetSynciv;
+ glGetTexLevelParameterfv; # introduced=21
+ glGetTexLevelParameteriv; # introduced=21
+ glGetTexParameterIiv; # introduced=24
+ glGetTexParameterIivEXT; # introduced=21
+ glGetTexParameterIuiv; # introduced=24
+ glGetTexParameterIuivEXT; # introduced=21
+ glGetTexParameterfv;
+ glGetTexParameteriv;
+ glGetTransformFeedbackVarying;
+ glGetUniformBlockIndex;
+ glGetUniformIndices;
+ glGetUniformLocation;
+ glGetUniformfv;
+ glGetUniformiv;
+ glGetUniformuiv;
+ glGetVertexAttribIiv;
+ glGetVertexAttribIuiv;
+ glGetVertexAttribPointerv;
+ glGetVertexAttribfv;
+ glGetVertexAttribiv;
+ glGetnUniformfv; # introduced=24
+ glGetnUniformiv; # introduced=24
+ glGetnUniformuiv; # introduced=24
+ glHint;
+ glInvalidateFramebuffer;
+ glInvalidateSubFramebuffer;
+ glIsBuffer;
+ glIsEnabled;
+ glIsEnabledi; # introduced=24
+ glIsEnablediEXT; # introduced=21
+ glIsFramebuffer;
+ glIsProgram;
+ glIsProgramPipeline; # introduced=21
+ glIsQuery;
+ glIsRenderbuffer;
+ glIsSampler;
+ glIsShader;
+ glIsSync;
+ glIsTexture;
+ glIsTransformFeedback;
+ glIsVertexArray;
+ glIsVertexArrayOES;
+ glLineWidth;
+ glLinkProgram;
+ glMapBufferOES;
+ glMapBufferRange;
+ glMemoryBarrier; # introduced=21
+ glMemoryBarrierByRegion; # introduced=21
+ glMinSampleShading; # introduced=24
+ glMinSampleShadingOES; # introduced=21
+ glObjectLabel; # introduced=24
+ glObjectLabelKHR; # introduced=21
+ glObjectPtrLabel; # introduced=24
+ glObjectPtrLabelKHR; # introduced=21
+ glPatchParameteri; # introduced=24
+ glPatchParameteriEXT; # introduced=21
+ glPauseTransformFeedback;
+ glPixelStorei;
+ glPolygonOffset;
+ glPopDebugGroup; # introduced=24
+ glPopDebugGroupKHR; # introduced=21
+ glPrimitiveBoundingBox; # introduced=24
+ glPrimitiveBoundingBoxEXT; # introduced=21
+ glProgramBinary;
+ glProgramBinaryOES;
+ glProgramParameteri;
+ glProgramUniform1f; # introduced=21
+ glProgramUniform1fv; # introduced=21
+ glProgramUniform1i; # introduced=21
+ glProgramUniform1iv; # introduced=21
+ glProgramUniform1ui; # introduced=21
+ glProgramUniform1uiv; # introduced=21
+ glProgramUniform2f; # introduced=21
+ glProgramUniform2fv; # introduced=21
+ glProgramUniform2i; # introduced=21
+ glProgramUniform2iv; # introduced=21
+ glProgramUniform2ui; # introduced=21
+ glProgramUniform2uiv; # introduced=21
+ glProgramUniform3f; # introduced=21
+ glProgramUniform3fv; # introduced=21
+ glProgramUniform3i; # introduced=21
+ glProgramUniform3iv; # introduced=21
+ glProgramUniform3ui; # introduced=21
+ glProgramUniform3uiv; # introduced=21
+ glProgramUniform4f; # introduced=21
+ glProgramUniform4fv; # introduced=21
+ glProgramUniform4i; # introduced=21
+ glProgramUniform4iv; # introduced=21
+ glProgramUniform4ui; # introduced=21
+ glProgramUniform4uiv; # introduced=21
+ glProgramUniformMatrix2fv; # introduced=21
+ glProgramUniformMatrix2x3fv; # introduced=21
+ glProgramUniformMatrix2x4fv; # introduced=21
+ glProgramUniformMatrix3fv; # introduced=21
+ glProgramUniformMatrix3x2fv; # introduced=21
+ glProgramUniformMatrix3x4fv; # introduced=21
+ glProgramUniformMatrix4fv; # introduced=21
+ glProgramUniformMatrix4x2fv; # introduced=21
+ glProgramUniformMatrix4x3fv; # introduced=21
+ glPushDebugGroup; # introduced=24
+ glPushDebugGroupKHR; # introduced=21
+ glReadBuffer;
+ glReadPixels;
+ glReadnPixels; # introduced=24
+ glReleaseShaderCompiler;
+ glRenderbufferStorage;
+ glRenderbufferStorageMultisample;
+ glResumeTransformFeedback;
+ glSampleCoverage;
+ glSampleMaski; # introduced=21
+ glSamplerParameterIiv; # introduced=24
+ glSamplerParameterIivEXT; # introduced=21
+ glSamplerParameterIuiv; # introduced=24
+ glSamplerParameterIuivEXT; # introduced=21
+ glSamplerParameterf;
+ glSamplerParameterfv;
+ glSamplerParameteri;
+ glSamplerParameteriv;
+ glScissor;
+ glShaderBinary;
+ glShaderSource;
+ glStencilFunc;
+ glStencilFuncSeparate;
+ glStencilMask;
+ glStencilMaskSeparate;
+ glStencilOp;
+ glStencilOpSeparate;
+ glTexBuffer; # introduced=24
+ glTexBufferEXT; # introduced=21
+ glTexBufferRange; # introduced=24
+ glTexBufferRangeEXT; # introduced=21
+ glTexImage2D;
+ glTexImage3D;
+ glTexImage3DOES;
+ glTexParameterIiv; # introduced=24
+ glTexParameterIivEXT; # introduced=21
+ glTexParameterIuiv; # introduced=24
+ glTexParameterIuivEXT; # introduced=21
+ glTexParameterf;
+ glTexParameterfv;
+ glTexParameteri;
+ glTexParameteriv;
+ glTexStorage2D;
+ glTexStorage2DMultisample; # introduced=21
+ glTexStorage3D;
+ glTexStorage3DMultisample; # introduced=24
+ glTexStorage3DMultisampleOES; # introduced=21
+ glTexSubImage2D;
+ glTexSubImage3D;
+ glTexSubImage3DOES;
+ glTransformFeedbackVaryings;
+ glUniform1f;
+ glUniform1fv;
+ glUniform1i;
+ glUniform1iv;
+ glUniform1ui;
+ glUniform1uiv;
+ glUniform2f;
+ glUniform2fv;
+ glUniform2i;
+ glUniform2iv;
+ glUniform2ui;
+ glUniform2uiv;
+ glUniform3f;
+ glUniform3fv;
+ glUniform3i;
+ glUniform3iv;
+ glUniform3ui;
+ glUniform3uiv;
+ glUniform4f;
+ glUniform4fv;
+ glUniform4i;
+ glUniform4iv;
+ glUniform4ui;
+ glUniform4uiv;
+ glUniformBlockBinding;
+ glUniformMatrix2fv;
+ glUniformMatrix2x3fv;
+ glUniformMatrix2x4fv;
+ glUniformMatrix3fv;
+ glUniformMatrix3x2fv;
+ glUniformMatrix3x4fv;
+ glUniformMatrix4fv;
+ glUniformMatrix4x2fv;
+ glUniformMatrix4x3fv;
+ glUnmapBuffer;
+ glUnmapBufferOES;
+ glUseProgram;
+ glUseProgramStages; # introduced=21
+ glValidateProgram;
+ glValidateProgramPipeline; # introduced=21
+ glVertexAttrib1f;
+ glVertexAttrib1fv;
+ glVertexAttrib2f;
+ glVertexAttrib2fv;
+ glVertexAttrib3f;
+ glVertexAttrib3fv;
+ glVertexAttrib4f;
+ glVertexAttrib4fv;
+ glVertexAttribBinding; # introduced=21
+ glVertexAttribDivisor;
+ glVertexAttribFormat; # introduced=21
+ glVertexAttribI4i;
+ glVertexAttribI4iv;
+ glVertexAttribI4ui;
+ glVertexAttribI4uiv;
+ glVertexAttribIFormat; # introduced=21
+ glVertexAttribIPointer;
+ glVertexAttribPointer;
+ glVertexBindingDivisor; # introduced=21
+ glViewport;
+ glWaitSync;
+ local:
+ *;
+};
diff --git a/opengl/tests/angeles/demo.c b/opengl/tests/angeles/demo.c
index 802f398..39d871e 100644
--- a/opengl/tests/angeles/demo.c
+++ b/opengl/tests/angeles/demo.c
@@ -666,7 +666,7 @@
y[2] /= mag;
}
-#define M(row,col) m[col*4+row]
+#define M(row,col) m[(col)*4+(row)]
M(0, 0) = x[0];
M(0, 1) = x[1];
M(0, 2) = x[2];
diff --git a/opengl/tests/hwc/hwcColorEquiv.cpp b/opengl/tests/hwc/hwcColorEquiv.cpp
index f1361b8..a9bbcb6 100644
--- a/opengl/tests/hwc/hwcColorEquiv.cpp
+++ b/opengl/tests/hwc/hwcColorEquiv.cpp
@@ -116,7 +116,7 @@
#define CMD_START_FRAMEWORK "start 2>&1"
// Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
#define MEMCLR(addr, size) do { \
memset((addr), 0, (size)); \
} while (0)
diff --git a/opengl/tests/hwc/hwcCommit.cpp b/opengl/tests/hwc/hwcCommit.cpp
index 6b287e9..3686dab 100644
--- a/opengl/tests/hwc/hwcCommit.cpp
+++ b/opengl/tests/hwc/hwcCommit.cpp
@@ -156,12 +156,12 @@
#define CMD_START_FRAMEWORK "start 2>&1"
// Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
// Local types
class Rectangle {
public:
- Rectangle(uint32_t graphicFormat = defaultFormat,
+ explicit Rectangle(uint32_t graphicFormat = defaultFormat,
HwcTestDim dfDim = HwcTestDim(1, 1),
HwcTestDim sDim = HwcTestDim(1, 1));
void setSourceDim(HwcTestDim dim);
diff --git a/opengl/tests/hwc/hwcRects.cpp b/opengl/tests/hwc/hwcRects.cpp
index 2e2b204..69e56ff 100644
--- a/opengl/tests/hwc/hwcRects.cpp
+++ b/opengl/tests/hwc/hwcRects.cpp
@@ -137,7 +137,7 @@
#define CMD_START_FRAMEWORK "start 2>&1"
// Macros
-#define NUMA(a) (sizeof(a) / sizeof(a [0])) // Num elements in an array
+#define NUMA(a) (sizeof(a) / sizeof((a)[0])) // Num elements in an array
// Local types
class Rectangle {
diff --git a/opengl/tests/hwc/hwcStress.cpp b/opengl/tests/hwc/hwcStress.cpp
index 60c29ef..1469f7c 100644
--- a/opengl/tests/hwc/hwcStress.cpp
+++ b/opengl/tests/hwc/hwcStress.cpp
@@ -162,7 +162,7 @@
#define CMD_STOP_FRAMEWORK "stop 2>&1"
#define CMD_START_FRAMEWORK "start 2>&1"
-#define NUMA(a) (sizeof(a) / sizeof(a [0]))
+#define NUMA(a) (sizeof(a) / sizeof((a)[0]))
#define MEMCLR(addr, size) do { \
memset((addr), 0, (size)); \
} while (0)
diff --git a/opengl/tests/hwc/hwcTestLib.h b/opengl/tests/hwc/hwcTestLib.h
index a942c10..922fc19 100644
--- a/opengl/tests/hwc/hwcTestLib.h
+++ b/opengl/tests/hwc/hwcTestLib.h
@@ -71,7 +71,7 @@
class ColorRGB {
public:
ColorRGB(): _r(0.0), _g(0.0), _b(0.0) {};
- ColorRGB(float f): _r(f), _g(f), _b(f) {}; // Gray
+ ColorRGB(float f): _r(f), _g(f), _b(f) {}; // Gray, NOLINT(implicit)
ColorRGB(float r, float g, float b): _r(r), _g(g), _b(b) {};
float r(void) const { return _r; }
float g(void) const { return _g; }
diff --git a/services/batteryservice/Android.bp b/services/batteryservice/Android.bp
new file mode 100644
index 0000000..79db871
--- /dev/null
+++ b/services/batteryservice/Android.bp
@@ -0,0 +1,22 @@
+cc_library_static {
+ name: "libbatteryservice",
+
+ srcs: [
+ "BatteryProperties.cpp",
+ "BatteryProperty.cpp",
+ "IBatteryPropertiesListener.cpp",
+ "IBatteryPropertiesRegistrar.cpp",
+ ],
+
+ static_libs: [
+ "libutils",
+ "libbinder",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wunused",
+ "-Wunreachable-code",
+ ],
+}
diff --git a/services/batteryservice/Android.mk b/services/batteryservice/Android.mk
deleted file mode 100644
index e4097d7..0000000
--- a/services/batteryservice/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- BatteryProperties.cpp \
- BatteryProperty.cpp \
- IBatteryPropertiesListener.cpp \
- IBatteryPropertiesRegistrar.cpp
-
-LOCAL_STATIC_LIBRARIES := \
- libutils \
- libbinder
-
-LOCAL_MODULE:= libbatteryservice
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/services/batteryservice/IBatteryPropertiesListener.cpp b/services/batteryservice/IBatteryPropertiesListener.cpp
index 8aff26c..7555f4b 100644
--- a/services/batteryservice/IBatteryPropertiesListener.cpp
+++ b/services/batteryservice/IBatteryPropertiesListener.cpp
@@ -24,7 +24,7 @@
class BpBatteryPropertiesListener : public BpInterface<IBatteryPropertiesListener>
{
public:
- BpBatteryPropertiesListener(const sp<IBinder>& impl)
+ explicit BpBatteryPropertiesListener(const sp<IBinder>& impl)
: BpInterface<IBatteryPropertiesListener>(impl)
{
}
diff --git a/services/batteryservice/IBatteryPropertiesRegistrar.cpp b/services/batteryservice/IBatteryPropertiesRegistrar.cpp
index 46934e0..1fdda43 100644
--- a/services/batteryservice/IBatteryPropertiesRegistrar.cpp
+++ b/services/batteryservice/IBatteryPropertiesRegistrar.cpp
@@ -28,7 +28,7 @@
class BpBatteryPropertiesRegistrar : public BpInterface<IBatteryPropertiesRegistrar> {
public:
- BpBatteryPropertiesRegistrar(const sp<IBinder>& impl)
+ explicit BpBatteryPropertiesRegistrar(const sp<IBinder>& impl)
: BpInterface<IBatteryPropertiesRegistrar>(impl) {}
void registerListener(const sp<IBatteryPropertiesListener>& listener) {
diff --git a/services/inputflinger/EventHub.cpp b/services/inputflinger/EventHub.cpp
index 2a53dec..d2f8995 100644
--- a/services/inputflinger/EventHub.cpp
+++ b/services/inputflinger/EventHub.cpp
@@ -55,10 +55,10 @@
* operation with a byte that only has the relevant bit set.
* eg. to check for the 12th bit, we do (array[1] & 1<<4)
*/
-#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
+#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8)))
/* this macro computes the number of bytes needed to represent a bit array of the specified size */
-#define sizeof_bit_array(bits) ((bits + 7) / 8)
+#define sizeof_bit_array(bits) (((bits) + 7) / 8)
#define INDENT " "
#define INDENT2 " "
diff --git a/services/inputflinger/InputDispatcher.h b/services/inputflinger/InputDispatcher.h
index 1c054f5..90c69ce 100644
--- a/services/inputflinger/InputDispatcher.h
+++ b/services/inputflinger/InputDispatcher.h
@@ -455,7 +455,7 @@
};
struct ConfigurationChangedEntry : EventEntry {
- ConfigurationChangedEntry(nsecs_t eventTime);
+ explicit ConfigurationChangedEntry(nsecs_t eventTime);
virtual void appendDescription(String8& msg) const;
protected:
@@ -591,7 +591,7 @@
class Connection;
struct CommandEntry : Link<CommandEntry> {
- CommandEntry(Command command);
+ explicit CommandEntry(Command command);
~CommandEntry();
Command command;
diff --git a/services/inputflinger/InputListener.h b/services/inputflinger/InputListener.h
index 1ec09ce..ea3dd1c 100644
--- a/services/inputflinger/InputListener.h
+++ b/services/inputflinger/InputListener.h
@@ -40,7 +40,7 @@
inline NotifyConfigurationChangedArgs() { }
- NotifyConfigurationChangedArgs(nsecs_t eventTime);
+ explicit NotifyConfigurationChangedArgs(nsecs_t eventTime);
NotifyConfigurationChangedArgs(const NotifyConfigurationChangedArgs& other);
@@ -178,7 +178,7 @@
virtual ~QueuedInputListener();
public:
- QueuedInputListener(const sp<InputListenerInterface>& innerListener);
+ explicit QueuedInputListener(const sp<InputListenerInterface>& innerListener);
virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args);
virtual void notifyKey(const NotifyKeyArgs* args);
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index b9be675..4dec34b 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -6652,6 +6652,7 @@
size_t inCount = mMultiTouchMotionAccumulator.getSlotCount();
size_t outCount = 0;
BitSet32 newPointerIdBits;
+ mHavePointerIds = true;
for (size_t inIndex = 0; inIndex < inCount; inIndex++) {
const MultiTouchMotionAccumulator::Slot* inSlot =
@@ -6696,33 +6697,33 @@
outPointer.isHovering = isHovering;
// Assign pointer id using tracking id if available.
- mHavePointerIds = true;
- int32_t trackingId = inSlot->getTrackingId();
- int32_t id = -1;
- if (trackingId >= 0) {
- for (BitSet32 idBits(mPointerIdBits); !idBits.isEmpty(); ) {
- uint32_t n = idBits.clearFirstMarkedBit();
- if (mPointerTrackingIdMap[n] == trackingId) {
- id = n;
+ if (mHavePointerIds) {
+ int32_t trackingId = inSlot->getTrackingId();
+ int32_t id = -1;
+ if (trackingId >= 0) {
+ for (BitSet32 idBits(mPointerIdBits); !idBits.isEmpty(); ) {
+ uint32_t n = idBits.clearFirstMarkedBit();
+ if (mPointerTrackingIdMap[n] == trackingId) {
+ id = n;
+ }
+ }
+
+ if (id < 0 && !mPointerIdBits.isFull()) {
+ id = mPointerIdBits.markFirstUnmarkedBit();
+ mPointerTrackingIdMap[id] = trackingId;
}
}
-
- if (id < 0 && !mPointerIdBits.isFull()) {
- id = mPointerIdBits.markFirstUnmarkedBit();
- mPointerTrackingIdMap[id] = trackingId;
+ if (id < 0) {
+ mHavePointerIds = false;
+ outState->rawPointerData.clearIdBits();
+ newPointerIdBits.clear();
+ } else {
+ outPointer.id = id;
+ outState->rawPointerData.idToIndex[id] = outCount;
+ outState->rawPointerData.markIdBit(id, isHovering);
+ newPointerIdBits.markBit(id);
}
}
- if (id < 0) {
- mHavePointerIds = false;
- outState->rawPointerData.clearIdBits();
- newPointerIdBits.clear();
- } else {
- outPointer.id = id;
- outState->rawPointerData.idToIndex[id] = outCount;
- outState->rawPointerData.markIdBit(id, isHovering);
- newPointerIdBits.markBit(id);
- }
-
outCount += 1;
}
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index 076f3d6..8e2fe95 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -484,7 +484,7 @@
InputReader* mReader;
public:
- ContextImpl(InputReader* reader);
+ explicit ContextImpl(InputReader* reader);
virtual void updateGlobalMetaState();
virtual int32_t getGlobalMetaState();
@@ -568,7 +568,7 @@
/* Reads raw events from the event hub and processes them, endlessly. */
class InputReaderThread : public Thread {
public:
- InputReaderThread(const sp<InputReaderInterface>& reader);
+ explicit InputReaderThread(const sp<InputReaderInterface>& reader);
virtual ~InputReaderThread();
private:
@@ -1007,7 +1007,7 @@
*/
class InputMapper {
public:
- InputMapper(InputDevice* device);
+ explicit InputMapper(InputDevice* device);
virtual ~InputMapper();
inline InputDevice* getDevice() { return mDevice; }
@@ -1058,7 +1058,7 @@
class SwitchInputMapper : public InputMapper {
public:
- SwitchInputMapper(InputDevice* device);
+ explicit SwitchInputMapper(InputDevice* device);
virtual ~SwitchInputMapper();
virtual uint32_t getSources();
@@ -1078,7 +1078,7 @@
class VibratorInputMapper : public InputMapper {
public:
- VibratorInputMapper(InputDevice* device);
+ explicit VibratorInputMapper(InputDevice* device);
virtual ~VibratorInputMapper();
virtual uint32_t getSources();
@@ -1178,7 +1178,7 @@
class CursorInputMapper : public InputMapper {
public:
- CursorInputMapper(InputDevice* device);
+ explicit CursorInputMapper(InputDevice* device);
virtual ~CursorInputMapper();
virtual uint32_t getSources();
@@ -1243,7 +1243,7 @@
class RotaryEncoderInputMapper : public InputMapper {
public:
- RotaryEncoderInputMapper(InputDevice* device);
+ explicit RotaryEncoderInputMapper(InputDevice* device);
virtual ~RotaryEncoderInputMapper();
virtual uint32_t getSources();
@@ -1264,7 +1264,7 @@
class TouchInputMapper : public InputMapper {
public:
- TouchInputMapper(InputDevice* device);
+ explicit TouchInputMapper(InputDevice* device);
virtual ~TouchInputMapper();
virtual uint32_t getSources();
@@ -1887,7 +1887,7 @@
class SingleTouchInputMapper : public TouchInputMapper {
public:
- SingleTouchInputMapper(InputDevice* device);
+ explicit SingleTouchInputMapper(InputDevice* device);
virtual ~SingleTouchInputMapper();
virtual void reset(nsecs_t when);
@@ -1905,7 +1905,7 @@
class MultiTouchInputMapper : public TouchInputMapper {
public:
- MultiTouchInputMapper(InputDevice* device);
+ explicit MultiTouchInputMapper(InputDevice* device);
virtual ~MultiTouchInputMapper();
virtual void reset(nsecs_t when);
@@ -1926,7 +1926,7 @@
class ExternalStylusInputMapper : public InputMapper {
public:
- ExternalStylusInputMapper(InputDevice* device);
+ explicit ExternalStylusInputMapper(InputDevice* device);
virtual ~ExternalStylusInputMapper() = default;
virtual uint32_t getSources();
@@ -1948,7 +1948,7 @@
class JoystickInputMapper : public InputMapper {
public:
- JoystickInputMapper(InputDevice* device);
+ explicit JoystickInputMapper(InputDevice* device);
virtual ~JoystickInputMapper();
virtual uint32_t getSources();
diff --git a/services/inputflinger/InputWindow.h b/services/inputflinger/InputWindow.h
index e243637..feca6cf 100644
--- a/services/inputflinger/InputWindow.h
+++ b/services/inputflinger/InputWindow.h
@@ -196,7 +196,7 @@
void releaseInfo();
protected:
- InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle);
+ explicit InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle);
virtual ~InputWindowHandle();
InputWindowInfo* mInfo;
diff --git a/services/inputflinger/host/InputDriver.h b/services/inputflinger/host/InputDriver.h
index 8d5a31e..e56673b 100644
--- a/services/inputflinger/host/InputDriver.h
+++ b/services/inputflinger/host/InputDriver.h
@@ -82,7 +82,7 @@
class InputDriver : public InputDriverInterface {
public:
- InputDriver(const char* name);
+ explicit InputDriver(const char* name);
virtual ~InputDriver() = default;
virtual void init() override;
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index a7fe69c..f12320d 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -325,7 +325,7 @@
KeyedVector<int32_t, bool> leds;
Vector<VirtualKeyDefinition> virtualKeys;
- Device(uint32_t classes) :
+ explicit Device(uint32_t classes) :
classes(classes) {
}
};
diff --git a/services/nativeperms/.clang-format b/services/nativeperms/.clang-format
new file mode 100644
index 0000000..6006e6f
--- /dev/null
+++ b/services/nativeperms/.clang-format
@@ -0,0 +1,13 @@
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: true
+AllowShortLoopsOnASingleLine: true
+BinPackArguments: true
+BinPackParameters: true
+ColumnLimit: 80
+CommentPragmas: NOLINT:.*
+ContinuationIndentWidth: 8
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
diff --git a/services/nativeperms/Android.mk b/services/nativeperms/Android.mk
new file mode 100644
index 0000000..34ccd0b
--- /dev/null
+++ b/services/nativeperms/Android.mk
@@ -0,0 +1,31 @@
+# Copyright 2016 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := nativeperms
+LOCAL_SRC_FILES := \
+ nativeperms.cpp \
+ android/os/IPermissionController.aidl
+LOCAL_CFLAGS := -Wall -Werror
+LOCAL_SHARED_LIBRARIES := \
+ libbinder \
+ libbrillo \
+ libbrillo-binder \
+ libchrome \
+ libutils
+LOCAL_INIT_RC := nativeperms.rc
+include $(BUILD_EXECUTABLE)
diff --git a/services/nativeperms/android/os/IPermissionController.aidl b/services/nativeperms/android/os/IPermissionController.aidl
new file mode 100644
index 0000000..89db85c
--- /dev/null
+++ b/services/nativeperms/android/os/IPermissionController.aidl
@@ -0,0 +1,25 @@
+/* //device/java/android/android/os/IPowerManager.aidl
+**
+** Copyright 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.
+*/
+
+package android.os;
+
+/** @hide */
+interface IPermissionController {
+ boolean checkPermission(String permission, int pid, int uid);
+ String[] getPackagesForUid(int uid);
+ boolean isRuntimePermission(String permission);
+}
diff --git a/services/nativeperms/android/os/README b/services/nativeperms/android/os/README
new file mode 100644
index 0000000..e414499
--- /dev/null
+++ b/services/nativeperms/android/os/README
@@ -0,0 +1,4 @@
+IPermissionController.aidl in this directory is a verbatim copy of
+https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/IPermissionController.aidl,
+because some Brillo manifests do not currently include the frameworks/base repo.
+TODO(jorgelo): Figure out a way to use the .aidl file in frameworks/base.
diff --git a/services/nativeperms/nativeperms.cpp b/services/nativeperms/nativeperms.cpp
new file mode 100644
index 0000000..7f03bed
--- /dev/null
+++ b/services/nativeperms/nativeperms.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2016 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.
+ */
+
+#include <base/at_exit.h>
+#include <base/logging.h>
+#include <base/message_loop/message_loop.h>
+#include <binder/IServiceManager.h>
+#include <binder/Status.h>
+#include <brillo/binder_watcher.h>
+#include <brillo/message_loops/base_message_loop.h>
+#include <brillo/syslog_logging.h>
+#include <utils/String16.h>
+
+#include "android/os/BnPermissionController.h"
+
+namespace {
+static android::String16 serviceName("permission");
+}
+
+namespace android {
+
+class PermissionService : public android::os::BnPermissionController {
+ public:
+ ::android::binder::Status checkPermission(
+ const ::android::String16& permission, int32_t pid, int32_t uid,
+ bool* _aidl_return) {
+ (void)permission;
+ (void)pid;
+ (void)uid;
+ *_aidl_return = true;
+ return binder::Status::ok();
+ }
+
+ ::android::binder::Status getPackagesForUid(
+ int32_t uid, ::std::vector<::android::String16>* _aidl_return) {
+ (void)uid;
+ // Brillo doesn't currently have installable packages.
+ if (_aidl_return) {
+ _aidl_return->clear();
+ }
+ return binder::Status::ok();
+ }
+
+ ::android::binder::Status isRuntimePermission(
+ const ::android::String16& permission, bool* _aidl_return) {
+ (void)permission;
+ // Brillo doesn't currently have runtime permissions.
+ *_aidl_return = false;
+ return binder::Status::ok();
+ }
+};
+
+} // namespace android
+
+int main() {
+ base::AtExitManager atExitManager;
+ brillo::InitLog(brillo::kLogToSyslog);
+ // Register the service with servicemanager.
+ android::status_t status = android::defaultServiceManager()->addService(
+ serviceName, new android::PermissionService());
+ CHECK(status == android::OK) << "Failed to get IPermissionController "
+ "binder from servicemanager.";
+
+ // Create a message loop.
+ base::MessageLoopForIO messageLoopForIo;
+ brillo::BaseMessageLoop messageLoop{&messageLoopForIo};
+
+ // Initialize a binder watcher.
+ brillo::BinderWatcher watcher(&messageLoop);
+ watcher.Init();
+
+ // Run the message loop.
+ messageLoop.Run();
+}
diff --git a/services/nativeperms/nativeperms.rc b/services/nativeperms/nativeperms.rc
new file mode 100644
index 0000000..704c0a2
--- /dev/null
+++ b/services/nativeperms/nativeperms.rc
@@ -0,0 +1,4 @@
+service nativeperms /system/bin/nativeperms
+ class main
+ user system
+ group system
diff --git a/services/powermanager/Android.bp b/services/powermanager/Android.bp
new file mode 100644
index 0000000..7b3af70
--- /dev/null
+++ b/services/powermanager/Android.bp
@@ -0,0 +1,17 @@
+cc_library_shared {
+ name: "libpowermanager",
+
+ srcs: ["IPowerManager.cpp"],
+
+ shared_libs: [
+ "libutils",
+ "libbinder",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wunused",
+ "-Wunreachable-code",
+ ],
+}
diff --git a/services/powermanager/Android.mk b/services/powermanager/Android.mk
deleted file mode 100644
index 4deb115..0000000
--- a/services/powermanager/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- IPowerManager.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libbinder
-
-LOCAL_MODULE:= libpowermanager
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
-
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../../include
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/services/powermanager/IPowerManager.cpp b/services/powermanager/IPowerManager.cpp
index bff8719..ea3a831 100644
--- a/services/powermanager/IPowerManager.cpp
+++ b/services/powermanager/IPowerManager.cpp
@@ -30,7 +30,7 @@
class BpPowerManager : public BpInterface<IPowerManager>
{
public:
- BpPowerManager(const sp<IBinder>& impl)
+ explicit BpPowerManager(const sp<IBinder>& impl)
: BpInterface<IPowerManager>(impl)
{
}
diff --git a/services/sensorservice/RecentEventLogger.h b/services/sensorservice/RecentEventLogger.h
index 8b15e5a..bf1f655 100644
--- a/services/sensorservice/RecentEventLogger.h
+++ b/services/sensorservice/RecentEventLogger.h
@@ -35,7 +35,7 @@
// behavior.
class RecentEventLogger : public Dumpable {
public:
- RecentEventLogger(int sensorType);
+ explicit RecentEventLogger(int sensorType);
void addEvent(const sensors_event_t& event);
bool populateLastEvent(sensors_event_t *event) const;
bool isEmpty() const;
@@ -47,7 +47,7 @@
protected:
struct SensorEventLog {
- SensorEventLog(const sensors_event_t& e);
+ explicit SensorEventLog(const sensors_event_t& e);
timespec mWallTime;
sensors_event_t mEvent;
};
diff --git a/services/sensorservice/RingBuffer.h b/services/sensorservice/RingBuffer.h
index ec98a01..a60eb90 100644
--- a/services/sensorservice/RingBuffer.h
+++ b/services/sensorservice/RingBuffer.h
@@ -39,7 +39,7 @@
/**
* Construct a RingBuffer that can grow up to the given length.
*/
- RingBuffer(size_t length);
+ explicit RingBuffer(size_t length);
/**
* Forward iterator to this class. Implements an std:forward_iterator.
diff --git a/services/sensorservice/RotationVectorSensor.h b/services/sensorservice/RotationVectorSensor.h
index 3cc2248..265b4c4 100644
--- a/services/sensorservice/RotationVectorSensor.h
+++ b/services/sensorservice/RotationVectorSensor.h
@@ -34,7 +34,7 @@
class RotationVectorSensor : public VirtualSensor {
public:
- RotationVectorSensor(int mode = FUSION_9AXIS);
+ explicit RotationVectorSensor(int mode = FUSION_9AXIS);
virtual bool process(sensors_event_t* outEvent, const sensors_event_t& event) override;
virtual status_t activate(void* ident, bool enabled) override;
virtual status_t setDelay(void* ident, int handle, int64_t ns) override;
diff --git a/services/sensorservice/SensorEventAckReceiver.h b/services/sensorservice/SensorEventAckReceiver.h
index 998597a..20fa4c7 100644
--- a/services/sensorservice/SensorEventAckReceiver.h
+++ b/services/sensorservice/SensorEventAckReceiver.h
@@ -27,7 +27,7 @@
sp<SensorService> const mService;
public:
virtual bool threadLoop();
- SensorEventAckReceiver(const sp<SensorService>& service)
+ explicit SensorEventAckReceiver(const sp<SensorService>& service)
: mService(service) {
}
};
diff --git a/services/sensorservice/SensorInterface.h b/services/sensorservice/SensorInterface.h
index dafcf2d..0867dc2 100644
--- a/services/sensorservice/SensorInterface.h
+++ b/services/sensorservice/SensorInterface.h
@@ -47,7 +47,7 @@
class BaseSensor : public SensorInterface {
public:
- BaseSensor(const sensor_t& sensor);
+ explicit BaseSensor(const sensor_t& sensor);
BaseSensor(const sensor_t& sensor, const uint8_t (&uuid)[16]);
// Not all sensors need to support batching.
@@ -74,7 +74,7 @@
class HardwareSensor : public BaseSensor {
public:
- HardwareSensor(const sensor_t& sensor);
+ explicit HardwareSensor(const sensor_t& sensor);
HardwareSensor(const sensor_t& sensor, const uint8_t (&uuid)[16]);
virtual ~HardwareSensor();
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 99da2c4..7b47709 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -950,9 +950,11 @@
status_t SensorService::resetToNormalModeLocked() {
SensorDevice& dev(SensorDevice::getInstance());
- dev.enableAllSensors();
status_t err = dev.setMode(NORMAL);
- mCurrentOperatingMode = NORMAL;
+ if (err == NO_ERROR) {
+ mCurrentOperatingMode = NORMAL;
+ dev.enableAllSensors();
+ }
return err;
}
diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h
index 4a63ef0..e969d8a 100644
--- a/services/sensorservice/SensorService.h
+++ b/services/sensorservice/SensorService.h
@@ -49,9 +49,9 @@
#define IGNORE_HARDWARE_FUSION false
#define DEBUG_CONNECTIONS false
// Max size is 100 KB which is enough to accept a batch of about 1000 events.
-#define MAX_SOCKET_BUFFER_SIZE_BATCHED 100 * 1024
+#define MAX_SOCKET_BUFFER_SIZE_BATCHED (100 * 1024)
// For older HALs which don't support batching, use a smaller socket buffer size.
-#define SOCKET_BUFFER_SIZE_NON_BATCHED 4 * 1024
+#define SOCKET_BUFFER_SIZE_NON_BATCHED (4 * 1024)
#define SENSOR_REGISTRATIONS_BUF_SIZE 200
diff --git a/services/sensorservice/mat.h b/services/sensorservice/mat.h
index a76fc91..495c14e 100644
--- a/services/sensorservice/mat.h
+++ b/services/sensorservice/mat.h
@@ -139,13 +139,13 @@
mat() { }
mat(const mat& rhs) : base(rhs) { }
- mat(const base& rhs) : base(rhs) { }
+ mat(const base& rhs) : base(rhs) { } // NOLINT(implicit)
// -----------------------------------------------------------------------
// conversion constructors
// sets the diagonal to the value, off-diagonal to zero
- mat(pTYPE rhs) {
+ mat(pTYPE rhs) { // NOLINT(implicit)
helpers::doAssign(*this, rhs);
}
@@ -220,7 +220,7 @@
template<size_t PREV_COLUMN>
struct column_builder {
mat& matrix;
- column_builder(mat& matrix) : matrix(matrix) { }
+ explicit column_builder(mat& matrix) : matrix(matrix) { }
};
// operator << is not a method of column_builder<> so we can
@@ -265,9 +265,9 @@
enum { ROWS = R, COLS = 1 };
mat() { }
- mat(const base& rhs) : base(rhs) { }
+ explicit mat(const base& rhs) : base(rhs) { }
mat(const mat& rhs) : base(rhs) { }
- mat(const TYPE& rhs) { helpers::doAssign(*this, rhs); }
+ explicit mat(const TYPE& rhs) { helpers::doAssign(*this, rhs); }
mat& operator=(const mat& rhs) { base::operator=(rhs); return *this; }
mat& operator=(const base& rhs) { base::operator=(rhs); return *this; }
mat& operator=(const TYPE& rhs) { return helpers::doAssign(*this, rhs); }
diff --git a/services/sensorservice/vec.h b/services/sensorservice/vec.h
index a142bad..9e5d280 100644
--- a/services/sensorservice/vec.h
+++ b/services/sensorservice/vec.h
@@ -322,12 +322,12 @@
vec() { }
vec(const vec& rhs) : base(rhs) { }
- vec(const base& rhs) : base(rhs) { }
+ vec(const base& rhs) : base(rhs) { } // NOLINT(implicit)
// -----------------------------------------------------------------------
// conversion constructors
- vec(pTYPE rhs) {
+ vec(pTYPE rhs) { // NOLINT(implicit)
for (size_t i=0 ; i<SIZE ; i++)
base::operator[](i) = rhs;
}
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index ffda035..170faa8 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -124,7 +124,6 @@
endif
LOCAL_CFLAGS += -fvisibility=hidden -Werror=format
-LOCAL_CFLAGS += -std=c++14
LOCAL_STATIC_LIBRARIES := libvkjson
LOCAL_SHARED_LIBRARIES := \
@@ -154,9 +153,9 @@
LOCAL_CLANG := true
-LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic
+LOCAL_LDFLAGS_32 := -Wl,--version-script,art/sigchainlib/version-script32.txt -Wl,--export-dynamic
+LOCAL_LDFLAGS_64 := -Wl,--version-script,art/sigchainlib/version-script64.txt -Wl,--export-dynamic
LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\"
-LOCAL_CPPFLAGS := -std=c++14
LOCAL_INIT_RC := surfaceflinger.rc
@@ -199,7 +198,6 @@
LOCAL_CLANG := true
LOCAL_CFLAGS := -DLOG_TAG=\"SurfaceFlinger\"
-LOCAL_CPPFLAGS := -std=c++14
LOCAL_SRC_FILES := \
DdmConnection.cpp
diff --git a/services/surfaceflinger/Client.h b/services/surfaceflinger/Client.h
index 12db505..9c7d050 100644
--- a/services/surfaceflinger/Client.h
+++ b/services/surfaceflinger/Client.h
@@ -38,7 +38,7 @@
class Client : public BnSurfaceComposerClient
{
public:
- Client(const sp<SurfaceFlinger>& flinger);
+ explicit Client(const sp<SurfaceFlinger>& flinger);
~Client();
status_t initCheck() const;
diff --git a/services/surfaceflinger/Colorizer.h b/services/surfaceflinger/Colorizer.h
index 6524481..f2e6491 100644
--- a/services/surfaceflinger/Colorizer.h
+++ b/services/surfaceflinger/Colorizer.h
@@ -34,7 +34,7 @@
WHITE = 37
};
- Colorizer(bool enabled)
+ explicit Colorizer(bool enabled)
: mEnabled(enabled) {
}
diff --git a/services/surfaceflinger/DispSync.h b/services/surfaceflinger/DispSync.h
index 537c81b..2763e59 100644
--- a/services/surfaceflinger/DispSync.h
+++ b/services/surfaceflinger/DispSync.h
@@ -61,7 +61,7 @@
virtual void onDispSyncEvent(nsecs_t when) = 0;
};
- DispSync(const char* name);
+ explicit DispSync(const char* name);
~DispSync();
// reset clears the resync samples and error value.
diff --git a/services/surfaceflinger/DisplayHardware/FloatRect.h b/services/surfaceflinger/DisplayHardware/FloatRect.h
index 9ad1040..151eaaa 100644
--- a/services/surfaceflinger/DisplayHardware/FloatRect.h
+++ b/services/surfaceflinger/DisplayHardware/FloatRect.h
@@ -32,7 +32,7 @@
inline FloatRect()
: left(0), top(0), right(0), bottom(0) { }
- inline FloatRect(const Rect& other)
+ inline FloatRect(const Rect& other) // NOLINT(implicit)
: left(other.left), top(other.top), right(other.right), bottom(other.bottom) { }
inline float getWidth() const { return right - left; }
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
index 7368d77..18c7945 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.cpp
@@ -240,7 +240,7 @@
#endif
void FramebufferSurface::dumpAsString(String8& result) const {
- ConsumerBase::dump(result);
+ ConsumerBase::dumpState(result);
}
void FramebufferSurface::dumpLocked(String8& result, const char* prefix) const
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index fb04af8..32a9de0 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -57,7 +57,7 @@
class Device
{
public:
- Device(hwc2_device_t* device);
+ explicit Device(hwc2_device_t* device);
~Device();
friend class HWC2::Display;
diff --git a/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h b/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
index bdacc73..962361e 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.h
@@ -43,7 +43,7 @@
class HWC2On1Adapter : public hwc2_device_t
{
public:
- HWC2On1Adapter(struct hwc_composer_device_1* hwc1Device);
+ explicit HWC2On1Adapter(struct hwc_composer_device_1* hwc1Device);
~HWC2On1Adapter();
struct hwc_composer_device_1* getHwc1Device() const { return mHwc1Device; }
@@ -495,7 +495,7 @@
class Layer {
public:
- Layer(Display& display);
+ explicit Layer(Display& display);
bool operator==(const Layer& other) { return mId == other.mId; }
bool operator!=(const Layer& other) { return !(*this == other); }
diff --git a/services/surfaceflinger/EventControlThread.h b/services/surfaceflinger/EventControlThread.h
index be6c53a..9368db6 100644
--- a/services/surfaceflinger/EventControlThread.h
+++ b/services/surfaceflinger/EventControlThread.h
@@ -29,7 +29,7 @@
class EventControlThread: public Thread {
public:
- EventControlThread(const sp<SurfaceFlinger>& flinger);
+ explicit EventControlThread(const sp<SurfaceFlinger>& flinger);
virtual ~EventControlThread() {}
void setVsyncEnabled(bool enabled);
diff --git a/services/surfaceflinger/EventLog/EventLog.h b/services/surfaceflinger/EventLog/EventLog.h
index 5207514..efc5d70 100644
--- a/services/surfaceflinger/EventLog/EventLog.h
+++ b/services/surfaceflinger/EventLog/EventLog.h
@@ -52,7 +52,7 @@
bool mOverflow;
char mStorage[STORAGE_MAX_SIZE];
public:
- TagBuffer(int32_t tag);
+ explicit TagBuffer(int32_t tag);
// starts list of items
void startList(int8_t count);
diff --git a/services/surfaceflinger/EventThread.h b/services/surfaceflinger/EventThread.h
index 34654fa..b635115 100644
--- a/services/surfaceflinger/EventThread.h
+++ b/services/surfaceflinger/EventThread.h
@@ -57,7 +57,7 @@
class EventThread : public Thread, private VSyncSource::Callback {
class Connection : public BnDisplayEventConnection {
public:
- Connection(const sp<EventThread>& eventThread);
+ explicit Connection(const sp<EventThread>& eventThread);
status_t postEvent(const DisplayEventReceiver::Event& event);
// count >= 1 : continuous event. count is the vsync rate
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 3ffa655..1b90678 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -163,9 +163,7 @@
mSurfaceFlingerConsumer->setContentsChangedListener(this);
mSurfaceFlingerConsumer->setName(mName);
-#ifdef TARGET_DISABLE_TRIPLE_BUFFERING
-#warning "disabling triple buffering"
-#else
+#ifndef TARGET_DISABLE_TRIPLE_BUFFERING
mProducer->setMaxDequeuedBufferCount(2);
#endif
@@ -2238,7 +2236,7 @@
mQueuedFrames, mRefreshPending);
if (mSurfaceFlingerConsumer != 0) {
- mSurfaceFlingerConsumer->dump(result, " ");
+ mSurfaceFlingerConsumer->dumpState(result, " ");
}
}
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 2ce1340..24de87e 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -477,7 +477,7 @@
class SyncPoint
{
public:
- SyncPoint(uint64_t frameNumber) : mFrameNumber(frameNumber),
+ explicit SyncPoint(uint64_t frameNumber) : mFrameNumber(frameNumber),
mFrameIsAvailable(false), mTransactionIsApplied(false) {}
uint64_t getFrameNumber() const {
diff --git a/services/surfaceflinger/MessageQueue.h b/services/surfaceflinger/MessageQueue.h
index 1004f4c..aed0aa9 100644
--- a/services/surfaceflinger/MessageQueue.h
+++ b/services/surfaceflinger/MessageQueue.h
@@ -69,7 +69,7 @@
MessageQueue& mQueue;
int32_t mEventMask;
public:
- Handler(MessageQueue& queue) : mQueue(queue), mEventMask(0) { }
+ explicit Handler(MessageQueue& queue) : mQueue(queue), mEventMask(0) { }
virtual void handleMessage(const Message& message);
void dispatchRefresh();
void dispatchInvalidate();
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 8db071e..b4538b3 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -656,6 +656,10 @@
}
int SurfaceFlinger::getActiveConfig(const sp<IBinder>& display) {
+ if (display == NULL) {
+ ALOGE("%s : display is NULL", __func__);
+ return BAD_VALUE;
+ }
sp<DisplayDevice> device(getDisplayDevice(display));
if (device != NULL) {
return device->getActiveConfig();
diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.cpp b/services/surfaceflinger/SurfaceFlingerConsumer.cpp
index e0e4c61..6f2520b 100644
--- a/services/surfaceflinger/SurfaceFlingerConsumer.cpp
+++ b/services/surfaceflinger/SurfaceFlingerConsumer.cpp
@@ -70,6 +70,14 @@
return err;
}
+ if (autoRefresh) {
+ *autoRefresh = item.mAutoRefresh;
+ }
+
+ if (queuedBuffer) {
+ *queuedBuffer = item.mQueuedBuffer;
+ }
+
// We call the rejecter here, in case the caller has a reason to
// not accept this buffer. This is used by SurfaceFlinger to
// reject buffers which have the wrong size
@@ -79,14 +87,6 @@
return BUFFER_REJECTED;
}
- if (autoRefresh) {
- *autoRefresh = item.mAutoRefresh;
- }
-
- if (queuedBuffer) {
- *queuedBuffer = item.mQueuedBuffer;
- }
-
// Release the previous buffer.
#ifdef USE_HWC2
err = updateAndReleaseLocked(item, &mPendingRelease);
diff --git a/vulkan/Android.bp b/vulkan/Android.bp
new file mode 100644
index 0000000..ba3cf79
--- /dev/null
+++ b/vulkan/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2016 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.
+
+ndk_headers {
+ name: "libvulkan_headers",
+ from: "include",
+ to: "",
+ srcs: ["include/vulkan/**/*.h"],
+ license: "include/vulkan/NOTICE",
+}
+
+cc_library_static {
+ name: "vulkan_headers",
+ export_include_dirs: ["include"],
+}
+
+subdirs = [
+ "nulldrv",
+ "libvulkan",
+ "tools",
+]
diff --git a/vulkan/Android.mk b/vulkan/Android.mk
deleted file mode 100644
index d125673..0000000
--- a/vulkan/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(call all-named-subdir-makefiles, libvulkan nulldrv tools)
diff --git a/vulkan/include/vulkan/NOTICE b/vulkan/include/vulkan/NOTICE
new file mode 100644
index 0000000..c958fba
--- /dev/null
+++ b/vulkan/include/vulkan/NOTICE
@@ -0,0 +1,13 @@
+Copyright (c) 2015-2016 The Khronos Group Inc.
+
+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.
diff --git a/vulkan/libvulkan/Android.bp b/vulkan/libvulkan/Android.bp
new file mode 100644
index 0000000..34697d1
--- /dev/null
+++ b/vulkan/libvulkan/Android.bp
@@ -0,0 +1,79 @@
+// Copyright (C) 2016 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.
+
+// Headers module is in frameworks/native/vulkan/Android.bp.
+ndk_library {
+ name: "libvulkan.ndk",
+ symbol_file: "libvulkan.map.txt",
+ first_version: "24",
+}
+
+cc_library_shared {
+ name: "libvulkan",
+ clang: true,
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+
+ cflags: [
+ "-DLOG_TAG=\"vulkan\"",
+ "-DVK_USE_PLATFORM_ANDROID_KHR",
+ "-DVK_NO_PROTOTYPES",
+ "-fvisibility=hidden",
+ "-fstrict-aliasing",
+ "-Weverything",
+ "-Werror",
+ "-Wno-padded",
+ "-Wno-switch-enum",
+ "-Wno-undef",
+
+ //"-DLOG_NDEBUG=0",
+ ],
+
+ cppflags: [
+ "-std=c++14",
+ "-Wno-c99-extensions",
+ "-Wno-c++98-compat-pedantic",
+ "-Wno-exit-time-destructors",
+ "-Wno-global-constructors",
+ "-Wno-zero-length-array",
+ ],
+
+ srcs: [
+ "api.cpp",
+ "api_gen.cpp",
+ "debug_report.cpp",
+ "driver.cpp",
+ "driver_gen.cpp",
+ "layers_extensions.cpp",
+ "stubhal.cpp",
+ "swapchain.cpp",
+ "vulkan_loader_data.cpp",
+ ],
+
+ export_static_lib_headers: ["vulkan_headers"],
+ static_libs: [
+ "vulkan_headers",
+ "libziparchive",
+ ],
+ shared_libs: [
+ "libhardware",
+ "libsync",
+ "libbase",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "libz",
+ ],
+}
diff --git a/vulkan/libvulkan/Android.mk b/vulkan/libvulkan/Android.mk
deleted file mode 100644
index d2e28ff..0000000
--- a/vulkan/libvulkan/Android.mk
+++ /dev/null
@@ -1,57 +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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CLANG := true
-LOCAL_SANITIZE := integer
-
-LOCAL_CFLAGS := -DLOG_TAG=\"vulkan\" \
- -DVK_USE_PLATFORM_ANDROID_KHR \
- -DVK_NO_PROTOTYPES \
- -std=c99 -fvisibility=hidden -fstrict-aliasing \
- -Weverything -Werror \
- -Wno-padded \
- -Wno-switch-enum \
- -Wno-undef
-#LOCAL_CFLAGS += -DLOG_NDEBUG=0
-LOCAL_CPPFLAGS := -std=c++14 \
- -Wno-c99-extensions \
- -Wno-c++98-compat-pedantic \
- -Wno-exit-time-destructors \
- -Wno-global-constructors \
- -Wno-zero-length-array
-
-LOCAL_C_INCLUDES := \
- frameworks/native/vulkan/include \
- system/core/libsync/include
-
-LOCAL_SRC_FILES := \
- api.cpp \
- api_gen.cpp \
- debug_report.cpp \
- driver.cpp \
- driver_gen.cpp \
- layers_extensions.cpp \
- stubhal.cpp \
- swapchain.cpp \
- vulkan_loader_data.cpp
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_STATIC_LIBRARIES := libziparchive
-LOCAL_SHARED_LIBRARIES := libhardware libsync libbase liblog libutils libcutils libz
-
-LOCAL_MODULE := libvulkan
-include $(BUILD_SHARED_LIBRARY)
diff --git a/vulkan/libvulkan/debug_report.h b/vulkan/libvulkan/debug_report.h
index be9b645..3d8bd50 100644
--- a/vulkan/libvulkan/debug_report.h
+++ b/vulkan/libvulkan/debug_report.h
@@ -85,9 +85,9 @@
class DebugReportLogger {
public:
- DebugReportLogger(const VkInstanceCreateInfo& info)
+ explicit DebugReportLogger(const VkInstanceCreateInfo& info)
: instance_pnext_(info.pNext), callbacks_(nullptr) {}
- DebugReportLogger(const DebugReportCallbackList& callbacks)
+ explicit DebugReportLogger(const DebugReportCallbackList& callbacks)
: instance_pnext_(nullptr), callbacks_(&callbacks) {}
void Message(VkDebugReportFlagsEXT flags,
diff --git a/vulkan/libvulkan/driver.h b/vulkan/libvulkan/driver.h
index a02ebd7..a1612c7 100644
--- a/vulkan/libvulkan/driver.h
+++ b/vulkan/libvulkan/driver.h
@@ -61,7 +61,7 @@
VK_DEFINE_HANDLE(DeviceDispatchable)
struct InstanceData {
- InstanceData(const VkAllocationCallbacks& alloc)
+ explicit InstanceData(const VkAllocationCallbacks& alloc)
: opaque_api_data(),
allocator(alloc),
driver(),
diff --git a/vulkan/libvulkan/layers_extensions.h b/vulkan/libvulkan/layers_extensions.h
index 79fe59d..07ac1a3 100644
--- a/vulkan/libvulkan/layers_extensions.h
+++ b/vulkan/libvulkan/layers_extensions.h
@@ -26,7 +26,7 @@
class LayerRef {
public:
- LayerRef(const Layer* layer);
+ explicit LayerRef(const Layer* layer);
LayerRef(LayerRef&& other);
~LayerRef();
LayerRef(const LayerRef&) = delete;
diff --git a/vulkan/libvulkan/libvulkan.map.txt b/vulkan/libvulkan/libvulkan.map.txt
new file mode 100644
index 0000000..1745925
--- /dev/null
+++ b/vulkan/libvulkan/libvulkan.map.txt
@@ -0,0 +1,153 @@
+LIBVULKAN {
+ global:
+ vkAcquireNextImageKHR;
+ vkAllocateCommandBuffers;
+ vkAllocateDescriptorSets;
+ vkAllocateMemory;
+ vkBeginCommandBuffer;
+ vkBindBufferMemory;
+ vkBindImageMemory;
+ vkCmdBeginQuery;
+ vkCmdBeginRenderPass;
+ vkCmdBindDescriptorSets;
+ vkCmdBindIndexBuffer;
+ vkCmdBindPipeline;
+ vkCmdBindVertexBuffers;
+ vkCmdBlitImage;
+ vkCmdClearAttachments;
+ vkCmdClearColorImage;
+ vkCmdClearDepthStencilImage;
+ vkCmdCopyBuffer;
+ vkCmdCopyBufferToImage;
+ vkCmdCopyImage;
+ vkCmdCopyImageToBuffer;
+ vkCmdCopyQueryPoolResults;
+ vkCmdDispatch;
+ vkCmdDispatchIndirect;
+ vkCmdDraw;
+ vkCmdDrawIndexed;
+ vkCmdDrawIndexedIndirect;
+ vkCmdDrawIndirect;
+ vkCmdEndQuery;
+ vkCmdEndRenderPass;
+ vkCmdExecuteCommands;
+ vkCmdFillBuffer;
+ vkCmdNextSubpass;
+ vkCmdPipelineBarrier;
+ vkCmdPushConstants;
+ vkCmdResetEvent;
+ vkCmdResetQueryPool;
+ vkCmdResolveImage;
+ vkCmdSetBlendConstants;
+ vkCmdSetDepthBias;
+ vkCmdSetDepthBounds;
+ vkCmdSetEvent;
+ vkCmdSetLineWidth;
+ vkCmdSetScissor;
+ vkCmdSetStencilCompareMask;
+ vkCmdSetStencilReference;
+ vkCmdSetStencilWriteMask;
+ vkCmdSetViewport;
+ vkCmdUpdateBuffer;
+ vkCmdWaitEvents;
+ vkCmdWriteTimestamp;
+ vkCreateAndroidSurfaceKHR;
+ vkCreateBuffer;
+ vkCreateBufferView;
+ vkCreateCommandPool;
+ vkCreateComputePipelines;
+ vkCreateDescriptorPool;
+ vkCreateDescriptorSetLayout;
+ vkCreateDevice;
+ vkCreateEvent;
+ vkCreateFence;
+ vkCreateFramebuffer;
+ vkCreateGraphicsPipelines;
+ vkCreateImage;
+ vkCreateImageView;
+ vkCreateInstance;
+ vkCreatePipelineCache;
+ vkCreatePipelineLayout;
+ vkCreateQueryPool;
+ vkCreateRenderPass;
+ vkCreateSampler;
+ vkCreateSemaphore;
+ vkCreateShaderModule;
+ vkCreateSwapchainKHR;
+ vkDestroyBuffer;
+ vkDestroyBufferView;
+ vkDestroyCommandPool;
+ vkDestroyDescriptorPool;
+ vkDestroyDescriptorSetLayout;
+ vkDestroyDevice;
+ vkDestroyEvent;
+ vkDestroyFence;
+ vkDestroyFramebuffer;
+ vkDestroyImage;
+ vkDestroyImageView;
+ vkDestroyInstance;
+ vkDestroyPipeline;
+ vkDestroyPipelineCache;
+ vkDestroyPipelineLayout;
+ vkDestroyQueryPool;
+ vkDestroyRenderPass;
+ vkDestroySampler;
+ vkDestroySemaphore;
+ vkDestroyShaderModule;
+ vkDestroySurfaceKHR;
+ vkDestroySwapchainKHR;
+ vkDeviceWaitIdle;
+ vkEndCommandBuffer;
+ vkEnumerateDeviceExtensionProperties;
+ vkEnumerateDeviceLayerProperties;
+ vkEnumerateInstanceExtensionProperties;
+ vkEnumerateInstanceLayerProperties;
+ vkEnumeratePhysicalDevices;
+ vkFlushMappedMemoryRanges;
+ vkFreeCommandBuffers;
+ vkFreeDescriptorSets;
+ vkFreeMemory;
+ vkGetBufferMemoryRequirements;
+ vkGetDeviceMemoryCommitment;
+ vkGetDeviceProcAddr;
+ vkGetDeviceQueue;
+ vkGetEventStatus;
+ vkGetFenceStatus;
+ vkGetImageMemoryRequirements;
+ vkGetImageSparseMemoryRequirements;
+ vkGetImageSubresourceLayout;
+ vkGetInstanceProcAddr;
+ vkGetPhysicalDeviceFeatures;
+ vkGetPhysicalDeviceFormatProperties;
+ vkGetPhysicalDeviceImageFormatProperties;
+ vkGetPhysicalDeviceMemoryProperties;
+ vkGetPhysicalDeviceProperties;
+ vkGetPhysicalDeviceQueueFamilyProperties;
+ vkGetPhysicalDeviceSparseImageFormatProperties;
+ vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
+ vkGetPhysicalDeviceSurfaceFormatsKHR;
+ vkGetPhysicalDeviceSurfacePresentModesKHR;
+ vkGetPhysicalDeviceSurfaceSupportKHR;
+ vkGetPipelineCacheData;
+ vkGetQueryPoolResults;
+ vkGetRenderAreaGranularity;
+ vkGetSwapchainImagesKHR;
+ vkInvalidateMappedMemoryRanges;
+ vkMapMemory;
+ vkMergePipelineCaches;
+ vkQueueBindSparse;
+ vkQueuePresentKHR;
+ vkQueueSubmit;
+ vkQueueWaitIdle;
+ vkResetCommandBuffer;
+ vkResetCommandPool;
+ vkResetDescriptorPool;
+ vkResetEvent;
+ vkResetFences;
+ vkSetEvent;
+ vkUnmapMemory;
+ vkUpdateDescriptorSets;
+ vkWaitForFences;
+ local:
+ *;
+};
diff --git a/vulkan/libvulkan/stubhal.cpp b/vulkan/libvulkan/stubhal.cpp
index a74d370..869317b 100644
--- a/vulkan/libvulkan/stubhal.cpp
+++ b/vulkan/libvulkan/stubhal.cpp
@@ -43,7 +43,7 @@
static std::bitset<kMaxInstances> g_instance_used(false);
static std::array<hwvulkan_dispatch_t, kMaxInstances> g_instances;
-[[noreturn]] void NoOp() {
+[[noreturn]] VKAPI_ATTR void NoOp() {
LOG_ALWAYS_FATAL("invalid stub function called");
}
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index adc7d5c..63c597c 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -361,9 +361,11 @@
if (formats) {
if (*count < kNumFormats)
result = VK_INCOMPLETE;
- std::copy(kFormats, kFormats + std::min(*count, kNumFormats), formats);
+ *count = std::min(*count, kNumFormats);
+ std::copy(kFormats, kFormats + *count, formats);
+ } else {
+ *count = kNumFormats;
}
- *count = kNumFormats;
return result;
}
@@ -381,9 +383,11 @@
if (modes) {
if (*count < kNumModes)
result = VK_INCOMPLETE;
- std::copy(kModes, kModes + std::min(*count, kNumModes), modes);
+ *count = std::min(*count, kNumModes);
+ std::copy(kModes, kModes + *count, modes);
+ } else {
+ *count = kNumModes;
}
- *count = kNumModes;
return result;
}
@@ -751,8 +755,10 @@
}
for (uint32_t i = 0; i < n; i++)
images[i] = swapchain.images[i].image;
+ *count = n;
+ } else {
+ *count = swapchain.num_images;
}
- *count = swapchain.num_images;
return result;
}
diff --git a/vulkan/nulldrv/Android.bp b/vulkan/nulldrv/Android.bp
new file mode 100644
index 0000000..ea3b781
--- /dev/null
+++ b/vulkan/nulldrv/Android.bp
@@ -0,0 +1,47 @@
+// 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.
+
+cc_library_shared {
+ // Real drivers would set this to vulkan.$(TARGET_BOARD_PLATFORM)
+ name: "vulkan.default",
+ proprietary: true,
+ relative_install_path: "hw",
+
+ clang: true,
+ cflags: [
+ "-fvisibility=hidden",
+ "-fstrict-aliasing",
+ "-DLOG_TAG=\"vknulldrv\"",
+ "-Weverything",
+ "-Werror",
+ "-Wno-padded",
+ "-Wno-undef",
+ "-Wno-zero-length-array",
+
+ "-DLOG_NDEBUG=0",
+ ],
+ cppflags: [
+ "-std=c++1y",
+ "-Wno-c++98-compat-pedantic",
+ "-Wno-c99-extensions",
+ ],
+
+ srcs: [
+ "null_driver.cpp",
+ "null_driver_gen.cpp",
+ ],
+
+ static_libs: ["vulkan_headers"],
+ shared_libs: ["liblog"],
+}
diff --git a/vulkan/nulldrv/Android.mk b/vulkan/nulldrv/Android.mk
deleted file mode 100644
index 77d4746..0000000
--- a/vulkan/nulldrv/Android.mk
+++ /dev/null
@@ -1,45 +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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CLANG := true
-LOCAL_CFLAGS := -std=c99 -fvisibility=hidden -fstrict-aliasing \
- -DLOG_TAG=\"vknulldrv\" \
- -Weverything -Werror \
- -Wno-padded \
- -Wno-undef \
- -Wno-zero-length-array
-#LOCAL_CFLAGS += -DLOG_NDEBUG=0
-LOCAL_CPPFLAGS := -std=c++1y \
- -Wno-c++98-compat-pedantic \
- -Wno-c99-extensions
-
-LOCAL_C_INCLUDES := \
- frameworks/native/vulkan/include
-
-LOCAL_SRC_FILES := \
- null_driver.cpp \
- null_driver_gen.cpp
-
-LOCAL_SHARED_LIBRARIES := liblog
-
-# Real drivers would set this to vulkan.$(TARGET_BOARD_PLATFORM)
-LOCAL_MODULE := vulkan.default
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/vulkan/tools/Android.bp b/vulkan/tools/Android.bp
new file mode 100644
index 0000000..d81d9ec
--- /dev/null
+++ b/vulkan/tools/Android.bp
@@ -0,0 +1,44 @@
+// 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.
+
+cc_binary {
+ name: "vkinfo",
+
+ clang: true,
+ cflags: [
+ "-fvisibility=hidden",
+ "-fstrict-aliasing",
+
+ "-DLOG_TAG=\"vkinfo\"",
+
+ "-Weverything",
+ "-Werror",
+ "-Wno-padded",
+ "-Wno-undef",
+ "-Wno-switch-enum",
+ ],
+ cppflags: [
+ "-std=c++1y",
+ "-Wno-c++98-compat-pedantic",
+ "-Wno-c99-extensions",
+ "-Wno-old-style-cast",
+ ],
+
+ srcs: ["vkinfo.cpp"],
+
+ shared_libs: [
+ "libvulkan",
+ "liblog",
+ ],
+}
diff --git a/vulkan/tools/Android.mk b/vulkan/tools/Android.mk
deleted file mode 100644
index 337e683..0000000
--- a/vulkan/tools/Android.mk
+++ /dev/null
@@ -1,38 +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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CLANG := true
-LOCAL_CFLAGS := -std=c99 -fvisibility=hidden -fstrict-aliasing
-LOCAL_CFLAGS += -DLOG_TAG=\"vkinfo\"
-LOCAL_CFLAGS += -Weverything -Werror -Wno-padded -Wno-undef -Wno-switch-enum
-LOCAL_CPPFLAGS := -std=c++1y \
- -Wno-c++98-compat-pedantic \
- -Wno-c99-extensions \
- -Wno-old-style-cast
-
-LOCAL_C_INCLUDES := \
- frameworks/native/vulkan/include
-
-LOCAL_SRC_FILES := vkinfo.cpp
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_SHARED_LIBRARIES := libvulkan liblog
-
-LOCAL_MODULE := vkinfo
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_EXECUTABLE)