Merge "Scale the pressure range's max value."
diff --git a/libs/binder/ActivityManager.cpp b/libs/binder/ActivityManager.cpp
new file mode 100644
index 0000000..2904718
--- /dev/null
+++ b/libs/binder/ActivityManager.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2017 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 <mutex>
+#include <binder/ActivityManager.h>
+#include <binder/Binder.h>
+#include <binder/IServiceManager.h>
+
+#include <utils/SystemClock.h>
+
+namespace android {
+
+ActivityManager::ActivityManager()
+{
+}
+
+sp<IActivityManager> ActivityManager::getService()
+{
+ std::lock_guard<Mutex> scoped_lock(mLock);
+ int64_t startTime = 0;
+ sp<IActivityManager> service = mService;
+ while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) {
+ sp<IBinder> binder = defaultServiceManager()->checkService(String16("activity"));
+ if (binder == NULL) {
+ // Wait for the activity service to come back...
+ if (startTime == 0) {
+ startTime = uptimeMillis();
+ ALOGI("Waiting for activity service");
+ } else if ((uptimeMillis() - startTime) > 10000) {
+ ALOGW("Waiting too long for activity service, giving up");
+ service = NULL;
+ break;
+ }
+ sleep(1);
+ } else {
+ service = interface_cast<IActivityManager>(binder);
+ mService = service;
+ }
+ }
+ return service;
+}
+
+int ActivityManager::openContentUri(const String16& stringUri)
+{
+ sp<IActivityManager> service = getService();
+ return service != NULL ? service->openContentUri(stringUri) : -1;
+}
+
+void ActivityManager::registerUidObserver(const sp<IUidObserver>& observer,
+ const int32_t event,
+ const int32_t cutpoint,
+ const String16& callingPackage)
+{
+ sp<IActivityManager> service = getService();
+ if (service != NULL) {
+ service->registerUidObserver(observer, event, cutpoint, callingPackage);
+ }
+}
+
+void ActivityManager::unregisterUidObserver(const sp<IUidObserver>& observer)
+{
+ sp<IActivityManager> service = getService();
+ if (service != NULL) {
+ service->unregisterUidObserver(observer);
+ }
+}
+
+}; // namespace android
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index c130087..2a07cd1 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -38,6 +38,7 @@
},
srcs: [
+ "ActivityManager.cpp",
"AppOpsManager.cpp",
"Binder.cpp",
"BpBinder.cpp",
@@ -56,6 +57,7 @@
"IResultReceiver.cpp",
"IServiceManager.cpp",
"IShellCallback.cpp",
+ "IUidObserver.cpp",
"MemoryBase.cpp",
"MemoryDealer.cpp",
"MemoryHeapBase.cpp",
diff --git a/libs/binder/IActivityManager.cpp b/libs/binder/IActivityManager.cpp
index 50a8b28..b7a5fd9 100644
--- a/libs/binder/IActivityManager.cpp
+++ b/libs/binder/IActivityManager.cpp
@@ -56,6 +56,28 @@
}
return fd;
}
+
+ virtual void registerUidObserver(const sp<IUidObserver>& observer,
+ const int32_t event,
+ const int32_t cutpoint,
+ const String16& callingPackage)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor());
+ data.writeStrongBinder(IInterface::asBinder(observer));
+ data.writeInt32(event);
+ data.writeInt32(cutpoint);
+ data.writeString16(callingPackage);
+ remote()->transact(REGISTER_UID_OBSERVER_TRANSACTION, data, &reply);
+ }
+
+ virtual void unregisterUidObserver(const sp<IUidObserver>& observer)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor());
+ data.writeStrongBinder(IInterface::asBinder(observer));
+ remote()->transact(UNREGISTER_UID_OBSERVER_TRANSACTION, data, &reply);
+ }
};
// ------------------------------------------------------------------------------------
diff --git a/libs/binder/IUidObserver.cpp b/libs/binder/IUidObserver.cpp
new file mode 100644
index 0000000..697e948
--- /dev/null
+++ b/libs/binder/IUidObserver.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2017 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 <binder/IUidObserver.h>
+
+#include <binder/Parcel.h>
+
+namespace android {
+
+// ------------------------------------------------------------------------------------
+
+class BpUidObserver : public BpInterface<IUidObserver>
+{
+public:
+ explicit BpUidObserver(const sp<IBinder>& impl)
+ : BpInterface<IUidObserver>(impl)
+ {
+ }
+
+ virtual void onUidGone(uid_t uid, bool disabled)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IUidObserver::getInterfaceDescriptor());
+ data.writeInt32((int32_t) uid);
+ data.writeInt32(disabled ? 1 : 0);
+ remote()->transact(ON_UID_GONE_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ virtual void onUidActive(uid_t uid)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IUidObserver::getInterfaceDescriptor());
+ data.writeInt32((int32_t) uid);
+ remote()->transact(ON_UID_ACTIVE_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ virtual void onUidIdle(uid_t uid, bool disabled)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IUidObserver::getInterfaceDescriptor());
+ data.writeInt32((int32_t) uid);
+ data.writeInt32(disabled ? 1 : 0);
+ remote()->transact(ON_UID_IDLE_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+};
+
+// ----------------------------------------------------------------------
+
+IMPLEMENT_META_INTERFACE(UidObserver, "android.app.IUidObserver");
+
+// ----------------------------------------------------------------------
+
+status_t BnUidObserver::onTransact(
+ uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+{
+ switch(code) {
+ case ON_UID_GONE_TRANSACTION: {
+ CHECK_INTERFACE(IUidObserver, data, reply);
+ uid_t uid = data.readInt32();
+ bool disabled = data.readInt32() == 1;
+ onUidGone(uid, disabled);
+ return NO_ERROR;
+ } break;
+
+ case ON_UID_ACTIVE_TRANSACTION: {
+ CHECK_INTERFACE(IUidObserver, data, reply);
+ uid_t uid = data.readInt32();
+ onUidActive(uid);
+ return NO_ERROR;
+ } break;
+
+ case ON_UID_IDLE_TRANSACTION: {
+ CHECK_INTERFACE(IUidObserver, data, reply);
+ uid_t uid = data.readInt32();
+ bool disabled = data.readInt32() == 1;
+ onUidIdle(uid, disabled);
+ return NO_ERROR;
+ } break;
+ default:
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+}
+
+}; // namespace android
diff --git a/libs/binder/include/binder/ActivityManager.h b/libs/binder/include/binder/ActivityManager.h
new file mode 100644
index 0000000..408c428
--- /dev/null
+++ b/libs/binder/include/binder/ActivityManager.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_ACTIVITY_MANAGER_H
+#define ANDROID_ACTIVITY_MANAGER_H
+
+#include <binder/IActivityManager.h>
+
+#include <utils/threads.h>
+
+// ---------------------------------------------------------------------------
+namespace android {
+
+class ActivityManager
+{
+public:
+
+ enum {
+ // Flag for registerUidObserver: report uid gone
+ UID_OBSERVER_GONE = 1<<1,
+ // Flag for registerUidObserver: report uid has become idle
+ UID_OBSERVER_IDLE = 1<<2,
+ // Flag for registerUidObserver: report uid has become active
+ UID_OBSERVER_ACTIVE = 1<<3
+ };
+
+ enum {
+ // Not a real process state
+ PROCESS_STATE_UNKNOWN = -1
+ };
+
+ ActivityManager();
+
+ int openContentUri(const String16& stringUri);
+ void registerUidObserver(const sp<IUidObserver>& observer,
+ const int32_t event,
+ const int32_t cutpoint,
+ const String16& callingPackage);
+ void unregisterUidObserver(const sp<IUidObserver>& observer);
+
+private:
+ Mutex mLock;
+ sp<IActivityManager> mService;
+ sp<IActivityManager> getService();
+};
+
+
+}; // namespace android
+// ---------------------------------------------------------------------------
+#endif // ANDROID_ACTIVITY_MANAGER_H
diff --git a/libs/binder/include/binder/IActivityManager.h b/libs/binder/include/binder/IActivityManager.h
index 5ad2180..bac2a99 100644
--- a/libs/binder/include/binder/IActivityManager.h
+++ b/libs/binder/include/binder/IActivityManager.h
@@ -18,6 +18,7 @@
#define ANDROID_IACTIVITY_MANAGER_H
#include <binder/IInterface.h>
+#include <binder/IUidObserver.h>
namespace android {
@@ -28,10 +29,17 @@
public:
DECLARE_META_INTERFACE(ActivityManager)
- virtual int openContentUri(const String16& /* stringUri */) = 0;
+ virtual int openContentUri(const String16& stringUri) = 0;
+ virtual void registerUidObserver(const sp<IUidObserver>& observer,
+ const int32_t event,
+ const int32_t cutpoint,
+ const String16& callingPackage) = 0;
+ virtual void unregisterUidObserver(const sp<IUidObserver>& observer) = 0;
enum {
- OPEN_CONTENT_URI_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION
+ OPEN_CONTENT_URI_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
+ REGISTER_UID_OBSERVER_TRANSACTION,
+ UNREGISTER_UID_OBSERVER_TRANSACTION
};
};
@@ -39,4 +47,4 @@
}; // namespace android
-#endif // ANDROID_IACTIVITY_MANAGER_H
\ No newline at end of file
+#endif // ANDROID_IACTIVITY_MANAGER_H
diff --git a/libs/binder/include/binder/IUidObserver.h b/libs/binder/include/binder/IUidObserver.h
new file mode 100644
index 0000000..fd4d8a6
--- /dev/null
+++ b/libs/binder/include/binder/IUidObserver.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//
+#ifndef ANDROID_IUID_OBSERVER_H
+#define ANDROID_IUID_OBSERVER_H
+
+#include <binder/IInterface.h>
+
+namespace android {
+
+// ----------------------------------------------------------------------
+
+class IUidObserver : public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(UidObserver)
+
+ virtual void onUidGone(uid_t uid, bool disabled) = 0;
+ virtual void onUidActive(uid_t uid) = 0;
+ virtual void onUidIdle(uid_t uid, bool disabled) = 0;
+
+ enum {
+ ON_UID_GONE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
+ ON_UID_ACTIVE_TRANSACTION,
+ ON_UID_IDLE_TRANSACTION
+ };
+};
+
+// ----------------------------------------------------------------------
+
+class BnUidObserver : public BnInterface<IUidObserver>
+{
+public:
+ virtual status_t onTransact(uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+// ----------------------------------------------------------------------
+
+}; // namespace android
+
+#endif // ANDROID_IUID_OBSERVER_H
diff --git a/libs/graphicsenv/Android.bp b/libs/graphicsenv/Android.bp
index 9f99538..4da30e9 100644
--- a/libs/graphicsenv/Android.bp
+++ b/libs/graphicsenv/Android.bp
@@ -22,7 +22,6 @@
cflags: ["-Wall", "-Werror"],
shared_libs: [
- "libnativeloader",
"liblog",
],
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index f46e9f6..961f101 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -20,13 +20,23 @@
#include <mutex>
+#include <android/dlext.h>
#include <log/log.h>
-#include <nativeloader/dlext_namespaces.h>
-#include <nativeloader/native_loader.h>
// TODO(b/37049319) Get this from a header once one exists
extern "C" {
android_namespace_t* android_get_exported_namespace(const char*);
+ android_namespace_t* android_create_namespace(const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path,
+ android_namespace_t* parent);
+
+ enum {
+ ANDROID_NAMESPACE_TYPE_ISOLATED = 1,
+ ANDROID_NAMESPACE_TYPE_SHARED = 2,
+ };
}
namespace android {
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
index 102964f..abe856e 100644
--- a/libs/ui/Android.bp
+++ b/libs/ui/Android.bp
@@ -95,6 +95,7 @@
],
header_libs: [
+ "libbase_headers",
"libnativebase_headers",
"libhardware_headers",
],
@@ -107,6 +108,7 @@
],
export_header_lib_headers: [
+ "libbase_headers",
"libnativebase_headers",
"libhardware_headers",
],
diff --git a/libs/ui/Fence.cpp b/libs/ui/Fence.cpp
index b67f4d9..ff53aa8 100644
--- a/libs/ui/Fence.cpp
+++ b/libs/ui/Fence.cpp
@@ -37,18 +37,12 @@
const sp<Fence> Fence::NO_FENCE = sp<Fence>(new Fence);
-Fence::Fence() :
- mFenceFd(-1) {
-}
-
Fence::Fence(int fenceFd) :
mFenceFd(fenceFd) {
}
-Fence::~Fence() {
- if (mFenceFd != -1) {
- close(mFenceFd);
- }
+Fence::Fence(base::unique_fd fenceFd) :
+ mFenceFd(std::move(fenceFd)) {
}
status_t Fence::wait(int timeout) {
@@ -68,7 +62,7 @@
int warningTimeout = 3000;
int err = sync_wait(mFenceFd, warningTimeout);
if (err < 0 && errno == ETIME) {
- ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd,
+ ALOGE("%s: fence %d didn't signal in %u ms", logname, mFenceFd.get(),
warningTimeout);
err = sync_wait(mFenceFd, TIMEOUT_NEVER);
}
@@ -94,7 +88,7 @@
if (result == -1) {
status_t err = -errno;
ALOGE("merge: sync_merge(\"%s\", %d, %d) returned an error: %s (%d)",
- name, f1->mFenceFd, f2->mFenceFd,
+ name, f1->mFenceFd.get(), f2->mFenceFd.get(),
strerror(-err), err);
return NO_FENCE;
}
@@ -117,7 +111,7 @@
struct sync_fence_info_data* finfo = sync_fence_info(mFenceFd);
if (finfo == NULL) {
- ALOGE("sync_fence_info returned NULL for fd %d", mFenceFd);
+ ALOGE("sync_fence_info returned NULL for fd %d", mFenceFd.get());
return SIGNAL_TIME_INVALID;
}
if (finfo->status != 1) {
@@ -181,7 +175,7 @@
}
if (numFds) {
- mFenceFd = *fds++;
+ mFenceFd.reset(*fds++);
count--;
}
diff --git a/libs/ui/include/ui/Fence.h b/libs/ui/include/ui/Fence.h
index 37811bc..ec67fa9 100644
--- a/libs/ui/include/ui/Fence.h
+++ b/libs/ui/include/ui/Fence.h
@@ -19,6 +19,7 @@
#include <stdint.h>
+#include <android-base/unique_fd.h>
#include <utils/Flattenable.h>
#include <utils/RefBase.h>
#include <utils/Timers.h>
@@ -49,12 +50,13 @@
// Construct a new Fence object with an invalid file descriptor. This
// should be done when the Fence object will be set up by unflattening
// serialized data.
- Fence();
+ Fence() = default;
// 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.
explicit Fence(int fenceFd);
+ explicit Fence(base::unique_fd fenceFd);
// Not copyable or movable.
Fence(const Fence& rhs) = delete;
@@ -136,9 +138,9 @@
private:
// Only allow instantiation using ref counting.
friend class LightRefBase<Fence>;
- ~Fence();
+ ~Fence() = default;
- int mFenceFd;
+ base::unique_fd mFenceFd;
};
}; // namespace android
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index acdfafc..5f70ab5 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -53,7 +53,7 @@
BufferLayer::BufferLayer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name,
uint32_t w, uint32_t h, uint32_t flags)
: Layer(flinger, client, name, w, h, flags),
- mSurfaceFlingerConsumer(nullptr),
+ mConsumer(nullptr),
mTextureName(UINT32_MAX),
mFormat(PIXEL_FORMAT_NONE),
mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
@@ -89,7 +89,7 @@
if (mFlinger->mForceFullDamage) {
surfaceDamageRegion = Region::INVALID_REGION;
} else {
- surfaceDamageRegion = mSurfaceFlingerConsumer->getSurfaceDamage();
+ surfaceDamageRegion = mConsumer->getSurfaceDamage();
}
}
@@ -129,9 +129,9 @@
mProtectedByApp = (flags & ISurfaceComposerClient::eProtectedByApp) ? true : false;
mCurrentOpacity = getOpacityForFormat(format);
- mSurfaceFlingerConsumer->setDefaultBufferSize(w, h);
- mSurfaceFlingerConsumer->setDefaultBufferFormat(format);
- mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
+ mConsumer->setDefaultBufferSize(w, h);
+ mConsumer->setDefaultBufferFormat(format);
+ mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
return NO_ERROR;
}
@@ -190,7 +190,7 @@
// Bind the current buffer to the GL texture, and wait for it to be
// ready for us to draw into.
- status_t err = mSurfaceFlingerConsumer->bindTextureImage();
+ status_t err = mConsumer->bindTextureImage();
if (err != NO_ERROR) {
ALOGW("onDraw: bindTextureImage failed (err=%d)", err);
// Go ahead and draw the buffer anyway; no matter what we do the screen
@@ -207,8 +207,8 @@
// Query the texture matrix given our current filtering mode.
float textureMatrix[16];
- mSurfaceFlingerConsumer->setFilteringEnabled(useFiltering);
- mSurfaceFlingerConsumer->getTransformMatrix(textureMatrix);
+ mConsumer->setFilteringEnabled(useFiltering);
+ mConsumer->getTransformMatrix(textureMatrix);
if (getTransformToDisplayInverse()) {
/*
@@ -253,11 +253,11 @@
}
void BufferLayer::onLayerDisplayed(const sp<Fence>& releaseFence) {
- mSurfaceFlingerConsumer->setReleaseFence(releaseFence);
+ mConsumer->setReleaseFence(releaseFence);
}
void BufferLayer::abandon() {
- mSurfaceFlingerConsumer->abandon();
+ mConsumer->abandon();
}
bool BufferLayer::shouldPresentNow(const DispSync& dispSync) const {
@@ -270,7 +270,7 @@
return false;
}
auto timestamp = mQueueItems[0].mTimestamp;
- nsecs_t expectedPresent = mSurfaceFlingerConsumer->computeExpectedPresent(dispSync);
+ nsecs_t expectedPresent = mConsumer->computeExpectedPresent(dispSync);
// Ignore timestamps more than a second in the future
bool isPlausible = timestamp < (expectedPresent + s2ns(1));
@@ -284,7 +284,7 @@
}
void BufferLayer::setTransformHint(uint32_t orientation) const {
- mSurfaceFlingerConsumer->setTransformHint(orientation);
+ mConsumer->setTransformHint(orientation);
}
bool BufferLayer::onPreComposition(nsecs_t refreshStartTime) {
@@ -312,10 +312,10 @@
}
// Update mFrameTracker.
- nsecs_t desiredPresentTime = mSurfaceFlingerConsumer->getTimestamp();
+ nsecs_t desiredPresentTime = mConsumer->getTimestamp();
mFrameTracker.setDesiredPresentTime(desiredPresentTime);
- std::shared_ptr<FenceTime> frameReadyFence = mSurfaceFlingerConsumer->getCurrentFenceTime();
+ std::shared_ptr<FenceTime> frameReadyFence = mConsumer->getCurrentFenceTime();
if (frameReadyFence->isValid()) {
mFrameTracker.setFrameReadyFence(std::move(frameReadyFence));
} else {
@@ -340,7 +340,7 @@
std::vector<OccupancyTracker::Segment> BufferLayer::getOccupancyHistory(bool forceFlush) {
std::vector<OccupancyTracker::Segment> history;
- status_t result = mSurfaceFlingerConsumer->getOccupancyHistory(forceFlush, &history);
+ status_t result = mConsumer->getOccupancyHistory(forceFlush, &history);
if (result != NO_ERROR) {
ALOGW("[%s] Failed to obtain occupancy history (%d)", mName.string(), result);
return {};
@@ -349,16 +349,16 @@
}
bool BufferLayer::getTransformToDisplayInverse() const {
- return mSurfaceFlingerConsumer->getTransformToDisplayInverse();
+ return mConsumer->getTransformToDisplayInverse();
}
void BufferLayer::releasePendingBuffer(nsecs_t dequeueReadyTime) {
- if (!mSurfaceFlingerConsumer->releasePendingBuffer()) {
+ if (!mConsumer->releasePendingBuffer()) {
return;
}
auto releaseFenceTime =
- std::make_shared<FenceTime>(mSurfaceFlingerConsumer->getPrevFinalReleaseFence());
+ std::make_shared<FenceTime>(mConsumer->getPrevFinalReleaseFence());
mReleaseTimeline.updateSignalTimes();
mReleaseTimeline.push(releaseFenceTime);
@@ -374,7 +374,7 @@
if (android_atomic_acquire_cas(true, false, &mSidebandStreamChanged) == 0) {
// mSidebandStreamChanged was true
- mSidebandStream = mSurfaceFlingerConsumer->getSidebandStream();
+ mSidebandStream = mConsumer->getSidebandStream();
// replicated in LayerBE until FE/BE is ready to be synchronized
getBE().compositionInfo.hwc.sidebandStream = mSidebandStream;
if (getBE().compositionInfo.hwc.sidebandStream != NULL) {
@@ -427,7 +427,7 @@
getProducerStickyTransform() != 0, mName.string(),
mOverrideScalingMode, mFreezeGeometryUpdates);
status_t updateResult =
- mSurfaceFlingerConsumer->updateTexImage(&r, mFlinger->mPrimaryDispSync,
+ mConsumer->updateTexImage(&r, mFlinger->mPrimaryDispSync,
&mAutoRefresh, &queuedBuffer,
mLastFrameNumberReceived);
if (updateResult == BufferQueue::PRESENT_LATER) {
@@ -466,7 +466,7 @@
if (queuedBuffer) {
// Autolock scope
- auto currentFrameNumber = mSurfaceFlingerConsumer->getFrameNumber();
+ auto currentFrameNumber = mConsumer->getFrameNumber();
Mutex::Autolock lock(mQueueItemLock);
@@ -489,7 +489,7 @@
// update the active buffer
getBE().compositionInfo.mBuffer =
- mSurfaceFlingerConsumer->getCurrentBuffer(&getBE().compositionInfo.mBufferSlot);
+ mConsumer->getCurrentBuffer(&getBE().compositionInfo.mBufferSlot);
// replicated in LayerBE until FE/BE is ready to be synchronized
mActiveBuffer = getBE().compositionInfo.mBuffer;
if (getBE().compositionInfo.mBuffer == NULL) {
@@ -499,7 +499,7 @@
mBufferLatched = true;
mPreviousFrameNumber = mCurrentFrameNumber;
- mCurrentFrameNumber = mSurfaceFlingerConsumer->getFrameNumber();
+ mCurrentFrameNumber = mConsumer->getFrameNumber();
{
Mutex::Autolock lock(mFrameEventHistoryMutex);
@@ -514,11 +514,11 @@
recomputeVisibleRegions = true;
}
- setDataSpace(mSurfaceFlingerConsumer->getCurrentDataSpace());
+ setDataSpace(mConsumer->getCurrentDataSpace());
- Rect crop(mSurfaceFlingerConsumer->getCurrentCrop());
- const uint32_t transform(mSurfaceFlingerConsumer->getCurrentTransform());
- const uint32_t scalingMode(mSurfaceFlingerConsumer->getCurrentScalingMode());
+ Rect crop(mConsumer->getCurrentCrop());
+ const uint32_t transform(mConsumer->getCurrentTransform());
+ const uint32_t scalingMode(mConsumer->getCurrentScalingMode());
if ((crop != mCurrentCrop) ||
(transform != mCurrentTransform) ||
(scalingMode != mCurrentScalingMode)) {
@@ -573,7 +573,7 @@
}
void BufferLayer::setDefaultBufferSize(uint32_t w, uint32_t h) {
- mSurfaceFlingerConsumer->setDefaultBufferSize(w, h);
+ mConsumer->setDefaultBufferSize(w, h);
}
void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
@@ -633,7 +633,7 @@
hwcInfo.bufferCache.getHwcBuffer(getBE().compositionInfo.mBufferSlot,
getBE().compositionInfo.mBuffer, &hwcSlot, &hwcBuffer);
- auto acquireFence = mSurfaceFlingerConsumer->getCurrentFence();
+ auto acquireFence = mConsumer->getCurrentFence();
error = hwcLayer->setBuffer(hwcSlot, hwcBuffer, acquireFence);
if (error != HWC2::Error::None) {
ALOGE("[%s] Failed to set buffer %p: %s (%d)", mName.string(),
@@ -660,11 +660,11 @@
sp<IGraphicBufferConsumer> consumer;
BufferQueue::createBufferQueue(&producer, &consumer, true);
mProducer = new MonitoredProducer(producer, mFlinger, this);
- mSurfaceFlingerConsumer = new BufferLayerConsumer(consumer,
+ mConsumer = new BufferLayerConsumer(consumer,
mFlinger->getRenderEngine(), mTextureName, this);
- mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
- mSurfaceFlingerConsumer->setContentsChangedListener(this);
- mSurfaceFlingerConsumer->setName(mName);
+ mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
+ mConsumer->setContentsChangedListener(this);
+ mConsumer->setName(mName);
if (mFlinger->isLayerTripleBufferingDisabled()) {
mProducer->setMaxDequeuedBufferCount(2);
diff --git a/services/surfaceflinger/BufferLayer.h b/services/surfaceflinger/BufferLayer.h
index fbe6367..6b02f8c 100644
--- a/services/surfaceflinger/BufferLayer.h
+++ b/services/surfaceflinger/BufferLayer.h
@@ -170,7 +170,7 @@
sp<IGraphicBufferProducer> getProducer() const;
private:
- sp<BufferLayerConsumer> mSurfaceFlingerConsumer;
+ sp<BufferLayerConsumer> mConsumer;
// Check all of the local sync points to ensure that all transactions
// which need to have been applied prior to the frame which is about to
diff --git a/services/surfaceflinger/BufferLayerConsumer.cpp b/services/surfaceflinger/BufferLayerConsumer.cpp
index 16c3254..976dde2 100644
--- a/services/surfaceflinger/BufferLayerConsumer.cpp
+++ b/services/surfaceflinger/BufferLayerConsumer.cpp
@@ -292,19 +292,6 @@
int slot = item.mSlot;
- // Ensure we have a valid EglImageKHR for the slot, creating an EglImage
- // if nessessary, for the gralloc buffer currently in the slot in
- // ConsumerBase.
- // We may have to do this even when item.mGraphicBuffer == NULL (which
- // means the buffer was previously acquired).
- const Rect& imageCrop = canUseImageCrop(item.mCrop) ? item.mCrop : Rect::EMPTY_RECT;
- err = mImages[slot]->createIfNeeded(imageCrop);
- if (err != NO_ERROR) {
- BLC_LOGW("updateAndRelease: unable to createImage on slot=%d", slot);
- releaseBufferLocked(slot, mSlots[slot].mGraphicBuffer);
- return UNKNOWN_ERROR;
- }
-
// Do whatever sync ops we need to do before releasing the old slot.
if (slot != mCurrentTexture) {
err = syncForReleaseLocked();
@@ -392,12 +379,12 @@
if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
if (SyncFeatures::getInstance().useNativeFenceSync()) {
- int fenceFd = mRE.flush().release();
+ base::unique_fd fenceFd = mRE.flush();
if (fenceFd == -1) {
BLC_LOGE("syncForReleaseLocked: failed to flush RenderEngine");
return UNKNOWN_ERROR;
}
- sp<Fence> fence(new Fence(fenceFd));
+ sp<Fence> fence(new Fence(std::move(fenceFd)));
status_t err = addReleaseFenceLocked(mCurrentTexture,
mCurrentTextureImage->graphicBuffer(), fence);
if (err != OK) {