diff options
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 24 | ||||
| -rw-r--r-- | cmds/dumpstate/dumpstate.h | 3 | ||||
| -rw-r--r-- | data/etc/android.hardware.sensor.heartrate.fitness.xml | 20 | ||||
| -rw-r--r-- | include/ui/Fence.h | 18 | ||||
| -rw-r--r-- | libs/gui/ConsumerBase.cpp | 12 | ||||
| -rw-r--r-- | libs/gui/SensorManager.cpp | 3 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 17 |
7 files changed, 74 insertions, 23 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 5b01be1274..11feb167f0 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -152,7 +152,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 +313,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 +370,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 +620,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 +691,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 +700,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()); 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/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/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/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/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 8db071ed2f..db52d40214 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1768,9 +1768,12 @@ void SurfaceFlinger::updateCursorAsync() void SurfaceFlinger::commitTransaction() { - if (!mLayersPendingRemoval.isEmpty()) { + sp<const DisplayDevice> hw = getDefaultDisplayDevice(); + + if (!mLayersPendingRemoval.isEmpty() && hw->isDisplayOn()) { // Notify removed layers now that they can't be drawn from for (size_t i = 0; i < mLayersPendingRemoval.size(); i++) { + mCurrentState.layersSortedByZ.remove(mLayersPendingRemoval[i]); recordBufferingStats(mLayersPendingRemoval[i]->getName().string(), mLayersPendingRemoval[i]->getOccupancyHistory(true)); mLayersPendingRemoval[i]->onRemoved(); @@ -2217,14 +2220,10 @@ status_t SurfaceFlinger::removeLayer(const wp<Layer>& weakLayer) { return NO_ERROR; } - ssize_t index = mCurrentState.layersSortedByZ.remove(layer); - if (index >= 0) { - mLayersPendingRemoval.push(layer); - mLayersRemoved = true; - setTransactionFlags(eTransactionNeeded); - return NO_ERROR; - } - return status_t(index); + mLayersPendingRemoval.push(layer); + mLayersRemoved = true; + setTransactionFlags(eTransactionNeeded); + return NO_ERROR; } uint32_t SurfaceFlinger::peekTransactionFlags(uint32_t /* flags */) { |