diff options
| -rw-r--r-- | cmds/dumpstate/Android.mk | 2 | ||||
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 65 | ||||
| -rw-r--r-- | cmds/dumpstate/dumpstate.h | 3 | ||||
| -rw-r--r-- | cmds/dumpstate/utils.cpp | 10 | ||||
| -rw-r--r-- | data/etc/android.hardware.sensor.heartrate.fitness.xml | 20 | ||||
| -rw-r--r-- | data/etc/handheld_core_hardware.xml | 4 | ||||
| -rw-r--r-- | include/binder/Parcel.h | 8 | ||||
| -rw-r--r-- | include/ui/Fence.h | 18 | ||||
| -rw-r--r-- | libs/binder/IServiceManager.cpp | 6 | ||||
| -rw-r--r-- | libs/binder/Parcel.cpp | 4 | ||||
| -rw-r--r-- | libs/gui/BufferQueueConsumer.cpp | 1 | ||||
| -rw-r--r-- | libs/gui/BufferQueueCore.cpp | 1 | ||||
| -rw-r--r-- | libs/gui/BufferQueueProducer.cpp | 1 | ||||
| -rw-r--r-- | libs/gui/ConsumerBase.cpp | 12 | ||||
| -rw-r--r-- | libs/gui/SensorManager.cpp | 3 | ||||
| -rw-r--r-- | libs/ui/Gralloc1On0Adapter.cpp | 3 |
16 files changed, 100 insertions, 61 deletions
diff --git a/cmds/dumpstate/Android.mk b/cmds/dumpstate/Android.mk index daeebc41e6..a3522596c0 100644 --- a/cmds/dumpstate/Android.mk +++ b/cmds/dumpstate/Android.mk @@ -10,7 +10,7 @@ LOCAL_SRC_FILES := dumpstate.cpp utils.cpp LOCAL_MODULE := dumpstate -LOCAL_SHARED_LIBRARIES := libcutils libdebuggerd_client liblog libselinux libbase libhardware_legacy +LOCAL_SHARED_LIBRARIES := libcutils libdebuggerd_client liblog libselinux libbase # ZipArchive support, the order matters here to get all symbols. LOCAL_STATIC_LIBRARIES := libziparchive libz libcrypto_static LOCAL_HAL_STATIC_LIBRARIES := libdumpstate diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 5b01be1274..44cc499bb2 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -23,7 +23,6 @@ #include <memory> #include <regex> #include <set> -#include <signal.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -40,7 +39,6 @@ #include <android-base/unique_fd.h> #include <android-base/file.h> #include <cutils/properties.h> -#include <hardware_legacy/power.h> #include <private/android_filesystem_config.h> #include <private/android_logger.h> @@ -83,7 +81,6 @@ static std::string suffix; #define TOMBSTONE_MAX_LEN (sizeof(TOMBSTONE_FILE_PREFIX) + 4) #define NUM_TOMBSTONES 10 #define WLUTIL "/vendor/xbin/wlutil" -#define WAKE_LOCK_NAME "dumpstate_wakelock" typedef struct { char name[TOMBSTONE_MAX_LEN]; @@ -152,7 +149,7 @@ void do_mountinfo(int pid, const char *name) { } void add_mountinfo() { - if (!zip_writer) return; + if (!is_zipping()) return; const char *title = "MOUNT INFO"; mount_points.clear(); DurationReporter duration_reporter(title, NULL); @@ -313,8 +310,8 @@ static bool dump_anrd_trace() { } static void dump_systrace() { - if (!zip_writer) { - MYLOGD("Not dumping systrace because zip_writer is not set\n"); + if (!is_zipping()) { + MYLOGD("Not dumping systrace because dumpstate is not zipping\n"); return; } std::string systrace_path = bugreport_dir + "/systrace-" + suffix + ".txt"; @@ -370,7 +367,7 @@ static void dump_raft() { return; } - if (!zip_writer) { + if (!is_zipping()) { // Write compressed and encoded raft logs to stdout if not zip_writer. run_command("RAFT LOGS", 600, "logcompressor", "-r", RAFT_DIR, NULL); return; @@ -620,8 +617,8 @@ static const std::set<std::string> PROBLEMATIC_FILE_EXTENSIONS = { }; bool add_zip_entry_from_fd(const std::string& entry_name, int fd) { - if (!zip_writer) { - MYLOGD("Not adding zip entry %s from fd because zip_writer is not set\n", + if (!is_zipping()) { + MYLOGD("Not adding entry %s from fd because dumpstate is not zipping\n", entry_name.c_str()); return false; } @@ -691,8 +688,8 @@ static int _add_file_from_fd(const char *title, const char *path, int fd) { // TODO: move to util.cpp void add_dir(const char *dir, bool recursive) { - if (!zip_writer) { - MYLOGD("Not adding dir %s because zip_writer is not set\n", dir); + if (!is_zipping()) { + MYLOGD("Not adding dir %s because dumpstate is not zipping\n", dir); return; } MYLOGD("Adding dir %s (recursive: %d)\n", dir, recursive); @@ -700,10 +697,14 @@ void add_dir(const char *dir, bool recursive) { dump_files(NULL, dir, recursive ? skip_none : is_dir, _add_file_from_fd); } +bool is_zipping() { + return zip_writer != nullptr; +} + /* adds a text entry entry to the existing zip file. */ static bool add_text_zip_entry(const std::string& entry_name, const std::string& content) { - if (!zip_writer) { - MYLOGD("Not adding text zip entry %s because zip_writer is not set\n", entry_name.c_str()); + if (!is_zipping()) { + MYLOGD("Not adding text entry %s because dumpstate is not zipping\n", entry_name.c_str()); return false; } MYLOGD("Adding zip text entry %s\n", entry_name.c_str()); @@ -1067,31 +1068,11 @@ static void usage() { VERSION_DEFAULT.c_str()); } -static void wake_lock_releaser() { - if (release_wake_lock(WAKE_LOCK_NAME) < 0) { - MYLOGE("Failed to release wake lock: %s \n", strerror(errno)); - } else { - MYLOGD("Wake lock released.\n"); - } -} - -static void sig_handler(int signo) { - wake_lock_releaser(); +static void sigpipe_handler(int n) { + // don't complain to stderr or stdout _exit(EXIT_FAILURE); } -static void register_sig_handler() { - struct sigaction sa; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sa.sa_handler = sig_handler; - sigaction(SIGPIPE, &sa, NULL); // broken pipe - sigaction(SIGSEGV, &sa, NULL); // segment fault - sigaction(SIGINT, &sa, NULL); // ctrl-c - sigaction(SIGTERM, &sa, NULL); // killed - sigaction(SIGQUIT, &sa, NULL); // quit -} - /* adds the temporary report to the existing .zip file, closes the .zip file, and removes the temporary file. */ @@ -1160,6 +1141,7 @@ static std::string SHA256_file_hash(std::string filepath) { } int main(int argc, char *argv[]) { + struct sigaction sigact; int do_add_date = 0; int do_zip_file = 0; int do_vibrate = 1; @@ -1176,14 +1158,6 @@ int main(int argc, char *argv[]) { MYLOGI("begin\n"); - if (acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_NAME) < 0) { - MYLOGE("Failed to acquire wake lock: %s \n", strerror(errno)); - } else { - MYLOGD("Wake lock acquired.\n"); - atexit(wake_lock_releaser); - register_sig_handler(); - } - /* gets the sequential id */ char last_id[PROPERTY_VALUE_MAX]; property_get("dumpstate.last_id", last_id, "0"); @@ -1192,6 +1166,11 @@ int main(int argc, char *argv[]) { property_set("dumpstate.last_id", last_id); MYLOGI("dumpstate id: %lu\n", id); + /* clear SIGPIPE handler */ + memset(&sigact, 0, sizeof(sigact)); + sigact.sa_handler = sigpipe_handler; + sigaction(SIGPIPE, &sigact, NULL); + /* set as high priority, and protect from OOM killer */ setpriority(PRIO_PROCESS, 0, -20); diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index 905fc2276a..1b28c49640 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -87,6 +87,9 @@ extern std::string bugreport_dir; /* root dir for all files copied as-is into the bugreport. */ extern const std::string ZIP_ROOT_DIR; +/* Checkes whether dumpstate is generating a zipped bugreport. */ +bool is_zipping(); + /* adds a new entry to the existing zip file. */ bool add_zip_entry(const std::string& entry_name, const std::string& entry_path); diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp index 4ac5b67ef1..7d3eaf363d 100644 --- a/cmds/dumpstate/utils.cpp +++ b/cmds/dumpstate/utils.cpp @@ -829,8 +829,8 @@ bool drop_root_user() { } gid_t groups[] = { AID_LOG, AID_SDCARD_R, AID_SDCARD_RW, - AID_MOUNT, AID_INET, AID_NET_BW_STATS, AID_READPROC, AID_WAKELOCK, - AID_BLUETOOTH }; + 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; @@ -851,10 +851,8 @@ bool drop_root_user() { capheader.version = _LINUX_CAPABILITY_VERSION_3; capheader.pid = 0; - capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = - (CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_BLOCK_SUSPEND)); - capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = - (CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_BLOCK_SUSPEND)); + capdata[CAP_TO_INDEX(CAP_SYSLOG)].permitted = CAP_TO_MASK(CAP_SYSLOG); + capdata[CAP_TO_INDEX(CAP_SYSLOG)].effective = CAP_TO_MASK(CAP_SYSLOG); capdata[0].inheritable = 0; capdata[1].inheritable = 0; diff --git a/data/etc/android.hardware.sensor.heartrate.fitness.xml b/data/etc/android.hardware.sensor.heartrate.fitness.xml new file mode 100644 index 0000000000..aef77b495e --- /dev/null +++ b/data/etc/android.hardware.sensor.heartrate.fitness.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<!-- Feature for devices supporting a fitness heart rate monitor --> +<permissions> + <feature name="android.hardware.sensor.heartrate.fitness" /> +</permissions> diff --git a/data/etc/handheld_core_hardware.xml b/data/etc/handheld_core_hardware.xml index 9cb4d6d480..f9464e8c55 100644 --- a/data/etc/handheld_core_hardware.xml +++ b/data/etc/handheld_core_hardware.xml @@ -50,8 +50,8 @@ <!-- Feature to specify if the device support managed users. --> <feature name="android.software.managed_users" /> - <!-- Feature to specify if the device supports a VR mode. --> - <feature name="android.software.vr.mode" /> + <!-- Feature to specify if the device supports a VR mode. + feature name="android.software.vr.mode" --> <!-- Devices with all optimizations required to be a "VR Ready" device that pass all CTS tests for this feature must include feature android.hardware.vr.high_performance --> diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index 74e75d74fc..b0d53ef5c8 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -681,8 +681,16 @@ status_t Parcel::unsafeReadTypedVector( return UNEXPECTED_NULL; } + if (val->max_size() < static_cast<size_t>(size)) { + return NO_MEMORY; + } + val->resize(static_cast<size_t>(size)); + if (val->size() < static_cast<size_t>(size)) { + return NO_MEMORY; + } + for (auto& v: *val) { status = (this->*read_func)(&v); diff --git a/include/ui/Fence.h b/include/ui/Fence.h index 2fbc9efb45..1df15f897c 100644 --- a/include/ui/Fence.h +++ b/include/ui/Fence.h @@ -27,6 +27,8 @@ #include <utils/String8.h> #include <utils/Timers.h> +#include <experimental/optional> + struct ANativeWindowBuffer; namespace android { @@ -96,16 +98,26 @@ public: // occurs then -1 is returned. nsecs_t getSignalTime() const; +#if __cplusplus > 201103L // hasSignaled returns whether the fence has signaled yet. Prefer this to // getSignalTime() or wait() if all you care about is whether the fence has - // signaled. - inline bool hasSignaled() { + // signaled. Returns an optional bool, which will have a value if there was + // no error. + inline std::experimental::optional<bool> hasSignaled() { // The sync_wait call underlying wait() has been measured to be // significantly faster than the sync_fence_info call underlying // getSignalTime(), which might otherwise appear to be the more obvious // way to check whether a fence has signaled. - return wait(0) == NO_ERROR; + switch (wait(0)) { + case NO_ERROR: + return true; + case -ETIME: + return false; + default: + return {}; + } } +#endif // Flattenable interface size_t getFlattenedSize() const; diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 2062b3b509..3aeff2eda3 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -135,10 +135,12 @@ public: { unsigned n; for (n = 0; n < 5; n++){ + if (n > 0) { + ALOGI("Waiting for service %s...", String8(name).string()); + sleep(1); + } sp<IBinder> svc = checkService(name); if (svc != NULL) return svc; - ALOGI("Waiting for service %s...\n", String8(name).string()); - sleep(1); } return NULL; } diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 061cb08fde..d753eb5fa8 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -514,7 +514,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len) // grow objects if (mObjectsCapacity < mObjectsSize + numObjects) { size_t newSize = ((mObjectsSize + numObjects)*3)/2; - if (newSize < mObjectsSize) return NO_MEMORY; // overflow + if (newSize*sizeof(binder_size_t) < mObjectsSize) return NO_MEMORY; // overflow binder_size_t *objects = (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t)); if (objects == (binder_size_t*)0) { @@ -1308,7 +1308,7 @@ restart_write: } if (!enoughObjects) { size_t newSize = ((mObjectsSize+2)*3)/2; - if (newSize < mObjectsSize) return NO_MEMORY; // overflow + if (newSize*sizeof(binder_size_t) < mObjectsSize) return NO_MEMORY; // overflow binder_size_t* objects = (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t)); if (objects == NULL) return NO_MEMORY; mObjects = objects; diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp index 7fbf312727..ee4c58cfce 100644 --- a/libs/gui/BufferQueueConsumer.cpp +++ b/libs/gui/BufferQueueConsumer.cpp @@ -716,6 +716,7 @@ status_t BufferQueueConsumer::setTransformHint(uint32_t hint) { } sp<NativeHandle> BufferQueueConsumer::getSidebandStream() const { + Mutex::Autolock lock(mCore->mMutex); return mCore->mSidebandStream; } diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp index d74d32c06d..6e6cce28eb 100644 --- a/libs/gui/BufferQueueCore.cpp +++ b/libs/gui/BufferQueueCore.cpp @@ -93,6 +93,7 @@ BufferQueueCore::BufferQueueCore(const sp<IGraphicBufferAlloc>& allocator) : mSharedBufferSlot(INVALID_BUFFER_SLOT), mSharedBufferCache(Rect::INVALID_RECT, 0, NATIVE_WINDOW_SCALING_MODE_FREEZE, HAL_DATASPACE_UNKNOWN), + mLastQueuedSlot(INVALID_BUFFER_SLOT), mUniqueId(getUniqueId()) { if (allocator == NULL) { diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index f8f38725b5..13b900c837 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -1358,6 +1358,7 @@ status_t BufferQueueProducer::setGenerationNumber(uint32_t generationNumber) { String8 BufferQueueProducer::getConsumerName() const { ATRACE_CALL(); + Mutex::Autolock lock(mCore->mMutex); BQ_LOGV("getConsumerName: %s", mConsumerName.string()); return mConsumerName; } diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp index 5546d5416c..3cf3078345 100644 --- a/libs/gui/ConsumerBase.cpp +++ b/libs/gui/ConsumerBase.cpp @@ -314,6 +314,18 @@ status_t ConsumerBase::addReleaseFenceLocked(int slot, if (!mSlots[slot].mFence.get()) { mSlots[slot].mFence = fence; + return OK; + } + + auto signaled = mSlots[slot].mFence->hasSignaled(); + + if (!signaled) { + CB_LOGE("fence has invalid state"); + return BAD_VALUE; + } + + if (*signaled) { + mSlots[slot].mFence = fence; } else { char fenceName[32] = {}; snprintf(fenceName, 32, "%.28s:%d", mName.string(), slot); diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp index 5338034fd6..57c3073bf4 100644 --- a/libs/gui/SensorManager.cpp +++ b/libs/gui/SensorManager.cpp @@ -194,7 +194,8 @@ Sensor const* SensorManager::getDefaultSensor(int type) // a non_wake-up version. if (type == SENSOR_TYPE_PROXIMITY || type == SENSOR_TYPE_SIGNIFICANT_MOTION || type == SENSOR_TYPE_TILT_DETECTOR || type == SENSOR_TYPE_WAKE_GESTURE || - type == SENSOR_TYPE_GLANCE_GESTURE || type == SENSOR_TYPE_PICK_UP_GESTURE) { + type == SENSOR_TYPE_GLANCE_GESTURE || type == SENSOR_TYPE_PICK_UP_GESTURE || + type == SENSOR_TYPE_WRIST_TILT_GESTURE) { wakeUpSensor = true; } // For now we just return the first sensor of that type we find. diff --git a/libs/ui/Gralloc1On0Adapter.cpp b/libs/ui/Gralloc1On0Adapter.cpp index d5b88deb9a..ec7df31f9c 100644 --- a/libs/ui/Gralloc1On0Adapter.cpp +++ b/libs/ui/Gralloc1On0Adapter.cpp @@ -288,6 +288,7 @@ gralloc1_error_t Gralloc1On0Adapter::allocateWithIdHook( gralloc1_error_t Gralloc1On0Adapter::retain( const std::shared_ptr<Buffer>& buffer) { + std::lock_guard<std::mutex> lock(mBufferMutex); buffer->retain(); return GRALLOC1_ERROR_NONE; } @@ -295,6 +296,7 @@ gralloc1_error_t Gralloc1On0Adapter::retain( gralloc1_error_t Gralloc1On0Adapter::release( const std::shared_ptr<Buffer>& buffer) { + std::lock_guard<std::mutex> lock(mBufferMutex); if (!buffer->release()) { return GRALLOC1_ERROR_NONE; } @@ -314,7 +316,6 @@ gralloc1_error_t Gralloc1On0Adapter::release( } } - std::lock_guard<std::mutex> lock(mBufferMutex); mBuffers.erase(handle); return GRALLOC1_ERROR_NONE; } |