Merge "Fix sensorservice on integer sanitized builds."
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index e792942..51942dd 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -1160,19 +1160,6 @@
RunCommand("LAST RADIO LOG", {"parse_radio_log", "/proc/last_radio_log"});
- printf("------ BACKLIGHTS ------\n");
- printf("LCD brightness=");
- DumpFile("", "/sys/class/leds/lcd-backlight/brightness");
- printf("Button brightness=");
- DumpFile("", "/sys/class/leds/button-backlight/brightness");
- printf("Keyboard brightness=");
- DumpFile("", "/sys/class/leds/keyboard-backlight/brightness");
- printf("ALS mode=");
- DumpFile("", "/sys/class/leds/lcd-backlight/als");
- printf("LCD driver registers:\n");
- DumpFile("", "/sys/class/leds/lcd-backlight/registers");
- printf("\n");
-
/* Binder state is expensive to look at as it uses a lot of memory. */
DumpFile("BINDER FAILED TRANSACTION LOG", "/sys/kernel/debug/binder/failed_transaction_log");
DumpFile("BINDER TRANSACTION LOG", "/sys/kernel/debug/binder/transaction_log");
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index 88edd0a..29d5c32 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -958,7 +958,7 @@
if (EndsWith(oat_path, ".dex")) {
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()));
+ CHECK(EndsWith(new_path, new_ext));
return new_path;
}
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index e0d23da..8a56894 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -882,7 +882,7 @@
// backs to do weird things.)
const char* apk_path = package_parameters_.apk_path;
CHECK(apk_path != nullptr);
- if (StartsWith(apk_path, android_root_.c_str())) {
+ if (StartsWith(apk_path, android_root_)) {
const char* last_slash = strrchr(apk_path, '/');
if (last_slash != nullptr) {
std::string path(apk_path, last_slash - apk_path + 1);
diff --git a/libs/nativewindow/Android.bp b/libs/nativewindow/Android.bp
index aa116bf..29555fd 100644
--- a/libs/nativewindow/Android.bp
+++ b/libs/nativewindow/Android.bp
@@ -47,6 +47,8 @@
"-std=c++1z"
],
+ version_script: "libnativewindow.map.txt",
+
srcs: [
"AHardwareBuffer.cpp",
"ANativeWindow.cpp",
diff --git a/libs/nativewindow/libnativewindow.map.txt b/libs/nativewindow/libnativewindow.map.txt
index 58045be..105d01b 100644
--- a/libs/nativewindow/libnativewindow.map.txt
+++ b/libs/nativewindow/libnativewindow.map.txt
@@ -3,13 +3,11 @@
AHardwareBuffer_acquire;
AHardwareBuffer_allocate;
AHardwareBuffer_describe;
- AHardwareBuffer_fromHardwareBuffer;
AHardwareBuffer_getNativeHandle; # vndk
AHardwareBuffer_lock;
AHardwareBuffer_recvHandleFromUnixSocket;
AHardwareBuffer_release;
AHardwareBuffer_sendHandleToUnixSocket;
- AHardwareBuffer_toHardwareBuffer;
AHardwareBuffer_unlock;
ANativeWindowBuffer_getHardwareBuffer; # vndk
ANativeWindow_OemStorageGet; # vndk
@@ -17,8 +15,6 @@
ANativeWindow_acquire;
ANativeWindow_cancelBuffer; # vndk
ANativeWindow_dequeueBuffer; # vndk
- ANativeWindow_fromSurface;
- ANativeWindow_fromSurfaceTexture;
ANativeWindow_getFormat;
ANativeWindow_getHeight;
ANativeWindow_getWidth;
@@ -42,3 +38,17 @@
local:
*;
};
+
+LIBNATIVEWINDOW_PLATFORM {
+ global:
+ extern "C++" {
+ android::AHardwareBuffer_isValidPixelFormat*;
+ android::AHardwareBuffer_convertFromPixelFormat*;
+ android::AHardwareBuffer_convertToPixelFormat*;
+ android::AHardwareBuffer_convertFromGrallocUsageBits*;
+ android::AHardwareBuffer_convertToGrallocUsageBits*;
+ android::AHardwareBuffer_to_GraphicBuffer*;
+ android::AHardwareBuffer_to_ANativeWindowBuffer*;
+ android::AHardwareBuffer_from_GraphicBuffer*;
+ };
+} LIBNATIVEWINDOW;
diff --git a/libs/sensor/ISensorServer.cpp b/libs/sensor/ISensorServer.cpp
index f20668d..efbbf7d 100644
--- a/libs/sensor/ISensorServer.cpp
+++ b/libs/sensor/ISensorServer.cpp
@@ -63,7 +63,8 @@
Vector<Sensor> v;
uint32_t n = reply.readUint32();
v.setCapacity(n);
- while (n--) {
+ while (n) {
+ n--;
reply.read(s);
v.add(s);
}
@@ -80,7 +81,8 @@
Vector<Sensor> v;
uint32_t n = reply.readUint32();
v.setCapacity(n);
- while (n--) {
+ while (n) {
+ n--;
reply.read(s);
v.add(s);
}
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index b096a3a..a16c040 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -444,10 +444,16 @@
HWC2::Error error = HWC2::Error::None;
- // First try to skip validate altogether if the HWC supports it.
+ // First try to skip validate altogether when there is no client
+ // composition. When there is client composition, since we haven't
+ // rendered to the client target yet, we should not attempt to skip
+ // validate.
+ //
+ // displayData.hasClientComposition hasn't been updated for this frame.
+ // The check below is incorrect. We actually rely on HWC here to fall
+ // back to validate when there is any client layer.
displayData.validateWasSkipped = false;
- if (hasCapability(HWC2::Capability::SkipValidate) &&
- !displayData.hasClientComposition) {
+ if (!displayData.hasClientComposition) {
sp<android::Fence> outPresentFence;
uint32_t state = UINT32_MAX;
error = hwcDisplay->presentOrValidate(&numTypes, &numRequests, &outPresentFence , &state);
diff --git a/services/surfaceflinger/EventThread.cpp b/services/surfaceflinger/EventThread.cpp
index a9bb2ba..f647742 100644
--- a/services/surfaceflinger/EventThread.cpp
+++ b/services/surfaceflinger/EventThread.cpp
@@ -248,7 +248,7 @@
// find out connections waiting for events
size_t count = mDisplayEventConnections.size();
- for (size_t i=0 ; i<count ; i++) {
+ for (size_t i=0 ; i<count ; ) {
sp<Connection> connection(mDisplayEventConnections[i].promote());
if (connection != NULL) {
bool added = false;
@@ -279,11 +279,12 @@
// messages.
signalConnections.add(connection);
}
+ ++i;
} else {
// we couldn't promote this reference, the connection has
// died, so clean-up!
mDisplayEventConnections.removeAt(i);
- --i; --count;
+ --count;
}
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index ca9a546..70c702b 100755
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -70,7 +70,7 @@
: contentDirty(false),
sequence(uint32_t(android_atomic_inc(&sSequence))),
mFlinger(flinger),
- mTextureName(-1U),
+ mTextureName(UINT32_MAX),
mPremultipliedAlpha(true),
mName("unnamed"),
mFormat(PIXEL_FORMAT_NONE),
@@ -2659,6 +2659,7 @@
return mDrawingState.z;
}
+__attribute__((no_sanitize("unsigned-integer-overflow")))
LayerVector Layer::makeTraversalList(LayerVector::StateSet stateSet) {
LOG_ALWAYS_FATAL_IF(stateSet == LayerVector::StateSet::Invalid,
"makeTraversalList received invalid stateSet");
@@ -2714,7 +2715,7 @@
LayerVector list = makeTraversalList(stateSet);
int32_t i = 0;
- for (i = list.size()-1; i>=0; i--) {
+ for (i = int32_t(list.size()) - 1; i >= 0; i--) {
const auto& relative = list[i];
if (relative->getZ() < 0) {
break;
diff --git a/services/surfaceflinger/LayerVector.cpp b/services/surfaceflinger/LayerVector.cpp
index 2233e78..d0f8fbe 100644
--- a/services/surfaceflinger/LayerVector.cpp
+++ b/services/surfaceflinger/LayerVector.cpp
@@ -35,14 +35,17 @@
uint32_t ls = l->getCurrentState().layerStack;
uint32_t rs = r->getCurrentState().layerStack;
if (ls != rs)
- return ls - rs;
+ return (ls > rs) ? 1 : -1;
uint32_t lz = l->getCurrentState().z;
uint32_t rz = r->getCurrentState().z;
if (lz != rz)
- return lz - rz;
+ return (lz > rz) ? 1 : -1;
- return l->sequence - r->sequence;
+ if (l->sequence == r->sequence)
+ return 0;
+
+ return (l->sequence > r->sequence) ? 1 : -1;
}
void LayerVector::traverseInZOrder(StateSet stateSet, const Visitor& visitor) const {
diff --git a/services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp b/services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp
index 561db8d..07b8cc0 100644
--- a/services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp
+++ b/services/surfaceflinger/tests/fakehwc/FakeComposerClient.cpp
@@ -157,6 +157,10 @@
FakeComposerClient::~FakeComposerClient() {}
+bool FakeComposerClient::hasCapability(hwc2_capability_t /*capability*/) {
+ return false;
+}
+
void FakeComposerClient::removeClient() {
ALOGV("removeClient");
// TODO: Ahooga! Only thing current lifetime management choices in
diff --git a/services/surfaceflinger/tests/fakehwc/FakeComposerClient.h b/services/surfaceflinger/tests/fakehwc/FakeComposerClient.h
index 294abb2..dd384c0 100644
--- a/services/surfaceflinger/tests/fakehwc/FakeComposerClient.h
+++ b/services/surfaceflinger/tests/fakehwc/FakeComposerClient.h
@@ -45,6 +45,8 @@
FakeComposerClient();
virtual ~FakeComposerClient();
+ bool hasCapability(hwc2_capability_t capability) override;
+
void removeClient() override;
void enableCallback(bool enable) override;
uint32_t getMaxVirtualDisplayCount() override;
diff --git a/services/vr/hardware_composer/impl/vr_hwc.cpp b/services/vr/hardware_composer/impl/vr_hwc.cpp
index fd271d0..d5664d5 100644
--- a/services/vr/hardware_composer/impl/vr_hwc.cpp
+++ b/services/vr/hardware_composer/impl/vr_hwc.cpp
@@ -232,7 +232,7 @@
VrHwc::~VrHwc() {}
-bool VrHwc::hasCapability(Capability /* capability */) const { return false; }
+bool VrHwc::hasCapability(hwc2_capability_t /* capability */) { return false; }
void VrHwc::removeClient() {
std::lock_guard<std::mutex> guard(mutex_);
diff --git a/services/vr/hardware_composer/impl/vr_hwc.h b/services/vr/hardware_composer/impl/vr_hwc.h
index fce9a06..eff721b 100644
--- a/services/vr/hardware_composer/impl/vr_hwc.h
+++ b/services/vr/hardware_composer/impl/vr_hwc.h
@@ -196,8 +196,6 @@
VrHwc();
~VrHwc() override;
- bool hasCapability(Capability capability) const;
-
Error setLayerInfo(Display display, Layer layer, uint32_t type,
uint32_t appId);
Error setClientTargetMetadata(
@@ -207,6 +205,8 @@
const IVrComposerClient::BufferMetadata& metadata);
// ComposerBase
+ bool hasCapability(hwc2_capability_t capability) override;
+
void removeClient() override;
void enableCallback(bool enable) override;