Merge "Consume events in dispatcher tests" into rvc-dev am: 0716947dcb am: e99402437c am: 53b43fd43a am: 95673d3b71

Change-Id: I7de6c62a3b9d9f3a6dfca9d9edfae29bd5ef58df
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 657409b..e9a16d4 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -2217,7 +2217,7 @@
 #if CRATE_DEBUG
     LOG(WARNING) << "retVector.size() =" << retVector.size();
     for (auto& item : retVector) {
-        CrateManager::dump(item);
+        CrateManager::dump(*item);
     }
 #endif
 
@@ -2249,7 +2249,7 @@
         if (cratedFolder == nullptr) {
             return;
         }
-        retVector->push_back(std::move(crateMetadata));
+        retVector.push_back(std::move(crateMetadata));
     };
 
     std::function<void(FTSENT*)> onHandingPackage = [&](FTSENT* packageDir) -> void {
@@ -2261,7 +2261,7 @@
 #if CRATE_DEBUG
     LOG(DEBUG) << "retVector.size() =" << retVector.size();
     for (auto& item : retVector) {
-        CrateManager::dump(item);
+        CrateManager::dump(*item);
     }
 #endif
 
diff --git a/cmds/installd/binder/android/os/IInstalld.aidl b/cmds/installd/binder/android/os/IInstalld.aidl
index e188807..5e5af73 100644
--- a/cmds/installd/binder/android/os/IInstalld.aidl
+++ b/cmds/installd/binder/android/os/IInstalld.aidl
@@ -114,10 +114,11 @@
             int userId, int snapshotId, int storageFlags);
     void restoreAppDataSnapshot(@nullable @utf8InCpp String uuid, in @utf8InCpp String packageName,
             int appId, @utf8InCpp String seInfo, int user, int snapshotId, int storageflags);
-    void destroyCeSnapshotsNotSpecified(@nullable @utf8InCpp String uuid, int userId,
-            in int[] retainSnapshotIds);
     void destroyAppDataSnapshot(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName,
             int userId, long ceSnapshotInode, int snapshotId, int storageFlags);
+    void destroyCeSnapshotsNotSpecified(@nullable @utf8InCpp String uuid, int userId,
+            in int[] retainSnapshotIds);
+
     void tryMountDataMirror(@nullable @utf8InCpp String volumeUuid);
     void onPrivateVolumeRemoved(@nullable @utf8InCpp String volumeUuid);
 
diff --git a/include/input/InputWindow.h b/include/input/InputWindow.h
index c44db51..717b7a6 100644
--- a/include/input/InputWindow.h
+++ b/include/input/InputWindow.h
@@ -37,23 +37,23 @@
     InputWindowInfo(const Parcel& from);
 
     // Window flags from WindowManager.LayoutParams
-    enum {
-        FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001,
-        FLAG_DIM_BEHIND        = 0x00000002,
-        FLAG_BLUR_BEHIND        = 0x00000004,
-        FLAG_NOT_FOCUSABLE      = 0x00000008,
-        FLAG_NOT_TOUCHABLE      = 0x00000010,
-        FLAG_NOT_TOUCH_MODAL    = 0x00000020,
+    enum : uint32_t {
+        FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001,
+        FLAG_DIM_BEHIND = 0x00000002,
+        FLAG_BLUR_BEHIND = 0x00000004,
+        FLAG_NOT_FOCUSABLE = 0x00000008,
+        FLAG_NOT_TOUCHABLE = 0x00000010,
+        FLAG_NOT_TOUCH_MODAL = 0x00000020,
         FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040,
-        FLAG_KEEP_SCREEN_ON     = 0x00000080,
-        FLAG_LAYOUT_IN_SCREEN   = 0x00000100,
-        FLAG_LAYOUT_NO_LIMITS   = 0x00000200,
-        FLAG_FULLSCREEN      = 0x00000400,
-        FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800,
-        FLAG_DITHER             = 0x00001000,
-        FLAG_SECURE             = 0x00002000,
-        FLAG_SCALED             = 0x00004000,
-        FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000,
+        FLAG_KEEP_SCREEN_ON = 0x00000080,
+        FLAG_LAYOUT_IN_SCREEN = 0x00000100,
+        FLAG_LAYOUT_NO_LIMITS = 0x00000200,
+        FLAG_FULLSCREEN = 0x00000400,
+        FLAG_FORCE_NOT_FULLSCREEN = 0x00000800,
+        FLAG_DITHER = 0x00001000,
+        FLAG_SECURE = 0x00002000,
+        FLAG_SCALED = 0x00004000,
+        FLAG_IGNORE_CHEEK_PRESSES = 0x00008000,
         FLAG_LAYOUT_INSET_DECOR = 0x00010000,
         FLAG_ALT_FOCUSABLE_IM = 0x00020000,
         FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000,
@@ -62,7 +62,14 @@
         FLAG_TURN_SCREEN_ON = 0x00200000,
         FLAG_DISMISS_KEYGUARD = 0x00400000,
         FLAG_SPLIT_TOUCH = 0x00800000,
+        FLAG_HARDWARE_ACCELERATED = 0x01000000,
+        FLAG_LAYOUT_IN_OVERSCAN = 0x02000000,
+        FLAG_TRANSLUCENT_STATUS = 0x04000000,
+        FLAG_TRANSLUCENT_NAVIGATION = 0x08000000,
+        FLAG_LOCAL_FOCUS_MODE = 0x10000000,
         FLAG_SLIPPERY = 0x20000000,
+        FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000,
+        FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000,
     };
 
     // Window types from WindowManager.LayoutParams
@@ -107,6 +114,7 @@
         TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27,
         TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32,
         TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34,
+        TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+39,
         LAST_SYSTEM_WINDOW      = 2999,
     };
 
@@ -190,6 +198,7 @@
     static InputWindowInfo read(const Parcel& from);
 };
 
+std::string inputWindowFlagsToString(uint32_t flags);
 
 /*
  * Handle for a window that can receive input.
diff --git a/include/powermanager/IPowerManager.h b/include/powermanager/IPowerManager.h
deleted file mode 100644
index 964e318..0000000
--- a/include/powermanager/IPowerManager.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 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_IPOWERMANAGER_H
-#define ANDROID_IPOWERMANAGER_H
-
-#include <utils/Errors.h>
-#include <binder/IInterface.h>
-#include <hardware/power.h>
-
-namespace android {
-
-// ----------------------------------------------------------------------------
-
-class IPowerManager : public IInterface
-{
-public:
-    // These transaction IDs must be kept in sync with the method order from
-    // IPowerManager.aidl.
-    enum {
-        ACQUIRE_WAKE_LOCK            = IBinder::FIRST_CALL_TRANSACTION,
-        ACQUIRE_WAKE_LOCK_UID        = IBinder::FIRST_CALL_TRANSACTION + 1,
-        RELEASE_WAKE_LOCK            = IBinder::FIRST_CALL_TRANSACTION + 2,
-        UPDATE_WAKE_LOCK_UIDS        = IBinder::FIRST_CALL_TRANSACTION + 3,
-        POWER_HINT                   = IBinder::FIRST_CALL_TRANSACTION + 4,
-        UPDATE_WAKE_LOCK_SOURCE      = IBinder::FIRST_CALL_TRANSACTION + 5,
-        IS_WAKE_LOCK_LEVEL_SUPPORTED = IBinder::FIRST_CALL_TRANSACTION + 6,
-        USER_ACTIVITY                = IBinder::FIRST_CALL_TRANSACTION + 7,
-        WAKE_UP                      = IBinder::FIRST_CALL_TRANSACTION + 8,
-        GO_TO_SLEEP                  = IBinder::FIRST_CALL_TRANSACTION + 9,
-        NAP                          = IBinder::FIRST_CALL_TRANSACTION + 10,
-        IS_INTERACTIVE               = IBinder::FIRST_CALL_TRANSACTION + 11,
-        IS_POWER_SAVE_MODE           = IBinder::FIRST_CALL_TRANSACTION + 12,
-        GET_POWER_SAVE_STATE         = IBinder::FIRST_CALL_TRANSACTION + 13,
-        SET_POWER_SAVE_MODE_ENABLED  = IBinder::FIRST_CALL_TRANSACTION + 14,
-        REBOOT                       = IBinder::FIRST_CALL_TRANSACTION + 21,
-        REBOOT_SAFE_MODE             = IBinder::FIRST_CALL_TRANSACTION + 22,
-        SHUTDOWN                     = IBinder::FIRST_CALL_TRANSACTION + 23,
-        CRASH                        = IBinder::FIRST_CALL_TRANSACTION + 24,
-    };
-
-    DECLARE_META_INTERFACE(PowerManager)
-
-    // The parcels created by these methods must be kept in sync with the
-    // corresponding methods from IPowerManager.aidl.
-    // FIXME remove the bool isOneWay parameters as they are not oneway in the .aidl
-    virtual status_t acquireWakeLock(int flags, const sp<IBinder>& lock, const String16& tag,
-            const String16& packageName, bool isOneWay = false) = 0;
-    virtual status_t acquireWakeLockWithUid(int flags, const sp<IBinder>& lock, const String16& tag,
-            const String16& packageName, int uid, bool isOneWay = false) = 0;
-    virtual status_t releaseWakeLock(const sp<IBinder>& lock, int flags, bool isOneWay = false) = 0;
-    virtual status_t updateWakeLockUids(const sp<IBinder>& lock, int len, const int *uids,
-            bool isOneWay = false) = 0;
-    virtual status_t powerHint(int hintId, int data) = 0;
-    virtual status_t goToSleep(int64_t event_time_ms, int reason, int flags) = 0;
-    virtual status_t reboot(bool confirm, const String16& reason, bool wait) = 0;
-    virtual status_t shutdown(bool confirm, const String16& reason, bool wait) = 0;
-    virtual status_t crash(const String16& message) = 0;
-};
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
-
-#endif // ANDROID_IPOWERMANAGER_H
diff --git a/libs/binder/fuzzer/binder.cpp b/libs/binder/fuzzer/binder.cpp
index 52c730c..8c0495c 100644
--- a/libs/binder/fuzzer/binder.cpp
+++ b/libs/binder/fuzzer/binder.cpp
@@ -135,6 +135,7 @@
 
     PARCEL_READ_WITH_STATUS(std::string, readUtf8FromUtf16),
     PARCEL_READ_WITH_STATUS(std::unique_ptr<std::string>, readUtf8FromUtf16),
+    PARCEL_READ_WITH_STATUS(std::optional<std::string>, readUtf8FromUtf16),
     [] (const ::android::Parcel& p, uint8_t /*data*/) {
         FUZZ_LOG() << "about to read c-str";
         const char* str = p.readCString();
@@ -143,6 +144,7 @@
     PARCEL_READ_OPT_STATUS(android::String8, readString8),
     PARCEL_READ_OPT_STATUS(android::String16, readString16),
     PARCEL_READ_WITH_STATUS(std::unique_ptr<android::String16>, readString16),
+    PARCEL_READ_WITH_STATUS(std::optional<android::String16>, readString16),
     [] (const ::android::Parcel& p, uint8_t /*data*/) {
         FUZZ_LOG() << "about to readString16Inplace";
         size_t outLen = 0;
@@ -156,17 +158,22 @@
     // TODO(b/131868573): can force read of arbitrarily sized vector
     // PARCEL_READ_WITH_STATUS(std::vector<ByteEnum>, readEnumVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<ByteEnum>>, readEnumVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<ByteEnum>>, readEnumVector),
     // PARCEL_READ_WITH_STATUS(std::vector<IntEnum>, readEnumVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<IntEnum>>, readEnumVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<IntEnum>>, readEnumVector),
     // PARCEL_READ_WITH_STATUS(std::vector<LongEnum>, readEnumVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<LongEnum>>, readEnumVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<LongEnum>>, readEnumVector),
 
     // only reading one parcelable type for now
     // TODO(b/131868573): can force read of arbitrarily sized vector
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<std::unique_ptr<ExampleParcelable>>>, readParcelableVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<std::optional<ExampleParcelable>>>, readParcelableVector),
     // PARCEL_READ_WITH_STATUS(std::vector<ExampleParcelable>, readParcelableVector),
     PARCEL_READ_WITH_STATUS(ExampleParcelable, readParcelable),
     PARCEL_READ_WITH_STATUS(std::unique_ptr<ExampleParcelable>, readParcelable),
+    PARCEL_READ_WITH_STATUS(std::optional<ExampleParcelable>, readParcelable),
 
     // only reading one binder type for now
     PARCEL_READ_WITH_STATUS(android::sp<android::os::IServiceManager>, readStrongBinder),
@@ -174,30 +181,42 @@
 
     // TODO(b/131868573): can force read of arbitrarily sized vector
     // PARCEL_READ_WITH_STATUS(::std::unique_ptr<std::vector<android::sp<android::IBinder>>>, readStrongBinderVector),
+    // PARCEL_READ_WITH_STATUS(::std::optional<std::vector<android::sp<android::IBinder>>>, readStrongBinderVector),
     // PARCEL_READ_WITH_STATUS(std::vector<android::sp<android::IBinder>>, readStrongBinderVector),
 
     // TODO(b/131868573): can force read of arbitrarily sized vector
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<int8_t>>, readByteVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<int8_t>>, readByteVector),
     // PARCEL_READ_WITH_STATUS(std::vector<int8_t>, readByteVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<uint8_t>>, readByteVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<uint8_t>>, readByteVector),
     // PARCEL_READ_WITH_STATUS(std::vector<uint8_t>, readByteVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<int32_t>>, readInt32Vector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<int32_t>>, readInt32Vector),
     // PARCEL_READ_WITH_STATUS(std::vector<int32_t>, readInt32Vector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<int64_t>>, readInt64Vector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<int64_t>>, readInt64Vector),
     // PARCEL_READ_WITH_STATUS(std::vector<int64_t>, readInt64Vector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<uint64_t>>, readUint64Vector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<uint64_t>>, readUint64Vector),
     // PARCEL_READ_WITH_STATUS(std::vector<uint64_t>, readUint64Vector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<float>>, readFloatVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<float>>, readFloatVector),
     // PARCEL_READ_WITH_STATUS(std::vector<float>, readFloatVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<double>>, readDoubleVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<double>>, readDoubleVector),
     // PARCEL_READ_WITH_STATUS(std::vector<double>, readDoubleVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<bool>>, readBoolVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<bool>>, readBoolVector),
     // PARCEL_READ_WITH_STATUS(std::vector<bool>, readBoolVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<char16_t>>, readCharVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<char16_t>>, readCharVector),
     // PARCEL_READ_WITH_STATUS(std::vector<char16_t>, readCharVector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<std::unique_ptr<android::String16>>>, readString16Vector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<std::optional<android::String16>>>, readString16Vector),
     // PARCEL_READ_WITH_STATUS(std::vector<android::String16>, readString16Vector),
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<std::unique_ptr<std::string>>>, readUtf8VectorFromUtf16Vector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<std::optional<std::string>>>, readUtf8VectorFromUtf16Vector),
     // PARCEL_READ_WITH_STATUS(std::vector<std::string>, readUtf8VectorFromUtf16Vector),
 
     [] (const android::Parcel& p, uint8_t /*len*/) {
@@ -234,6 +253,7 @@
 
     // TODO(b/131868573): can force read of arbitrarily sized vector
     // PARCEL_READ_WITH_STATUS(std::unique_ptr<std::vector<android::base::unique_fd>>, readUniqueFileDescriptorVector),
+    // PARCEL_READ_WITH_STATUS(std::optional<std::vector<android::base::unique_fd>>, readUniqueFileDescriptorVector),
     // PARCEL_READ_WITH_STATUS(std::vector<android::base::unique_fd>, readUniqueFileDescriptorVector),
 
     [] (const android::Parcel& p, uint8_t len) {
diff --git a/libs/graphicsenv/GraphicsEnv.cpp b/libs/graphicsenv/GraphicsEnv.cpp
index 4809c1f..e49fb08 100644
--- a/libs/graphicsenv/GraphicsEnv.cpp
+++ b/libs/graphicsenv/GraphicsEnv.cpp
@@ -29,7 +29,6 @@
 #include <android-base/strings.h>
 #include <android/dlext.h>
 #include <binder/IServiceManager.h>
-#include <cutils/properties.h>
 #include <graphicsenv/IGpuService.h>
 #include <log/log.h>
 #include <nativeloader/dlext_namespaces.h>
@@ -67,7 +66,7 @@
 
 static std::string vndkVersionStr() {
 #ifdef __BIONIC__
-    return android::base::GetProperty("ro.vndk.version", "");
+    return base::GetProperty("ro.vndk.version", "");
 #endif
     return "";
 }
@@ -338,10 +337,8 @@
 }
 
 bool GraphicsEnv::checkAngleRules(void* so) {
-    char manufacturer[PROPERTY_VALUE_MAX];
-    char model[PROPERTY_VALUE_MAX];
-    property_get("ro.product.manufacturer", manufacturer, "UNSET");
-    property_get("ro.product.model", model, "UNSET");
+    auto manufacturer = base::GetProperty("ro.product.manufacturer", "UNSET");
+    auto model = base::GetProperty("ro.product.model", "UNSET");
 
     auto ANGLEGetFeatureSupportUtilAPIVersion =
             (fpANGLEGetFeatureSupportUtilAPIVersion)dlsym(so,
@@ -394,7 +391,8 @@
                 ALOGW("ANGLE feature-support library cannot obtain SystemInfo");
                 break;
             }
-            if (!(ANGLEAddDeviceInfoToSystemInfo)(manufacturer, model, systemInfoHandle)) {
+            if (!(ANGLEAddDeviceInfoToSystemInfo)(manufacturer.c_str(), model.c_str(),
+                                                  systemInfoHandle)) {
                 ALOGW("ANGLE feature-support library cannot add device info to SystemInfo");
                 break;
             }
diff --git a/libs/gui/BufferHubProducer.cpp b/libs/gui/BufferHubProducer.cpp
index 4be014f..489f3c3 100644
--- a/libs/gui/BufferHubProducer.cpp
+++ b/libs/gui/BufferHubProducer.cpp
@@ -19,7 +19,6 @@
 #include <inttypes.h>
 #include <log/log.h>
 #include <system/window.h>
-#include <ui/BufferHubBuffer.h>
 
 namespace android {
 
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index bd4d62c..e43af67 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -371,10 +371,8 @@
         data.writeStrongBinder(display);
         remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
         const status_t result = reply.readInt32();
-        if (result == NO_ERROR) {
-            memcpy(info, reply.readInplace(sizeof(DisplayInfo)), sizeof(DisplayInfo));
-        }
-        return result;
+        if (result != NO_ERROR) return result;
+        return reply.read(*info);
     }
 
     virtual status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayConfig>* configs) {
@@ -1412,10 +1410,8 @@
             const sp<IBinder> display = data.readStrongBinder();
             const status_t result = getDisplayInfo(display, &info);
             reply->writeInt32(result);
-            if (result == NO_ERROR) {
-                memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo));
-            }
-            return NO_ERROR;
+            if (result != NO_ERROR) return result;
+            return reply->write(info);
         }
         case GET_DISPLAY_CONFIGS: {
             CHECK_INTERFACE(ISurfaceComposer, data, reply);
diff --git a/libs/input/InputWindow.cpp b/libs/input/InputWindow.cpp
index 03ca459..99b718b 100644
--- a/libs/input/InputWindow.cpp
+++ b/libs/input/InputWindow.cpp
@@ -17,9 +17,10 @@
 #define LOG_TAG "InputWindow"
 #define LOG_NDEBUG 0
 
+#include <android-base/stringprintf.h>
 #include <binder/Parcel.h>
-#include <input/InputWindow.h>
 #include <input/InputTransport.h>
+#include <input/InputWindow.h>
 
 #include <log/log.h>
 
@@ -28,6 +29,118 @@
 
 namespace android {
 
+const char* inputWindowFlagToString(uint32_t flag) {
+    switch (flag) {
+        case InputWindowInfo::FLAG_ALLOW_LOCK_WHILE_SCREEN_ON: {
+            return "ALLOW_LOCK_WHILE_SCREEN_ON";
+        }
+        case InputWindowInfo::FLAG_DIM_BEHIND: {
+            return "DIM_BEHIND";
+        }
+        case InputWindowInfo::FLAG_BLUR_BEHIND: {
+            return "BLUR_BEHIND";
+        }
+        case InputWindowInfo::FLAG_NOT_FOCUSABLE: {
+            return "NOT_FOCUSABLE";
+        }
+        case InputWindowInfo::FLAG_NOT_TOUCHABLE: {
+            return "NOT_TOUCHABLE";
+        }
+        case InputWindowInfo::FLAG_NOT_TOUCH_MODAL: {
+            return "NOT_TOUCH_MODAL";
+        }
+        case InputWindowInfo::FLAG_TOUCHABLE_WHEN_WAKING: {
+            return "TOUCHABLE_WHEN_WAKING";
+        }
+        case InputWindowInfo::FLAG_KEEP_SCREEN_ON: {
+            return "KEEP_SCREEN_ON";
+        }
+        case InputWindowInfo::FLAG_LAYOUT_IN_SCREEN: {
+            return "LAYOUT_IN_SCREEN";
+        }
+        case InputWindowInfo::FLAG_LAYOUT_NO_LIMITS: {
+            return "LAYOUT_NO_LIMITS";
+        }
+        case InputWindowInfo::FLAG_FULLSCREEN: {
+            return "FULLSCREEN";
+        }
+        case InputWindowInfo::FLAG_FORCE_NOT_FULLSCREEN: {
+            return "FORCE_NOT_FULLSCREEN";
+        }
+        case InputWindowInfo::FLAG_DITHER: {
+            return "DITHER";
+        }
+        case InputWindowInfo::FLAG_SECURE: {
+            return "SECURE";
+        }
+        case InputWindowInfo::FLAG_SCALED: {
+            return "SCALED";
+        }
+        case InputWindowInfo::FLAG_IGNORE_CHEEK_PRESSES: {
+            return "IGNORE_CHEEK_PRESSES";
+        }
+        case InputWindowInfo::FLAG_LAYOUT_INSET_DECOR: {
+            return "LAYOUT_INSET_DECOR";
+        }
+        case InputWindowInfo::FLAG_ALT_FOCUSABLE_IM: {
+            return "ALT_FOCUSABLE_IM";
+        }
+        case InputWindowInfo::FLAG_WATCH_OUTSIDE_TOUCH: {
+            return "WATCH_OUTSIDE_TOUCH";
+        }
+        case InputWindowInfo::FLAG_SHOW_WHEN_LOCKED: {
+            return "SHOW_WHEN_LOCKED";
+        }
+        case InputWindowInfo::FLAG_SHOW_WALLPAPER: {
+            return "SHOW_WALLPAPER";
+        }
+        case InputWindowInfo::FLAG_TURN_SCREEN_ON: {
+            return "TURN_SCREEN_ON";
+        }
+        case InputWindowInfo::FLAG_DISMISS_KEYGUARD: {
+            return "DISMISS_KEYGUARD";
+        }
+        case InputWindowInfo::FLAG_SPLIT_TOUCH: {
+            return "SPLIT_TOUCH";
+        }
+        case InputWindowInfo::FLAG_HARDWARE_ACCELERATED: {
+            return "HARDWARE_ACCELERATED";
+        }
+        case InputWindowInfo::FLAG_LAYOUT_IN_OVERSCAN: {
+            return "LAYOUT_IN_OVERSCAN";
+        }
+        case InputWindowInfo::FLAG_TRANSLUCENT_STATUS: {
+            return "TRANSLUCENT_STATUS";
+        }
+        case InputWindowInfo::FLAG_TRANSLUCENT_NAVIGATION: {
+            return "TRANSLUCENT_NAVIGATION";
+        }
+        case InputWindowInfo::FLAG_LOCAL_FOCUS_MODE: {
+            return "LOCAL_FOCUS_MODE";
+        }
+        case InputWindowInfo::FLAG_SLIPPERY: {
+            return "SLIPPERY";
+        }
+        case InputWindowInfo::FLAG_LAYOUT_ATTACHED_IN_DECOR: {
+            return "LAYOUT_ATTACHED_IN_DECOR";
+        }
+        case InputWindowInfo::FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS: {
+            return "DRAWS_SYSTEM_BAR_BACKGROUNDS";
+        }
+    }
+    return "UNKNOWN";
+}
+
+std::string inputWindowFlagsToString(uint32_t flags) {
+    std::string result;
+    for (BitSet32 bits(flags); !bits.isEmpty();) {
+        uint32_t bit = bits.clearLastMarkedBit(); // counts from left
+        const uint32_t flag = 1 << (32 - bit - 1);
+        result += android::base::StringPrintf("%s | ", inputWindowFlagToString(flag));
+    }
+    return result;
+}
+
 // --- InputWindowInfo ---
 void InputWindowInfo::addTouchableRegion(const Rect& region) {
     touchableRegion.orSelf(region);
@@ -43,7 +156,8 @@
 }
 
 bool InputWindowInfo::isTrustedOverlay() const {
-    return layoutParamsType == TYPE_INPUT_METHOD
+    return layoutParamsType == TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY
+            || layoutParamsType == TYPE_INPUT_METHOD
             || layoutParamsType == TYPE_INPUT_METHOD_DIALOG
             || layoutParamsType == TYPE_MAGNIFICATION_OVERLAY
             || layoutParamsType == TYPE_STATUS_BAR
diff --git a/libs/math/Android.bp b/libs/math/Android.bp
index 693bace..8e903e3 100644
--- a/libs/math/Android.bp
+++ b/libs/math/Android.bp
@@ -17,6 +17,11 @@
     host_supported: true,
     vendor_available: true,
     export_include_dirs: ["include"],
+    target:  {
+        windows: {
+            enabled: true,
+        }
+    }
 }
 
 subdirs = ["tests"]
diff --git a/libs/renderengine/gl/GLESRenderEngine.cpp b/libs/renderengine/gl/GLESRenderEngine.cpp
index 36a54a7..da87092 100644
--- a/libs/renderengine/gl/GLESRenderEngine.cpp
+++ b/libs/renderengine/gl/GLESRenderEngine.cpp
@@ -980,7 +980,7 @@
 
 status_t GLESRenderEngine::drawLayers(const DisplaySettings& display,
                                       const std::vector<const LayerSettings*>& layers,
-                                      ANativeWindowBuffer* const buffer,
+                                      const sp<GraphicBuffer>& buffer,
                                       const bool useFramebufferCache, base::unique_fd&& bufferFence,
                                       base::unique_fd* drawFence) {
     ATRACE_CALL();
@@ -1017,7 +1017,9 @@
     const auto blurLayersSize = blurLayers.size();
 
     if (blurLayersSize == 0) {
-        fbo = std::make_unique<BindNativeBufferAsFramebuffer>(*this, buffer, useFramebufferCache);
+        fbo = std::make_unique<BindNativeBufferAsFramebuffer>(*this,
+                                                              buffer.get()->getNativeBuffer(),
+                                                              useFramebufferCache);
         if (fbo->getStatus() != NO_ERROR) {
             ALOGE("Failed to bind framebuffer! Aborting GPU composition for buffer (%p).",
                   buffer->handle);
@@ -1074,7 +1076,9 @@
 
             if (blurLayers.size() == 0) {
                 // Done blurring, time to bind the native FBO and render our blur onto it.
-                fbo = std::make_unique<BindNativeBufferAsFramebuffer>(*this, buffer,
+                fbo = std::make_unique<BindNativeBufferAsFramebuffer>(*this,
+                                                                      buffer.get()
+                                                                              ->getNativeBuffer(),
                                                                       useFramebufferCache);
                 status = fbo->getStatus();
                 setViewportAndProjection(display.physicalDisplay, display.clip);
diff --git a/libs/renderengine/gl/GLESRenderEngine.h b/libs/renderengine/gl/GLESRenderEngine.h
index 32dbad1..d3c94a6 100644
--- a/libs/renderengine/gl/GLESRenderEngine.h
+++ b/libs/renderengine/gl/GLESRenderEngine.h
@@ -74,7 +74,7 @@
     bool useProtectedContext(bool useProtectedContext) override;
     status_t drawLayers(const DisplaySettings& display,
                         const std::vector<const LayerSettings*>& layers,
-                        ANativeWindowBuffer* buffer, const bool useFramebufferCache,
+                        const sp<GraphicBuffer>& buffer, const bool useFramebufferCache,
                         base::unique_fd&& bufferFence, base::unique_fd* drawFence) override;
 
     EGLDisplay getEGLDisplay() const { return mEGLDisplay; }
diff --git a/libs/renderengine/include/renderengine/RenderEngine.h b/libs/renderengine/include/renderengine/RenderEngine.h
index 46f3fc6..4983cb3 100644
--- a/libs/renderengine/include/renderengine/RenderEngine.h
+++ b/libs/renderengine/include/renderengine/RenderEngine.h
@@ -155,7 +155,7 @@
     // now, this always returns NO_ERROR.
     virtual status_t drawLayers(const DisplaySettings& display,
                                 const std::vector<const LayerSettings*>& layers,
-                                ANativeWindowBuffer* buffer, const bool useFramebufferCache,
+                                const sp<GraphicBuffer>& buffer, const bool useFramebufferCache,
                                 base::unique_fd&& bufferFence, base::unique_fd* drawFence) = 0;
 
 protected:
diff --git a/libs/renderengine/include/renderengine/mock/RenderEngine.h b/libs/renderengine/include/renderengine/mock/RenderEngine.h
index 3358c69..7f20c8c 100644
--- a/libs/renderengine/include/renderengine/mock/RenderEngine.h
+++ b/libs/renderengine/include/renderengine/mock/RenderEngine.h
@@ -57,7 +57,8 @@
     MOCK_METHOD1(useProtectedContext, bool(bool));
     MOCK_METHOD6(drawLayers,
                  status_t(const DisplaySettings&, const std::vector<const LayerSettings*>&,
-                          ANativeWindowBuffer*, const bool, base::unique_fd&&, base::unique_fd*));
+                          const sp<GraphicBuffer>&, const bool, base::unique_fd&&,
+                          base::unique_fd*));
 };
 
 } // namespace mock
diff --git a/libs/renderengine/tests/RenderEngineTest.cpp b/libs/renderengine/tests/RenderEngineTest.cpp
index f5bf014..2bf456b 100644
--- a/libs/renderengine/tests/RenderEngineTest.cpp
+++ b/libs/renderengine/tests/RenderEngineTest.cpp
@@ -252,8 +252,8 @@
                     std::vector<const renderengine::LayerSettings*> layers,
                     sp<GraphicBuffer> buffer) {
         base::unique_fd fence;
-        status_t status = sRE->drawLayers(settings, layers, buffer->getNativeBuffer(), true,
-                                          base::unique_fd(), &fence);
+        status_t status =
+                sRE->drawLayers(settings, layers, buffer, true, base::unique_fd(), &fence);
         sCurrentBuffer = buffer;
 
         int fd = fence.release();
@@ -1004,8 +1004,7 @@
     layer.alpha = 1.0;
     layers.push_back(&layer);
 
-    status_t status = sRE->drawLayers(settings, layers, mBuffer->getNativeBuffer(), true,
-                                      base::unique_fd(), nullptr);
+    status_t status = sRE->drawLayers(settings, layers, mBuffer, true, base::unique_fd(), nullptr);
     sCurrentBuffer = mBuffer;
     ASSERT_EQ(NO_ERROR, status);
     expectBufferColor(fullscreenRect(), 255, 0, 0, 255);
@@ -1023,8 +1022,7 @@
     layer.alpha = 1.0;
     layers.push_back(&layer);
 
-    status_t status = sRE->drawLayers(settings, layers, mBuffer->getNativeBuffer(), false,
-                                      base::unique_fd(), nullptr);
+    status_t status = sRE->drawLayers(settings, layers, mBuffer, false, base::unique_fd(), nullptr);
     sCurrentBuffer = mBuffer;
     ASSERT_EQ(NO_ERROR, status);
     ASSERT_FALSE(sRE->isFramebufferImageCachedForTesting(mBuffer->getId()));
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
index ba6255d..b68604d 100644
--- a/libs/ui/Android.bp
+++ b/libs/ui/Android.bp
@@ -12,6 +12,64 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+cc_defaults {
+    name: "libui-defaults",
+    clang: true,
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    cppflags: [
+        "-Wextra",
+    ],
+
+    sanitize: {
+        integer_overflow: true,
+        misc_undefined: ["bounds"],
+    },
+
+}
+
+cc_library_static {
+    name: "libui-types",
+    vendor_available: true,
+    host_supported: true,
+    target: {
+        windows: {
+            enabled: true,
+        }
+    },
+
+    defaults: [
+        "libui-defaults",
+    ],
+
+    apex_available: [
+        "//apex_available:anyapex",
+        "//apex_available:platform",
+    ],
+    shared_libs: [
+        "libutils",
+    ],
+
+    static_libs: [
+        "libmath",
+    ],
+
+    srcs: [
+        "ColorSpace.cpp",
+    ],
+
+    export_include_dirs: [
+        "include_types",
+    ],
+
+    export_static_lib_headers: [
+        "libmath",
+    ],
+
+}
+
 cc_library_shared {
     name: "libui",
     vendor_available: true,
@@ -35,11 +93,9 @@
     },
 
     srcs: [
-        "ColorSpace.cpp",
-        "BufferHubBuffer.cpp",
-        "BufferHubEventFd.cpp",
-        "BufferHubMetadata.cpp",
         "DebugUtils.cpp",
+        "DeviceProductInfo.cpp",
+        "DisplayInfo.cpp",
         "Fence.cpp",
         "FenceTime.cpp",
         "FrameStats.cpp",
@@ -68,11 +124,13 @@
         "include_private",
     ],
 
-    // Uncomment the following line to enable VALIDATE_REGIONS traces
-    //defaults: ["libui-validate-regions-defaults"],
+    defaults: [
+        "libui-defaults",
+        // Uncomment the following line to enable VALIDATE_REGIONS traces
+        //defaults: ["libui-validate-regions-defaults"],
+    ],
 
     shared_libs: [
-        "android.frameworks.bufferhub@1.0",
         "android.hardware.graphics.allocator@2.0",
         "android.hardware.graphics.allocator@3.0",
         "android.hardware.graphics.allocator@4.0",
@@ -104,35 +162,29 @@
         "libmath",
     ],
 
+    whole_static_libs: [
+        "libui-types",
+    ],
+
     // bufferhub is not used when building libgui for vendors
     target: {
         vendor: {
             cflags: ["-DLIBUI_IN_VNDK"],
             exclude_srcs: [
-                "BufferHubBuffer.cpp",
-                "BufferHubEventFd.cpp",
-                "BufferHubMetadata.cpp",
             ],
             exclude_header_libs: [
-                "libbufferhub_headers",
-                "libdvr_headers",
             ],
             exclude_shared_libs: [
-                "android.frameworks.bufferhub@1.0",
-                "libpdx_default_transport",
             ],
         },
     },
 
     header_libs: [
         "libbase_headers",
-        "libbufferhub_headers",
-        "libdvr_headers",
         "libnativebase_headers",
         "libnativewindow_headers",
         "libhardware_headers",
         "libui_headers",
-        "libpdx_headers",
     ],
 
     export_static_lib_headers: [
diff --git a/libs/ui/BufferHubBuffer.cpp b/libs/ui/BufferHubBuffer.cpp
deleted file mode 100644
index 1dfc1e9..0000000
--- a/libs/ui/BufferHubBuffer.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright (C) 2018 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 "BufferHubBuffer"
-#include <poll.h>
-
-#include <android-base/unique_fd.h>
-#include <android/frameworks/bufferhub/1.0/IBufferHub.h>
-#include <log/log.h>
-#include <ui/BufferHubBuffer.h>
-#include <ui/BufferHubDefs.h>
-#include <utils/Trace.h>
-
-using ::android::base::unique_fd;
-using ::android::BufferHubDefs::isAnyClientAcquired;
-using ::android::BufferHubDefs::isAnyClientGained;
-using ::android::BufferHubDefs::isClientAcquired;
-using ::android::BufferHubDefs::isClientGained;
-using ::android::BufferHubDefs::isClientPosted;
-using ::android::BufferHubDefs::isClientReleased;
-using ::android::frameworks::bufferhub::V1_0::BufferHubStatus;
-using ::android::frameworks::bufferhub::V1_0::BufferTraits;
-using ::android::frameworks::bufferhub::V1_0::IBufferClient;
-using ::android::frameworks::bufferhub::V1_0::IBufferHub;
-using ::android::hardware::hidl_handle;
-using ::android::hardware::graphics::common::V1_2::HardwareBufferDescription;
-
-namespace android {
-
-std::unique_ptr<BufferHubBuffer> BufferHubBuffer::create(uint32_t width, uint32_t height,
-                                                         uint32_t layerCount, uint32_t format,
-                                                         uint64_t usage, size_t userMetadataSize) {
-    auto buffer = std::unique_ptr<BufferHubBuffer>(
-            new BufferHubBuffer(width, height, layerCount, format, usage, userMetadataSize));
-    return buffer->isValid() ? std::move(buffer) : nullptr;
-}
-
-std::unique_ptr<BufferHubBuffer> BufferHubBuffer::import(const sp<NativeHandle>& token) {
-    if (token == nullptr || token.get() == nullptr) {
-        ALOGE("%s: token cannot be nullptr!", __FUNCTION__);
-        return nullptr;
-    }
-
-    auto buffer = std::unique_ptr<BufferHubBuffer>(new BufferHubBuffer(token));
-    return buffer->isValid() ? std::move(buffer) : nullptr;
-}
-
-BufferHubBuffer::BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layerCount,
-                                 uint32_t format, uint64_t usage, size_t userMetadataSize) {
-    ATRACE_CALL();
-    ALOGD("%s: width=%u height=%u layerCount=%u, format=%u "
-          "usage=%" PRIx64 " mUserMetadataSize=%zu",
-          __FUNCTION__, width, height, layerCount, format, usage, userMetadataSize);
-
-    sp<IBufferHub> bufferhub = IBufferHub::getService();
-    if (bufferhub.get() == nullptr) {
-        ALOGE("%s: BufferHub service not found!", __FUNCTION__);
-        return;
-    }
-
-    AHardwareBuffer_Desc aDesc = {width, height,         layerCount,   format,
-                                  usage, /*stride=*/0UL, /*rfu0=*/0UL, /*rfu1=*/0ULL};
-    HardwareBufferDescription desc;
-    memcpy(&desc, &aDesc, sizeof(HardwareBufferDescription));
-
-    BufferHubStatus ret;
-    sp<IBufferClient> client;
-    BufferTraits bufferTraits;
-    IBufferHub::allocateBuffer_cb allocCb = [&](const auto& status, const auto& outClient,
-                                                const auto& outTraits) {
-        ret = status;
-        client = std::move(outClient);
-        bufferTraits = std::move(outTraits);
-    };
-
-    if (!bufferhub->allocateBuffer(desc, static_cast<uint32_t>(userMetadataSize), allocCb).isOk()) {
-        ALOGE("%s: allocateBuffer transaction failed!", __FUNCTION__);
-        return;
-    } else if (ret != BufferHubStatus::NO_ERROR) {
-        ALOGE("%s: allocateBuffer failed with error %u.", __FUNCTION__, ret);
-        return;
-    } else if (client == nullptr) {
-        ALOGE("%s: allocateBuffer got null BufferClient.", __FUNCTION__);
-        return;
-    }
-
-    const int importRet = initWithBufferTraits(bufferTraits);
-    if (importRet < 0) {
-        ALOGE("%s: Failed to import buffer: %s", __FUNCTION__, strerror(-importRet));
-        client->close();
-    }
-    mBufferClient = std::move(client);
-}
-
-BufferHubBuffer::BufferHubBuffer(const sp<NativeHandle>& token) {
-    sp<IBufferHub> bufferhub = IBufferHub::getService();
-    if (bufferhub.get() == nullptr) {
-        ALOGE("%s: BufferHub service not found!", __FUNCTION__);
-        return;
-    }
-
-    BufferHubStatus ret;
-    sp<IBufferClient> client;
-    BufferTraits bufferTraits;
-    IBufferHub::importBuffer_cb importCb = [&](const auto& status, const auto& outClient,
-                                               const auto& outTraits) {
-        ret = status;
-        client = std::move(outClient);
-        bufferTraits = std::move(outTraits);
-    };
-
-    // hidl_handle(native_handle_t*) simply creates a raw pointer reference withouth ownership
-    // transfer.
-    if (!bufferhub->importBuffer(hidl_handle(token.get()->handle()), importCb).isOk()) {
-        ALOGE("%s: importBuffer transaction failed!", __FUNCTION__);
-        return;
-    } else if (ret != BufferHubStatus::NO_ERROR) {
-        ALOGE("%s: importBuffer failed with error %u.", __FUNCTION__, ret);
-        return;
-    } else if (client == nullptr) {
-        ALOGE("%s: importBuffer got null BufferClient.", __FUNCTION__);
-        return;
-    }
-
-    const int importRet = initWithBufferTraits(bufferTraits);
-    if (importRet < 0) {
-        ALOGE("%s: Failed to import buffer: %s", __FUNCTION__, strerror(-importRet));
-        client->close();
-    }
-    mBufferClient = std::move(client);
-}
-
-BufferHubBuffer::~BufferHubBuffer() {
-    // Close buffer client to avoid possible race condition: user could first duplicate and hold
-    // token with the original buffer gone, and then try to import the token. The close function
-    // will explicitly invalidate the token to avoid this.
-    if (mBufferClient != nullptr) {
-        if (!mBufferClient->close().isOk()) {
-            ALOGE("%s: close BufferClient transaction failed!", __FUNCTION__);
-        }
-    }
-}
-
-int BufferHubBuffer::initWithBufferTraits(const BufferTraits& bufferTraits) {
-    ATRACE_CALL();
-
-    if (bufferTraits.bufferInfo.getNativeHandle() == nullptr) {
-        ALOGE("%s: missing buffer info handle.", __FUNCTION__);
-        return -EINVAL;
-    }
-
-    if (bufferTraits.bufferHandle.getNativeHandle() == nullptr) {
-        ALOGE("%s: missing gralloc handle.", __FUNCTION__);
-        return -EINVAL;
-    }
-
-    // Import fds. Dup fds because hidl_handle owns the fds.
-    unique_fd ashmemFd(fcntl(bufferTraits.bufferInfo->data[0], F_DUPFD_CLOEXEC, 0));
-    mMetadata = BufferHubMetadata::import(std::move(ashmemFd));
-    if (!mMetadata.isValid()) {
-        ALOGE("%s: Received an invalid metadata.", __FUNCTION__);
-        return -EINVAL;
-    }
-
-    mEventFd = BufferHubEventFd(fcntl(bufferTraits.bufferInfo->data[1], F_DUPFD_CLOEXEC, 0));
-    if (!mEventFd.isValid()) {
-        ALOGE("%s: Received ad invalid event fd.", __FUNCTION__);
-        return -EINVAL;
-    }
-
-    int bufferId = bufferTraits.bufferInfo->data[2];
-    if (bufferId < 0) {
-        ALOGE("%s: Received an invalid (negative) id.", __FUNCTION__);
-        return -EINVAL;
-    }
-
-    uint32_t clientBitMask;
-    memcpy(&clientBitMask, &bufferTraits.bufferInfo->data[3], sizeof(clientBitMask));
-    if (clientBitMask == 0U) {
-        ALOGE("%s: Received an invalid client state mask.", __FUNCTION__);
-        return -EINVAL;
-    }
-
-    uint32_t userMetadataSize;
-    memcpy(&userMetadataSize, &bufferTraits.bufferInfo->data[4], sizeof(userMetadataSize));
-    if (mMetadata.userMetadataSize() != userMetadataSize) {
-        ALOGE("%s: user metadata size not match: expected %u, actual %zu.", __FUNCTION__,
-              userMetadataSize, mMetadata.userMetadataSize());
-        return -EINVAL;
-    }
-
-    size_t metadataSize = static_cast<size_t>(mMetadata.metadataSize());
-    if (metadataSize < BufferHubDefs::kMetadataHeaderSize) {
-        ALOGE("%s: metadata too small: %zu", __FUNCTION__, metadataSize);
-        return -EINVAL;
-    }
-
-    // Populate shortcuts to the atomics in metadata.
-    auto metadataHeader = mMetadata.metadataHeader();
-    mBufferState = &metadataHeader->bufferState;
-    mFenceState = &metadataHeader->fenceState;
-    mActiveClientsBitMask = &metadataHeader->activeClientsBitMask;
-    // The C++ standard recommends (but does not require) that lock-free atomic operations are
-    // also address-free, that is, suitable for communication between processes using shared
-    // memory.
-    LOG_ALWAYS_FATAL_IF(!std::atomic_is_lock_free(mBufferState) ||
-                                !std::atomic_is_lock_free(mFenceState) ||
-                                !std::atomic_is_lock_free(mActiveClientsBitMask),
-                        "Atomic variables in ashmen are not lock free.");
-
-    // Import the buffer: We only need to hold on the native_handle_t here so that
-    // GraphicBuffer instance can be created in future.
-    mBufferHandle = std::move(bufferTraits.bufferHandle);
-    memcpy(&mBufferDesc, &bufferTraits.bufferDesc, sizeof(AHardwareBuffer_Desc));
-
-    mId = bufferId;
-    mClientStateMask = clientBitMask;
-
-    // TODO(b/112012161) Set up shared fences.
-    ALOGD("%s: id=%d, mBufferState=%" PRIx32 ".", __FUNCTION__, mId,
-          mBufferState->load(std::memory_order_acquire));
-    return 0;
-}
-
-int BufferHubBuffer::gain() {
-    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
-    if (isClientGained(currentBufferState, mClientStateMask)) {
-        ALOGV("%s: Buffer is already gained by this client %" PRIx32 ".", __FUNCTION__,
-              mClientStateMask);
-        return 0;
-    }
-    do {
-        if (isAnyClientGained(currentBufferState & (~mClientStateMask)) ||
-            isAnyClientAcquired(currentBufferState)) {
-            ALOGE("%s: Buffer is in use, id=%d mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
-                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
-            return -EBUSY;
-        }
-        // Change the buffer state to gained state, whose value happens to be the same as
-        // mClientStateMask.
-    } while (!mBufferState->compare_exchange_weak(currentBufferState, mClientStateMask,
-                                                  std::memory_order_acq_rel,
-                                                  std::memory_order_acquire));
-    // TODO(b/119837586): Update fence state and return GPU fence.
-    return 0;
-}
-
-int BufferHubBuffer::post() {
-    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
-    uint32_t updatedBufferState = (~mClientStateMask) & BufferHubDefs::kHighBitsMask;
-    do {
-        if (!isClientGained(currentBufferState, mClientStateMask)) {
-            ALOGE("%s: Cannot post a buffer that is not gained by this client. buffer_id=%d "
-                  "mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
-                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
-            return -EBUSY;
-        }
-        // Set the producer client buffer state to released, other clients' buffer state to posted.
-        // Post to all existing and non-existing clients.
-    } while (!mBufferState->compare_exchange_weak(currentBufferState, updatedBufferState,
-                                                  std::memory_order_acq_rel,
-                                                  std::memory_order_acquire));
-    // TODO(b/119837586): Update fence state and return GPU fence if needed.
-    return 0;
-}
-
-int BufferHubBuffer::acquire() {
-    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
-    if (isClientAcquired(currentBufferState, mClientStateMask)) {
-        ALOGV("%s: Buffer is already acquired by this client %" PRIx32 ".", __FUNCTION__,
-              mClientStateMask);
-        return 0;
-    }
-    uint32_t updatedBufferState = 0U;
-    do {
-        if (!isClientPosted(currentBufferState, mClientStateMask)) {
-            ALOGE("%s: Cannot acquire a buffer that is not in posted state. buffer_id=%d "
-                  "mClientStateMask=%" PRIx32 " state=%" PRIx32 ".",
-                  __FUNCTION__, mId, mClientStateMask, currentBufferState);
-            return -EBUSY;
-        }
-        // Change the buffer state for this consumer from posted to acquired.
-        updatedBufferState = currentBufferState ^ mClientStateMask;
-    } while (!mBufferState->compare_exchange_weak(currentBufferState, updatedBufferState,
-                                                  std::memory_order_acq_rel,
-                                                  std::memory_order_acquire));
-    // TODO(b/119837586): Update fence state and return GPU fence.
-    return 0;
-}
-
-int BufferHubBuffer::release() {
-    uint32_t currentBufferState = mBufferState->load(std::memory_order_acquire);
-    if (isClientReleased(currentBufferState, mClientStateMask)) {
-        ALOGV("%s: Buffer is already released by this client %" PRIx32 ".", __FUNCTION__,
-              mClientStateMask);
-        return 0;
-    }
-    uint32_t updatedBufferState = 0U;
-    do {
-        updatedBufferState = currentBufferState & (~mClientStateMask);
-    } while (!mBufferState->compare_exchange_weak(currentBufferState, updatedBufferState,
-                                                  std::memory_order_acq_rel,
-                                                  std::memory_order_acquire));
-    // TODO(b/119837586): Update fence state and return GPU fence if needed.
-    return 0;
-}
-
-bool BufferHubBuffer::isReleased() const {
-    return (mBufferState->load(std::memory_order_acquire) &
-            mActiveClientsBitMask->load(std::memory_order_acquire)) == 0;
-}
-
-bool BufferHubBuffer::isValid() const {
-    return mBufferHandle.getNativeHandle() != nullptr && mId >= 0 && mClientStateMask != 0U &&
-            mEventFd.get() >= 0 && mMetadata.isValid() && mBufferClient != nullptr;
-}
-
-sp<NativeHandle> BufferHubBuffer::duplicate() {
-    if (mBufferClient == nullptr) {
-        ALOGE("%s: missing BufferClient!", __FUNCTION__);
-        return nullptr;
-    }
-
-    hidl_handle token;
-    BufferHubStatus ret;
-    IBufferClient::duplicate_cb dupCb = [&](const auto& outToken, const auto& status) {
-        token = std::move(outToken);
-        ret = status;
-    };
-
-    if (!mBufferClient->duplicate(dupCb).isOk()) {
-        ALOGE("%s: duplicate transaction failed!", __FUNCTION__);
-        return nullptr;
-    } else if (ret != BufferHubStatus::NO_ERROR) {
-        ALOGE("%s: duplicate failed with error %u.", __FUNCTION__, ret);
-        return nullptr;
-    } else if (token.getNativeHandle() == nullptr) {
-        ALOGE("%s: duplicate got null token.", __FUNCTION__);
-        return nullptr;
-    }
-
-    return NativeHandle::create(native_handle_clone(token.getNativeHandle()), /*ownsHandle=*/true);
-}
-
-} // namespace android
diff --git a/libs/ui/BufferHubEventFd.cpp b/libs/ui/BufferHubEventFd.cpp
deleted file mode 100644
index bffc2ca..0000000
--- a/libs/ui/BufferHubEventFd.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2018 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 <sys/eventfd.h>
-
-#include <log/log.h>
-#include <ui/BufferHubEventFd.h>
-
-namespace android {
-
-BufferHubEventFd::BufferHubEventFd() : mFd(eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)) {}
-
-BufferHubEventFd::BufferHubEventFd(int fd) : mFd(fd) {}
-
-status_t BufferHubEventFd::signal() const {
-    if (!isValid()) {
-        ALOGE("%s: cannot signal an invalid eventfd.", __FUNCTION__);
-        return DEAD_OBJECT;
-    }
-
-    eventfd_write(mFd.get(), 1);
-    return OK;
-}
-
-status_t BufferHubEventFd::clear() const {
-    if (!isValid()) {
-        ALOGE("%s: cannot clear an invalid eventfd.", __FUNCTION__);
-        return DEAD_OBJECT;
-    }
-
-    eventfd_t value;
-    eventfd_read(mFd.get(), &value);
-    return OK;
-}
-
-} // namespace android
diff --git a/libs/ui/BufferHubMetadata.cpp b/libs/ui/BufferHubMetadata.cpp
deleted file mode 100644
index 05bc7dd..0000000
--- a/libs/ui/BufferHubMetadata.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2018 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 <errno.h>
-#include <sys/mman.h>
-#include <limits>
-
-#include <cutils/ashmem.h>
-#include <log/log.h>
-#include <ui/BufferHubMetadata.h>
-
-namespace android {
-
-namespace {
-
-static const int kAshmemProt = PROT_READ | PROT_WRITE;
-
-} // namespace
-
-using BufferHubDefs::kMetadataHeaderSize;
-using BufferHubDefs::MetadataHeader;
-
-/* static */
-BufferHubMetadata BufferHubMetadata::create(size_t userMetadataSize) {
-    // The size the of metadata buffer is used as the "width" parameter during allocation. Thus it
-    // cannot overflow uint32_t.
-    if (userMetadataSize >= (std::numeric_limits<uint32_t>::max() - kMetadataHeaderSize)) {
-        ALOGE("BufferHubMetadata::Create: metadata size too big: %zu.", userMetadataSize);
-        return {};
-    }
-
-    const size_t metadataSize = userMetadataSize + kMetadataHeaderSize;
-    int fd = ashmem_create_region(/*name=*/"BufferHubMetadata", metadataSize);
-    if (fd < 0) {
-        ALOGE("BufferHubMetadata::Create: failed to create ashmem region.");
-        return {};
-    }
-
-    // Hand over the ownership of the fd to a unique_fd immediately after the successful
-    // return of ashmem_create_region. The ashmemFd is going to own the fd and to prevent fd
-    // leaks during error handling.
-    unique_fd ashmemFd{fd};
-
-    if (ashmem_set_prot_region(ashmemFd.get(), kAshmemProt) != 0) {
-        ALOGE("BufferHubMetadata::Create: failed to set protect region.");
-        return {};
-    }
-
-    return BufferHubMetadata::import(std::move(ashmemFd));
-}
-
-/* static */
-BufferHubMetadata BufferHubMetadata::import(unique_fd ashmemFd) {
-    if (!ashmem_valid(ashmemFd.get())) {
-        ALOGE("BufferHubMetadata::Import: invalid ashmem fd.");
-        return {};
-    }
-
-    size_t metadataSize = static_cast<size_t>(ashmem_get_size_region(ashmemFd.get()));
-    size_t userMetadataSize = metadataSize - kMetadataHeaderSize;
-
-    // Note that here the buffer state is mapped from shared memory as an atomic object. The
-    // std::atomic's constructor will not be called so that the original value stored in the memory
-    // region can be preserved.
-    auto metadataHeader = static_cast<MetadataHeader*>(mmap(nullptr, metadataSize, kAshmemProt,
-                                                            MAP_SHARED, ashmemFd.get(),
-                                                            /*offset=*/0));
-    if (metadataHeader == nullptr) {
-        ALOGE("BufferHubMetadata::Import: failed to map region.");
-        return {};
-    }
-
-    return BufferHubMetadata(userMetadataSize, std::move(ashmemFd), metadataHeader);
-}
-
-BufferHubMetadata::BufferHubMetadata(size_t userMetadataSize, unique_fd ashmemFd,
-                                     MetadataHeader* metadataHeader)
-      : mUserMetadataSize(userMetadataSize),
-        mAshmemFd(std::move(ashmemFd)),
-        mMetadataHeader(metadataHeader) {}
-
-BufferHubMetadata::~BufferHubMetadata() {
-    if (mMetadataHeader != nullptr) {
-        int ret = munmap(mMetadataHeader, metadataSize());
-        ALOGE_IF(ret != 0,
-                 "BufferHubMetadata::~BufferHubMetadata: failed to unmap ashmem, error=%d.", errno);
-        mMetadataHeader = nullptr;
-    }
-}
-
-} // namespace android
diff --git a/libs/ui/DeviceProductInfo.cpp b/libs/ui/DeviceProductInfo.cpp
new file mode 100644
index 0000000..efd61b6
--- /dev/null
+++ b/libs/ui/DeviceProductInfo.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2020 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 <ui/DeviceProductInfo.h>
+
+#include <ui/FlattenableHelpers.h>
+
+namespace android {
+
+size_t DeviceProductInfo::getFlattenedSize() const {
+    return FlattenableHelpers::getFlattenedSize(name) + sizeof(manufacturerPnpId) +
+            FlattenableHelpers::getFlattenedSize(productId) + sizeof(manufactureOrModelDate);
+}
+
+status_t DeviceProductInfo::flatten(void* buffer, size_t size) const {
+    if (size < getFlattenedSize()) {
+        return NO_MEMORY;
+    }
+    FlattenableHelpers::write(buffer, size, name);
+    FlattenableUtils::write(buffer, size, manufacturerPnpId);
+    FlattenableHelpers::write(buffer, size, productId);
+    FlattenableUtils::write(buffer, size, manufactureOrModelDate);
+    return NO_ERROR;
+}
+
+status_t DeviceProductInfo::unflatten(void const* buffer, size_t size) {
+    if (size < getFlattenedSize()) {
+        return NO_MEMORY;
+    }
+    FlattenableHelpers::read(buffer, size, &name);
+    FlattenableUtils::read(buffer, size, manufacturerPnpId);
+    FlattenableHelpers::read(buffer, size, &productId);
+    FlattenableUtils::read(buffer, size, manufactureOrModelDate);
+    return NO_ERROR;
+}
+
+} // namespace android
diff --git a/libs/ui/DisplayInfo.cpp b/libs/ui/DisplayInfo.cpp
new file mode 100644
index 0000000..6ed7e19
--- /dev/null
+++ b/libs/ui/DisplayInfo.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2020 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 <ui/DisplayInfo.h>
+
+#include <cstdint>
+
+#include <ui/FlattenableHelpers.h>
+
+namespace android {
+
+size_t DisplayInfo::getFlattenedSize() const {
+    return sizeof(connectionType) + sizeof(density) + sizeof(secure) +
+            FlattenableHelpers::getFlattenedSize(deviceProductInfo);
+}
+
+status_t DisplayInfo::flatten(void* buffer, size_t size) const {
+    if (size < getFlattenedSize()) {
+        return NO_MEMORY;
+    }
+    FlattenableUtils::write(buffer, size, connectionType);
+    FlattenableUtils::write(buffer, size, density);
+    FlattenableUtils::write(buffer, size, secure);
+    FlattenableHelpers::write(buffer, size, deviceProductInfo);
+
+    return NO_ERROR;
+}
+
+status_t DisplayInfo::unflatten(void const* buffer, size_t size) {
+    if (size < getFlattenedSize()) {
+        return NO_MEMORY;
+    }
+    FlattenableUtils::read(buffer, size, connectionType);
+    FlattenableUtils::read(buffer, size, density);
+    FlattenableUtils::read(buffer, size, secure);
+    FlattenableHelpers::read(buffer, size, &deviceProductInfo);
+
+    return NO_ERROR;
+}
+
+} // namespace android
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 05fc590..3732fee 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -23,10 +23,6 @@
 
 #include <grallocusage/GrallocUsageConversion.h>
 
-#ifndef LIBUI_IN_VNDK
-#include <ui/BufferHubBuffer.h>
-#endif // LIBUI_IN_VNDK
-
 #include <ui/GraphicBufferAllocator.h>
 #include <ui/GraphicBufferMapper.h>
 #include <utils/Trace.h>
@@ -110,22 +106,6 @@
                                 inUsage, inStride);
 }
 
-#ifndef LIBUI_IN_VNDK
-GraphicBuffer::GraphicBuffer(std::unique_ptr<BufferHubBuffer> buffer) : GraphicBuffer() {
-    if (buffer == nullptr) {
-        mInitCheck = BAD_VALUE;
-        return;
-    }
-
-    mInitCheck = initWithHandle(buffer->duplicateHandle(), /*method=*/TAKE_UNREGISTERED_HANDLE,
-                                buffer->desc().width, buffer->desc().height,
-                                static_cast<PixelFormat>(buffer->desc().format),
-                                buffer->desc().layers, buffer->desc().usage, buffer->desc().stride);
-    mBufferId = buffer->id();
-    mBufferHubBuffer = std::move(buffer);
-}
-#endif // LIBUI_IN_VNDK
-
 GraphicBuffer::~GraphicBuffer()
 {
     ATRACE_CALL();
@@ -374,29 +354,14 @@
 }
 
 size_t GraphicBuffer::getFlattenedSize() const {
-#ifndef LIBUI_IN_VNDK
-    if (mBufferHubBuffer != nullptr) {
-        return 48;
-    }
-#endif
     return static_cast<size_t>(13 + (handle ? mTransportNumInts : 0)) * sizeof(int);
 }
 
 size_t GraphicBuffer::getFdCount() const {
-#ifndef LIBUI_IN_VNDK
-    if (mBufferHubBuffer != nullptr) {
-        return 0;
-    }
-#endif
     return static_cast<size_t>(handle ? mTransportNumFds : 0);
 }
 
 status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const {
-#ifndef LIBUI_IN_VNDK
-    if (mBufferHubBuffer != nullptr) {
-        return flattenBufferHubBuffer(buffer, size);
-    }
-#endif
     size_t sizeNeeded = GraphicBuffer::getFlattenedSize();
     if (size < sizeNeeded) return NO_MEMORY;
 
@@ -453,12 +418,6 @@
     } else if (buf[0] == 'GBFR') {
         // old version, when usage bits were 32-bits
         flattenWordCount = 12;
-    } else if (buf[0] == 'BHBB') { // BufferHub backed buffer.
-#ifndef LIBUI_IN_VNDK
-        return unflattenBufferHubBuffer(buffer, size);
-#else
-        return BAD_TYPE;
-#endif
     } else {
         return BAD_TYPE;
     }
@@ -565,76 +524,6 @@
     mDeathCallbacks.emplace_back(deathCallback, context);
 }
 
-#ifndef LIBUI_IN_VNDK
-status_t GraphicBuffer::flattenBufferHubBuffer(void*& buffer, size_t& size) const {
-    sp<NativeHandle> tokenHandle = mBufferHubBuffer->duplicate();
-    if (tokenHandle == nullptr || tokenHandle->handle() == nullptr ||
-        tokenHandle->handle()->numFds != 0) {
-        return BAD_VALUE;
-    }
-
-    // Size needed for one label, one number of ints inside the token, one generation number and
-    // the token itself.
-    int numIntsInToken = tokenHandle->handle()->numInts;
-    const size_t sizeNeeded = static_cast<size_t>(3 + numIntsInToken) * sizeof(int);
-    if (size < sizeNeeded) {
-        ALOGE("%s: needed size %d, given size %d. Not enough memory.", __FUNCTION__,
-              static_cast<int>(sizeNeeded), static_cast<int>(size));
-        return NO_MEMORY;
-    }
-    size -= sizeNeeded;
-
-    int* buf = static_cast<int*>(buffer);
-    buf[0] = 'BHBB';
-    buf[1] = numIntsInToken;
-    memcpy(buf + 2, tokenHandle->handle()->data, static_cast<size_t>(numIntsInToken) * sizeof(int));
-    buf[2 + numIntsInToken] = static_cast<int32_t>(mGenerationNumber);
-
-    return NO_ERROR;
-}
-
-status_t GraphicBuffer::unflattenBufferHubBuffer(void const*& buffer, size_t& size) {
-    const int* buf = static_cast<const int*>(buffer);
-    int numIntsInToken = buf[1];
-    // Size needed for one label, one number of ints inside the token, one generation number and
-    // the token itself.
-    const size_t sizeNeeded = static_cast<size_t>(3 + numIntsInToken) * sizeof(int);
-    if (size < sizeNeeded) {
-        ALOGE("%s: needed size %d, given size %d. Not enough memory.", __FUNCTION__,
-              static_cast<int>(sizeNeeded), static_cast<int>(size));
-        return NO_MEMORY;
-    }
-    size -= sizeNeeded;
-    native_handle_t* importToken = native_handle_create(/*numFds=*/0, /*numInts=*/numIntsInToken);
-    memcpy(importToken->data, buf + 2, static_cast<size_t>(buf[1]) * sizeof(int));
-    sp<NativeHandle> importTokenHandle = NativeHandle::create(importToken, /*ownHandle=*/true);
-    std::unique_ptr<BufferHubBuffer> bufferHubBuffer = BufferHubBuffer::import(importTokenHandle);
-    if (bufferHubBuffer == nullptr || bufferHubBuffer.get() == nullptr) {
-        return BAD_VALUE;
-    }
-    // Reconstruct this GraphicBuffer object using the new BufferHubBuffer object.
-    if (handle) {
-        free_handle();
-    }
-    mId = 0;
-    mGenerationNumber = static_cast<uint32_t>(buf[2 + numIntsInToken]);
-    mInitCheck =
-            initWithHandle(bufferHubBuffer->duplicateHandle(), /*method=*/TAKE_UNREGISTERED_HANDLE,
-                           bufferHubBuffer->desc().width, bufferHubBuffer->desc().height,
-                           static_cast<PixelFormat>(bufferHubBuffer->desc().format),
-                           bufferHubBuffer->desc().layers, bufferHubBuffer->desc().usage,
-                           bufferHubBuffer->desc().stride);
-    mBufferId = bufferHubBuffer->id();
-    mBufferHubBuffer = std::move(bufferHubBuffer);
-
-    return NO_ERROR;
-}
-
-bool GraphicBuffer::isBufferHubBuffer() const {
-    return mBufferHubBuffer != nullptr;
-}
-#endif // LIBUI_IN_VNDK
-
 // ---------------------------------------------------------------------------
 
 }; // namespace android
diff --git a/libs/ui/include/ui/BufferHubBuffer.h b/libs/ui/include/ui/BufferHubBuffer.h
deleted file mode 100644
index 5ba189c..0000000
--- a/libs/ui/include/ui/BufferHubBuffer.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2018 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_BUFFER_HUB_BUFFER_H_
-#define ANDROID_BUFFER_HUB_BUFFER_H_
-
-#include <android/frameworks/bufferhub/1.0/IBufferClient.h>
-#include <android/hardware_buffer.h>
-#include <cutils/native_handle.h>
-#include <ui/BufferHubDefs.h>
-#include <ui/BufferHubEventFd.h>
-#include <ui/BufferHubMetadata.h>
-#include <utils/NativeHandle.h>
-
-namespace android {
-
-class BufferHubBuffer {
-public:
-    // Allocates a standalone BufferHubBuffer.
-    static std::unique_ptr<BufferHubBuffer> create(uint32_t width, uint32_t height,
-                                                   uint32_t layerCount, uint32_t format,
-                                                   uint64_t usage, size_t userMetadataSize);
-
-    // Imports the given token to a BufferHubBuffer. Not taking ownership of the token.
-    static std::unique_ptr<BufferHubBuffer> import(const sp<NativeHandle>& token);
-
-    BufferHubBuffer(const BufferHubBuffer&) = delete;
-    void operator=(const BufferHubBuffer&) = delete;
-
-    virtual ~BufferHubBuffer();
-
-    // Gets ID of the buffer client. All BufferHubBuffer clients derived from the same buffer in
-    // BufferHub share the same buffer id.
-    int id() const { return mId; }
-
-    // Returns the buffer description, which is guaranteed to be faithful values from BufferHub.
-    const AHardwareBuffer_Desc& desc() const { return mBufferDesc; }
-
-    // Duplicate the underlying Gralloc buffer handle. Caller is responsible to free the handle
-    // after use.
-    native_handle_t* duplicateHandle() {
-        return native_handle_clone(mBufferHandle.getNativeHandle());
-    }
-
-    const BufferHubEventFd& eventFd() const { return mEventFd; }
-
-    // Returns the current value of MetadataHeader::bufferState.
-    uint32_t bufferState() const { return mBufferState->load(std::memory_order_acquire); }
-
-    // A state mask which is unique to a buffer hub client among all its siblings sharing the same
-    // concrete graphic buffer.
-    uint32_t clientStateMask() const { return mClientStateMask; }
-
-    size_t userMetadataSize() const { return mMetadata.userMetadataSize(); }
-
-    // Returns true if the BufferClient is still alive.
-    bool isConnected() const { return mBufferClient->ping().isOk(); }
-
-    // Returns true if the buffer is valid: non-null buffer handle, valid id, valid client bit mask,
-    // valid metadata and valid buffer client
-    bool isValid() const;
-
-    // Gains the buffer for exclusive write permission. Read permission is implied once a buffer is
-    // gained.
-    // The buffer can be gained as long as there is no other client in acquired or gained state.
-    int gain();
-
-    // Posts the gained buffer for other buffer clients to use the buffer.
-    // The buffer can be posted iff the buffer state for this client is gained.
-    // After posting the buffer, this client is put to released state and does not have access to
-    // the buffer for this cycle of the usage of the buffer.
-    int post();
-
-    // Acquires the buffer for shared read permission.
-    // The buffer can be acquired iff the buffer state for this client is posted.
-    int acquire();
-
-    // Releases the buffer.
-    // The buffer can be released from any buffer state.
-    // After releasing the buffer, this client no longer have any permissions to the buffer for the
-    // current cycle of the usage of the buffer.
-    int release();
-
-    // Returns whether the buffer is released by all active clients or not.
-    bool isReleased() const;
-
-    // Creates a token that stands for this BufferHubBuffer client and could be used for Import to
-    // create another BufferHubBuffer. The new BufferHubBuffer will share the same underlying
-    // gralloc buffer and ashmem region for metadata. Not taking ownership of the token.
-    // Returns a valid token on success, nullptr on failure.
-    sp<NativeHandle> duplicate();
-
-private:
-    BufferHubBuffer(uint32_t width, uint32_t height, uint32_t layerCount, uint32_t format,
-                    uint64_t usage, size_t userMetadataSize);
-
-    BufferHubBuffer(const sp<NativeHandle>& token);
-
-    int initWithBufferTraits(const frameworks::bufferhub::V1_0::BufferTraits& bufferTraits);
-
-    // Global id for the buffer that is consistent across processes.
-    int mId = 0;
-
-    // Client state mask of this BufferHubBuffer object. It is unique amoung all
-    // clients/users of the buffer.
-    uint32_t mClientStateMask = 0U;
-
-    // Stores ground truth of the buffer.
-    AHardwareBuffer_Desc mBufferDesc;
-
-    // Wraps the gralloc buffer handle of this buffer.
-    hardware::hidl_handle mBufferHandle;
-
-    // Event fd used for signalling buffer state changes. Shared by all clients of the same buffer.
-    BufferHubEventFd mEventFd;
-
-    // An ashmem-based metadata object. The same shared memory are mapped to the
-    // bufferhubd daemon and all buffer clients.
-    BufferHubMetadata mMetadata;
-    // Shortcuts to the atomics inside the header of mMetadata.
-    std::atomic<uint32_t>* mBufferState = nullptr;
-    std::atomic<uint32_t>* mFenceState = nullptr;
-    std::atomic<uint32_t>* mActiveClientsBitMask = nullptr;
-
-    // HwBinder backend
-    sp<frameworks::bufferhub::V1_0::IBufferClient> mBufferClient;
-};
-
-} // namespace android
-
-#endif // ANDROID_BUFFER_HUB_BUFFER_H_
diff --git a/libs/ui/include/ui/BufferHubEventFd.h b/libs/ui/include/ui/BufferHubEventFd.h
deleted file mode 100644
index 8772304..0000000
--- a/libs/ui/include/ui/BufferHubEventFd.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2018 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_BUFFER_HUB_EVENT_FD_H_
-#define ANDROID_BUFFER_HUB_EVENT_FD_H_
-
-#include <android-base/unique_fd.h>
-#include <utils/Errors.h>
-
-namespace android {
-
-class BufferHubEventFd {
-public:
-    /**
-     * Constructs a valid event fd.
-     */
-    BufferHubEventFd();
-
-    /**
-     * Constructs from a valid event fd. Caller is responsible for the validity of the fd. Takes
-     * ownership.
-     */
-    BufferHubEventFd(int fd);
-
-    /**
-     * Returns whether this BufferHubEventFd holds a valid event_fd.
-     */
-    bool isValid() const { return get() >= 0; }
-
-    /**
-     * Returns the fd number of the BufferHubEventFd object. Note that there is no ownership
-     * transfer.
-     */
-    int get() const { return mFd.get(); }
-
-    /**
-     * Signals the eventfd.
-     */
-    status_t signal() const;
-
-    /**
-     * Clears the signal from this eventfd if it is signaled.
-     */
-    status_t clear() const;
-
-private:
-    base::unique_fd mFd;
-};
-
-} // namespace android
-
-#endif // ANDROID_BUFFER_HUB_EVENT_FD_H_
diff --git a/libs/ui/include/ui/BufferHubMetadata.h b/libs/ui/include/ui/BufferHubMetadata.h
deleted file mode 100644
index 3482507..0000000
--- a/libs/ui/include/ui/BufferHubMetadata.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2018 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_BUFFER_HUB_METADATA_H_
-#define ANDROID_BUFFER_HUB_METADATA_H_
-
-#include <android-base/unique_fd.h>
-#include <ui/BufferHubDefs.h>
-
-namespace android {
-
-namespace {
-using base::unique_fd;
-} // namespace
-
-class BufferHubMetadata {
-public:
-    // Creates a new BufferHubMetadata backed by an ashmem region.
-    //
-    // @param userMetadataSize Size in bytes of the user defined metadata. The entire metadata
-    //        shared memory region to be allocated is the size of canonical
-    //        BufferHubDefs::MetadataHeader plus userMetadataSize.
-    static BufferHubMetadata create(size_t userMetadataSize);
-
-    // Imports an existing BufferHubMetadata from an ashmem FD.
-    //
-    // @param ashmemFd Ashmem file descriptor representing an ashmem region.
-    static BufferHubMetadata import(unique_fd ashmemFd);
-
-    BufferHubMetadata() = default;
-
-    BufferHubMetadata(BufferHubMetadata&& other) { *this = std::move(other); }
-
-    ~BufferHubMetadata();
-
-    BufferHubMetadata& operator=(BufferHubMetadata&& other) {
-        if (this != &other) {
-            mUserMetadataSize = other.mUserMetadataSize;
-            other.mUserMetadataSize = 0;
-
-            mAshmemFd = std::move(other.mAshmemFd);
-
-            // The old raw mMetadataHeader pointer must be cleared, otherwise the destructor will
-            // automatically mummap() the shared memory.
-            mMetadataHeader = other.mMetadataHeader;
-            other.mMetadataHeader = nullptr;
-        }
-        return *this;
-    }
-
-    // Returns true if the metadata is valid, i.e. the metadata has a valid ashmem fd and the ashmem
-    // has been mapped into virtual address space.
-    bool isValid() const { return mAshmemFd.get() != -1 && mMetadataHeader != nullptr; }
-
-    size_t userMetadataSize() const { return mUserMetadataSize; }
-    size_t metadataSize() const { return mUserMetadataSize + BufferHubDefs::kMetadataHeaderSize; }
-
-    const unique_fd& ashmemFd() const { return mAshmemFd; }
-    BufferHubDefs::MetadataHeader* metadataHeader() { return mMetadataHeader; }
-
-private:
-    BufferHubMetadata(size_t userMetadataSize, unique_fd ashmemFd,
-                      BufferHubDefs::MetadataHeader* metadataHeader);
-
-    BufferHubMetadata(const BufferHubMetadata&) = delete;
-    void operator=(const BufferHubMetadata&) = delete;
-
-    size_t mUserMetadataSize = 0;
-    unique_fd mAshmemFd;
-    BufferHubDefs::MetadataHeader* mMetadataHeader = nullptr;
-};
-
-} // namespace android
-
-#endif // ANDROID_BUFFER_HUB_METADATA_H_
diff --git a/libs/ui/include/ui/DeviceProductInfo.h b/libs/ui/include/ui/DeviceProductInfo.h
index af00342..cc5ebe4 100644
--- a/libs/ui/include/ui/DeviceProductInfo.h
+++ b/libs/ui/include/ui/DeviceProductInfo.h
@@ -19,8 +19,12 @@
 #include <array>
 #include <cstdint>
 #include <optional>
+#include <string>
+#include <type_traits>
 #include <variant>
 
+#include <utils/Flattenable.h>
+
 namespace android {
 
 // NUL-terminated plug and play ID.
@@ -29,13 +33,7 @@
 // Product-specific information about the display or the directly connected device on the
 // display chain. For example, if the display is transitively connected, this field may contain
 // product information about the intermediate device.
-struct DeviceProductInfo {
-    static constexpr size_t TEXT_BUFFER_SIZE = 20;
-    static constexpr size_t RELATIVE_ADDRESS_SIZE = 4;
-
-    using RelativeAddress = std::array<uint8_t, RELATIVE_ADDRESS_SIZE>;
-    static constexpr RelativeAddress NO_RELATIVE_ADDRESS = {0xff, 0xff, 0xff, 0xff};
-
+struct DeviceProductInfo : LightFlattenable<DeviceProductInfo> {
     struct ModelYear {
         uint32_t year;
     };
@@ -48,21 +46,22 @@
     };
 
     // Display name.
-    std::array<char, TEXT_BUFFER_SIZE> name;
+    std::string name;
 
     // Manufacturer Plug and Play ID.
     PnpId manufacturerPnpId;
 
     // Manufacturer product ID.
-    std::array<char, TEXT_BUFFER_SIZE> productId;
+    std::string productId;
 
     using ManufactureOrModelDate = std::variant<ModelYear, ManufactureYear, ManufactureWeekAndYear>;
+    static_assert(std::is_trivially_copyable_v<ManufactureOrModelDate>);
     ManufactureOrModelDate manufactureOrModelDate;
 
-    // Relative address in the display network. Unavailable address is indicated
-    // by all elements equal to 255.
-    // For example, for HDMI connected device this will be the physical address.
-    RelativeAddress relativeAddress;
+    bool isFixedSize() const { return false; }
+    size_t getFlattenedSize() const;
+    status_t flatten(void* buffer, size_t size) const;
+    status_t unflatten(void const* buffer, size_t size);
 };
 
 } // namespace android
diff --git a/libs/ui/include/ui/DisplayInfo.h b/libs/ui/include/ui/DisplayInfo.h
index 897060c..03e0a38 100644
--- a/libs/ui/include/ui/DisplayInfo.h
+++ b/libs/ui/include/ui/DisplayInfo.h
@@ -20,19 +20,23 @@
 #include <type_traits>
 
 #include <ui/DeviceProductInfo.h>
+#include <utils/Flattenable.h>
 
 namespace android {
 
 enum class DisplayConnectionType { Internal, External };
 
 // Immutable information about physical display.
-struct DisplayInfo {
+struct DisplayInfo : LightFlattenable<DisplayInfo> {
     DisplayConnectionType connectionType = DisplayConnectionType::Internal;
     float density = 0.f;
     bool secure = false;
     std::optional<DeviceProductInfo> deviceProductInfo;
-};
 
-static_assert(std::is_trivially_copyable_v<DisplayInfo>);
+    bool isFixedSize() const { return false; }
+    size_t getFlattenedSize() const;
+    status_t flatten(void* buffer, size_t size) const;
+    status_t unflatten(void const* buffer, size_t size);
+};
 
 } // namespace android
diff --git a/libs/ui/include/ui/GraphicBuffer.h b/libs/ui/include/ui/GraphicBuffer.h
index c195342..013505a 100644
--- a/libs/ui/include/ui/GraphicBuffer.h
+++ b/libs/ui/include/ui/GraphicBuffer.h
@@ -38,10 +38,6 @@
 
 namespace android {
 
-#ifndef LIBUI_IN_VNDK
-class BufferHubBuffer;
-#endif // LIBUI_IN_VNDK
-
 class GraphicBufferMapper;
 
 using GraphicBufferDeathCallback = std::function<void(void* /*context*/, uint64_t bufferId)>;
@@ -147,11 +143,6 @@
     GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat,
             uint32_t inUsage, std::string requestorName = "<Unknown>");
 
-#ifndef LIBUI_IN_VNDK
-    // Create a GraphicBuffer from an existing BufferHubBuffer.
-    GraphicBuffer(std::unique_ptr<BufferHubBuffer> buffer);
-#endif // LIBUI_IN_VNDK
-
     // return status
     status_t initCheck() const;
 
@@ -163,7 +154,6 @@
     uint32_t getLayerCount() const      { return static_cast<uint32_t>(layerCount); }
     Rect getBounds() const              { return Rect(width, height); }
     uint64_t getId() const              { return mId; }
-    int32_t getBufferId() const { return mBufferId; }
 
     uint32_t getGenerationNumber() const { return mGenerationNumber; }
     void setGenerationNumber(uint32_t generation) {
@@ -225,11 +215,6 @@
 
     void addDeathCallback(GraphicBufferDeathCallback deathCallback, void* context);
 
-#ifndef LIBUI_IN_VNDK
-    // Returns whether this GraphicBuffer is backed by BufferHubBuffer.
-    bool isBufferHubBuffer() const;
-#endif // LIBUI_IN_VNDK
-
 private:
     ~GraphicBuffer();
 
@@ -275,12 +260,6 @@
 
     uint64_t mId;
 
-    // System unique buffer ID. Note that this is different from mId, which is process unique. For
-    // GraphicBuffer backed by BufferHub, the mBufferId is a system unique identifier that stays the
-    // same cross process for the same chunck of underlying memory. Also note that this only applies
-    // to GraphicBuffers that are backed by BufferHub.
-    int32_t mBufferId = -1;
-
     // Stores the generation number of this buffer. If this number does not
     // match the BufferQueue's internal generation number (set through
     // IGBP::setGenerationNumber), attempts to attach the buffer will fail.
@@ -299,22 +278,6 @@
     // and informs SurfaceFlinger that it should drop its strong pointer reference to the buffer.
     std::vector<std::pair<GraphicBufferDeathCallback, void* /*mDeathCallbackContext*/>>
             mDeathCallbacks;
-
-#ifndef LIBUI_IN_VNDK
-    // Flatten this GraphicBuffer object if backed by BufferHubBuffer.
-    status_t flattenBufferHubBuffer(void*& buffer, size_t& size) const;
-
-    // Unflatten into BufferHubBuffer backed GraphicBuffer.
-    // Unflatten will fail if the original GraphicBuffer object is destructed. For instance, a
-    // GraphicBuffer backed by BufferHubBuffer_1 flatten in process/thread A, transport the token
-    // to process/thread B through a socket, BufferHubBuffer_1 dies and bufferhub invalidated the
-    // token. Race condition occurs between the invalidation of the token in bufferhub process and
-    // process/thread B trying to unflatten and import the buffer with that token.
-    status_t unflattenBufferHubBuffer(void const*& buffer, size_t& size);
-
-    // Stores a BufferHubBuffer that handles buffer signaling, identification.
-    std::unique_ptr<BufferHubBuffer> mBufferHubBuffer;
-#endif // LIBUI_IN_VNDK
 };
 
 }; // namespace android
diff --git a/libs/ui/include_private/ui/FlattenableHelpers.h b/libs/ui/include_private/ui/FlattenableHelpers.h
new file mode 100644
index 0000000..bdf4804
--- /dev/null
+++ b/libs/ui/include_private/ui/FlattenableHelpers.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2020 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.
+ */
+
+#pragma once
+
+#include <optional>
+#include <type_traits>
+
+#include <utils/Flattenable.h>
+
+namespace android {
+
+struct FlattenableHelpers {
+    // Flattenable helpers for reading and writing std::string
+    static size_t getFlattenedSize(const std::string& str) { return str.length() + 1; }
+
+    static void write(void*& buffer, size_t& size, const std::string& str) {
+        strcpy(reinterpret_cast<char*>(buffer), str.c_str());
+        FlattenableUtils::advance(buffer, size, getFlattenedSize(str));
+    }
+
+    static void read(void const*& buffer, size_t& size, std::string* str) {
+        str->assign(reinterpret_cast<const char*>(buffer));
+        FlattenableUtils::advance(buffer, size, getFlattenedSize(*str));
+    }
+
+    // Flattenable utils for reading and writing std::optional
+    template <class T, typename = std::enable_if_t<std::is_base_of_v<LightFlattenable<T>, T>>>
+    static size_t getFlattenedSize(const std::optional<T>& value) {
+        return sizeof(bool) + (value ? value->getFlattenedSize() : 0);
+    }
+
+    template <class T, typename = std::enable_if_t<std::is_base_of_v<LightFlattenable<T>, T>>>
+    static void write(void*& buffer, size_t& size, const std::optional<T>& value) {
+        if (value) {
+            FlattenableUtils::write(buffer, size, true);
+            value->flatten(buffer, size);
+            FlattenableUtils::advance(buffer, size, value->getFlattenedSize());
+        } else {
+            FlattenableUtils::write(buffer, size, false);
+        }
+    }
+
+    template <class T, typename = std::enable_if_t<std::is_base_of_v<LightFlattenable<T>, T>>>
+    static void read(void const*& buffer, size_t& size, std::optional<T>* value) {
+        bool isPresent;
+        FlattenableUtils::read(buffer, size, isPresent);
+        if (isPresent) {
+            *value = T();
+            (*value)->unflatten(buffer, size);
+            FlattenableUtils::advance(buffer, size, (*value)->getFlattenedSize());
+        } else {
+            value->reset();
+        }
+    }
+};
+
+} // namespace android
diff --git a/libs/ui/include/ui/ColorSpace.h b/libs/ui/include_types/ui/ColorSpace.h
similarity index 100%
rename from libs/ui/include/ui/ColorSpace.h
rename to libs/ui/include_types/ui/ColorSpace.h
diff --git a/libs/ui/include_vndk/ui/ColorSpace.h b/libs/ui/include_vndk/ui/ColorSpace.h
index ddf70d5..7d2a6d3 120000
--- a/libs/ui/include_vndk/ui/ColorSpace.h
+++ b/libs/ui/include_vndk/ui/ColorSpace.h
@@ -1 +1 @@
-../../include/ui/ColorSpace.h
\ No newline at end of file
+../../include_types/ui/ColorSpace.h
\ No newline at end of file
diff --git a/libs/ui/tests/Android.bp b/libs/ui/tests/Android.bp
index 605c5a9..b53342c 100644
--- a/libs/ui/tests/Android.bp
+++ b/libs/ui/tests/Android.bp
@@ -31,7 +31,6 @@
 cc_test {
     name: "GraphicBufferAllocator_test",
     header_libs: [
-        "libdvr_headers",
         "libnativewindow_headers",
     ],
     static_libs: [
@@ -52,11 +51,9 @@
 cc_test {
     name: "GraphicBuffer_test",
     header_libs: [
-        "libdvr_headers",
         "libnativewindow_headers",
     ],
     shared_libs: [
-        "android.frameworks.bufferhub@1.0",
         "libcutils",
         "libhidlbase",
         "libui",
@@ -71,11 +68,7 @@
     name: "GraphicBufferOverBinder_test",
     srcs: ["GraphicBufferOverBinder_test.cpp"],
     cflags: ["-Wall", "-Werror"],
-    header_libs: [
-        "libdvr_headers",
-    ],
     shared_libs: [
-        "android.frameworks.bufferhub@1.0",
         "libbinder",
         "libgui",
         "liblog",
@@ -85,31 +78,6 @@
 }
 
 cc_test {
-    name: "BufferHub_test",
-    header_libs: [
-        "libdvr_headers",
-        "libnativewindow_headers",
-    ],
-    static_libs: [
-        "libgmock",
-    ],
-    shared_libs: [
-        "android.frameworks.bufferhub@1.0",
-        "libcutils",
-        "libhidlbase",
-        "liblog",
-        "libui",
-        "libutils"
-    ],
-    srcs: [
-        "BufferHubBuffer_test.cpp",
-        "BufferHubEventFd_test.cpp",
-        "BufferHubMetadata_test.cpp",
-    ],
-    cflags: ["-Wall", "-Werror"],
-}
-
-cc_test {
     name: "Size_test",
     test_suites: ["device-tests"],
     shared_libs: ["libui"],
diff --git a/libs/ui/tests/BufferHubBuffer_test.cpp b/libs/ui/tests/BufferHubBuffer_test.cpp
deleted file mode 100644
index 0c73a72..0000000
--- a/libs/ui/tests/BufferHubBuffer_test.cpp
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * Copyright 2018 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 "BufferHubBufferTest"
-
-#include <errno.h>
-#include <sys/epoll.h>
-
-#include <android/frameworks/bufferhub/1.0/IBufferHub.h>
-#include <android/hardware_buffer.h>
-#include <cutils/native_handle.h>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <hidl/ServiceManagement.h>
-#include <hwbinder/IPCThreadState.h>
-#include <ui/BufferHubBuffer.h>
-#include <ui/BufferHubEventFd.h>
-
-namespace android {
-
-namespace {
-
-using ::android::BufferHubDefs::isAnyClientAcquired;
-using ::android::BufferHubDefs::isAnyClientGained;
-using ::android::BufferHubDefs::isAnyClientPosted;
-using ::android::BufferHubDefs::isClientAcquired;
-using ::android::BufferHubDefs::isClientGained;
-using ::android::BufferHubDefs::isClientPosted;
-using ::android::BufferHubDefs::isClientReleased;
-using ::android::BufferHubDefs::kMetadataHeaderSize;
-using ::android::frameworks::bufferhub::V1_0::IBufferHub;
-using ::testing::IsNull;
-using ::testing::NotNull;
-
-const int kWidth = 640;
-const int kHeight = 480;
-const int kLayerCount = 1;
-const int kFormat = HAL_PIXEL_FORMAT_RGBA_8888;
-const int kUsage = 0;
-const AHardwareBuffer_Desc kDesc = {kWidth, kHeight,        kLayerCount,  kFormat,
-                                    kUsage, /*stride=*/0UL, /*rfu0=*/0UL, /*rfu1=*/0ULL};
-const size_t kUserMetadataSize = 1;
-
-class BufferHubBufferTest : public ::testing::Test {
-protected:
-    void SetUp() override {
-        android::hardware::ProcessState::self()->startThreadPool();
-
-        if (!BufferHubServiceRunning()) {
-            // TODO(b/112940221): Enforce the test cross all devices once BufferHub lands in Android
-            // R for all Android varieties.
-            GTEST_SKIP() << "Skip test as the BufferHub service is not running.";
-        }
-    }
-
-    bool BufferHubServiceRunning() {
-        sp<IBufferHub> bufferhub = IBufferHub::getService();
-        return bufferhub.get() != nullptr;
-    }
-};
-
-bool cmpAHardwareBufferDesc(const AHardwareBuffer_Desc& desc, const AHardwareBuffer_Desc& other) {
-    // Not comparing stride because it's unknown before allocation
-    return desc.format == other.format && desc.height == other.height &&
-            desc.layers == other.layers && desc.usage == other.usage && desc.width == other.width;
-}
-
-class BufferHubBufferStateTransitionTest : public BufferHubBufferTest {
-protected:
-    void SetUp() override {
-        BufferHubBufferTest::SetUp();
-
-        if (IsSkipped()) {
-            // If the base class' SetUp() stated the test should be skipped, we should short
-            // circuit this sub-class' logic.
-            return;
-        }
-
-        CreateTwoClientsOfABuffer();
-    }
-
-    std::unique_ptr<BufferHubBuffer> b1;
-    uint32_t b1ClientMask = 0U;
-    std::unique_ptr<BufferHubBuffer> b2;
-    uint32_t b2ClientMask = 0U;
-
-private:
-    // Creates b1 and b2 as the clients of the same buffer for testing.
-    void CreateTwoClientsOfABuffer();
-};
-
-void BufferHubBufferStateTransitionTest::CreateTwoClientsOfABuffer() {
-    b1 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage, kUserMetadataSize);
-    ASSERT_THAT(b1, NotNull());
-    b1ClientMask = b1->clientStateMask();
-    ASSERT_NE(b1ClientMask, 0U);
-
-    sp<NativeHandle> token = b1->duplicate();
-    ASSERT_THAT(token, NotNull());
-
-    b2 = BufferHubBuffer::import(token);
-    ASSERT_THAT(b2, NotNull());
-
-    b2ClientMask = b2->clientStateMask();
-    ASSERT_NE(b2ClientMask, 0U);
-    ASSERT_NE(b2ClientMask, b1ClientMask);
-}
-
-TEST_F(BufferHubBufferTest, CreateBufferFails) {
-    // Buffer Creation will fail: BLOB format requires height to be 1.
-    auto b1 = BufferHubBuffer::create(kWidth, /*height=*/2, kLayerCount,
-                                      /*format=*/HAL_PIXEL_FORMAT_BLOB, kUsage, kUserMetadataSize);
-
-    EXPECT_THAT(b1, IsNull());
-
-    // Buffer Creation will fail: user metadata size too large.
-    auto b2 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
-                                      /*userMetadataSize=*/std::numeric_limits<size_t>::max());
-
-    EXPECT_THAT(b2, IsNull());
-
-    // Buffer Creation will fail: user metadata size too large.
-    const size_t userMetadataSize = std::numeric_limits<size_t>::max() - kMetadataHeaderSize;
-    auto b3 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
-                                      userMetadataSize);
-
-    EXPECT_THAT(b3, IsNull());
-}
-
-TEST_F(BufferHubBufferTest, CreateBuffer) {
-    auto b1 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
-                                      kUserMetadataSize);
-    ASSERT_THAT(b1, NotNull());
-    EXPECT_TRUE(b1->isConnected());
-    EXPECT_TRUE(b1->isValid());
-    EXPECT_TRUE(cmpAHardwareBufferDesc(b1->desc(), kDesc));
-    EXPECT_EQ(b1->userMetadataSize(), kUserMetadataSize);
-}
-
-TEST_F(BufferHubBufferTest, DuplicateAndImportBuffer) {
-    auto b1 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
-                                      kUserMetadataSize);
-    ASSERT_THAT(b1, NotNull());
-    EXPECT_TRUE(b1->isValid());
-
-    sp<NativeHandle> token = b1->duplicate();
-    ASSERT_THAT(token, NotNull());
-
-    // The detached buffer should still be valid.
-    EXPECT_TRUE(b1->isConnected());
-    EXPECT_TRUE(b1->isValid());
-
-    std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::import(token);
-
-    ASSERT_THAT(b2, NotNull());
-    EXPECT_TRUE(b2->isValid());
-
-    EXPECT_TRUE(cmpAHardwareBufferDesc(b1->desc(), b2->desc()));
-    EXPECT_EQ(b1->userMetadataSize(), b2->userMetadataSize());
-
-    // These two buffer instances are based on the same physical buffer under the
-    // hood, so they should share the same id.
-    EXPECT_EQ(b1->id(), b2->id());
-    // We use clientStateMask() to tell those two instances apart.
-    EXPECT_NE(b1->clientStateMask(), b2->clientStateMask());
-
-    // Both buffer instances should be in released state currently.
-    EXPECT_TRUE(b1->isReleased());
-    EXPECT_TRUE(b2->isReleased());
-
-    // The event fd should behave like duped event fds.
-    const BufferHubEventFd& eventFd1 = b1->eventFd();
-    ASSERT_GE(eventFd1.get(), 0);
-    const BufferHubEventFd& eventFd2 = b2->eventFd();
-    ASSERT_GE(eventFd2.get(), 0);
-
-    base::unique_fd epollFd(epoll_create(64));
-    ASSERT_GE(epollFd.get(), 0);
-
-    // Add eventFd1 to epoll set, and signal eventFd2.
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd1.get(), &e), 0) << strerror(errno);
-
-    std::array<epoll_event, 1> events;
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    eventFd2.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-
-    // The epoll fd is edge triggered, so it only responds to the eventFd once.
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    eventFd2.signal();
-    eventFd2.clear();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-}
-
-TEST_F(BufferHubBufferTest, ImportFreedBuffer) {
-    auto b1 = BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
-                                      kUserMetadataSize);
-    ASSERT_THAT(b1, NotNull());
-    EXPECT_TRUE(b1->isValid());
-
-    sp<NativeHandle> token = b1->duplicate();
-    ASSERT_THAT(token, NotNull());
-
-    // Explicitly destroy b1. Backend buffer should be freed and token becomes invalid
-    b1.reset();
-
-    std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::import(token);
-
-    // Import should fail with INVALID_TOKEN
-    EXPECT_THAT(b2, IsNull());
-}
-
-// nullptr must not crash the service
-TEST_F(BufferHubBufferTest, ImportNullToken) {
-    auto b1 = BufferHubBuffer::import(nullptr);
-    EXPECT_THAT(b1, IsNull());
-}
-
-TEST_F(BufferHubBufferTest, ImportInvalidToken) {
-    native_handle_t* token = native_handle_create(/*numFds=*/0, /*numInts=*/1);
-    token->data[0] = 0;
-
-    sp<NativeHandle> tokenHandle = NativeHandle::create(token, /*ownHandle=*/true);
-    auto b1 = BufferHubBuffer::import(tokenHandle);
-
-    EXPECT_THAT(b1, IsNull());
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromReleasedState) {
-    ASSERT_TRUE(b1->isReleased());
-
-    // Successful gaining the buffer should change the buffer state bit of b1 to
-    // gained state, other client state bits to released state.
-    EXPECT_EQ(b1->gain(), 0);
-    EXPECT_TRUE(isClientGained(b1->bufferState(), b1ClientMask));
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromGainedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    auto currentBufferState = b1->bufferState();
-    ASSERT_TRUE(isClientGained(currentBufferState, b1ClientMask));
-
-    // Gaining from gained state by the same client should not return error.
-    EXPECT_EQ(b1->gain(), 0);
-
-    // Gaining from gained state by another client should return error.
-    EXPECT_EQ(b2->gain(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromAcquiredState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_EQ(b2->acquire(), 0);
-    ASSERT_TRUE(isAnyClientAcquired(b1->bufferState()));
-
-    // Gaining from acquired state should fail.
-    EXPECT_EQ(b1->gain(), -EBUSY);
-    EXPECT_EQ(b2->gain(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromOtherClientInPostedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_TRUE(isAnyClientPosted(b1->bufferState()));
-
-    // Gaining a buffer who has other posted client should succeed.
-    EXPECT_EQ(b1->gain(), 0);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, GainBuffer_fromSelfInPostedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_TRUE(isAnyClientPosted(b1->bufferState()));
-
-    // A posted client should be able to gain the buffer when there is no other clients in
-    // acquired state.
-    EXPECT_EQ(b2->gain(), 0);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromOtherInGainedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_TRUE(isClientGained(b1->bufferState(), b1ClientMask));
-
-    EXPECT_EQ(b2->post(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromSelfInGainedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_TRUE(isClientGained(b1->bufferState(), b1ClientMask));
-
-    EXPECT_EQ(b1->post(), 0);
-    auto currentBufferState = b1->bufferState();
-    EXPECT_TRUE(isClientReleased(currentBufferState, b1ClientMask));
-    EXPECT_TRUE(isClientPosted(currentBufferState, b2ClientMask));
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromPostedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_TRUE(isAnyClientPosted(b1->bufferState()));
-
-    // Post from posted state should fail.
-    EXPECT_EQ(b1->post(), -EBUSY);
-    EXPECT_EQ(b2->post(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromAcquiredState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_EQ(b2->acquire(), 0);
-    ASSERT_TRUE(isAnyClientAcquired(b1->bufferState()));
-
-    // Posting from acquired state should fail.
-    EXPECT_EQ(b1->post(), -EBUSY);
-    EXPECT_EQ(b2->post(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, PostBuffer_fromReleasedState) {
-    ASSERT_TRUE(b1->isReleased());
-
-    // Posting from released state should fail.
-    EXPECT_EQ(b1->post(), -EBUSY);
-    EXPECT_EQ(b2->post(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromSelfInPostedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_TRUE(isClientPosted(b1->bufferState(), b2ClientMask));
-
-    // Acquire from posted state should pass.
-    EXPECT_EQ(b2->acquire(), 0);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromOtherInPostedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_TRUE(isClientPosted(b1->bufferState(), b2ClientMask));
-
-    // Acquire from released state should fail, although there are other clients
-    // in posted state.
-    EXPECT_EQ(b1->acquire(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromSelfInAcquiredState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_EQ(b2->acquire(), 0);
-    auto currentBufferState = b1->bufferState();
-    ASSERT_TRUE(isClientAcquired(currentBufferState, b2ClientMask));
-
-    // Acquiring from acquired state by the same client should not error out.
-    EXPECT_EQ(b2->acquire(), 0);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromReleasedState) {
-    ASSERT_TRUE(b1->isReleased());
-
-    // Acquiring form released state should fail.
-    EXPECT_EQ(b1->acquire(), -EBUSY);
-    EXPECT_EQ(b2->acquire(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, AcquireBuffer_fromGainedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_TRUE(isAnyClientGained(b1->bufferState()));
-
-    // Acquiring from gained state should fail.
-    EXPECT_EQ(b1->acquire(), -EBUSY);
-    EXPECT_EQ(b2->acquire(), -EBUSY);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, ReleaseBuffer_fromSelfInReleasedState) {
-    ASSERT_TRUE(b1->isReleased());
-
-    EXPECT_EQ(b1->release(), 0);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, ReleaseBuffer_fromSelfInGainedState) {
-    ASSERT_TRUE(b1->isReleased());
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_TRUE(isAnyClientGained(b1->bufferState()));
-
-    EXPECT_EQ(b1->release(), 0);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, ReleaseBuffer_fromSelfInPostedState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_TRUE(isAnyClientPosted(b1->bufferState()));
-
-    EXPECT_EQ(b2->release(), 0);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, ReleaseBuffer_fromSelfInAcquiredState) {
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-    ASSERT_EQ(b2->acquire(), 0);
-    ASSERT_TRUE(isAnyClientAcquired(b1->bufferState()));
-
-    EXPECT_EQ(b2->release(), 0);
-}
-
-TEST_F(BufferHubBufferStateTransitionTest, BasicUsage) {
-    // 1 producer buffer and 1 consumer buffer initialised in testcase setup.
-    // Test if this set of basic operation succeed:
-    // Producer post three times to the consumer, and released by consumer.
-    for (int i = 0; i < 3; ++i) {
-        ASSERT_EQ(b1->gain(), 0);
-        ASSERT_EQ(b1->post(), 0);
-        ASSERT_EQ(b2->acquire(), 0);
-        ASSERT_EQ(b2->release(), 0);
-    }
-}
-
-TEST_F(BufferHubBufferTest, createNewConsumerAfterGain) {
-    // Create a poducer buffer and gain.
-    std::unique_ptr<BufferHubBuffer> b1 =
-            BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
-                                    kUserMetadataSize);
-    ASSERT_THAT(b1, NotNull());
-    ASSERT_EQ(b1->gain(), 0);
-
-    // Create a consumer of the buffer and test if the consumer can acquire the
-    // buffer if producer posts.
-    sp<NativeHandle> token = b1->duplicate();
-    ASSERT_THAT(token, NotNull());
-
-    std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::import(token);
-
-    ASSERT_THAT(b2, NotNull());
-    ASSERT_NE(b1->clientStateMask(), b2->clientStateMask());
-
-    ASSERT_EQ(b1->post(), 0);
-    EXPECT_EQ(b2->acquire(), 0);
-}
-
-TEST_F(BufferHubBufferTest, createNewConsumerAfterPost) {
-    // Create a poducer buffer and post.
-    std::unique_ptr<BufferHubBuffer> b1 =
-            BufferHubBuffer::create(kWidth, kHeight, kLayerCount, kFormat, kUsage,
-                                    kUserMetadataSize);
-    ASSERT_EQ(b1->gain(), 0);
-    ASSERT_EQ(b1->post(), 0);
-
-    // Create a consumer of the buffer and test if the consumer can acquire the
-    // buffer if producer posts.
-    sp<NativeHandle> token = b1->duplicate();
-    ASSERT_THAT(token, NotNull());
-
-    std::unique_ptr<BufferHubBuffer> b2 = BufferHubBuffer::import(token);
-
-    ASSERT_THAT(b2, NotNull());
-    ASSERT_NE(b1->clientStateMask(), b2->clientStateMask());
-
-    EXPECT_EQ(b2->acquire(), 0);
-}
-
-} // namespace
-
-} // namespace android
diff --git a/libs/ui/tests/BufferHubEventFd_test.cpp b/libs/ui/tests/BufferHubEventFd_test.cpp
deleted file mode 100644
index ef1781f..0000000
--- a/libs/ui/tests/BufferHubEventFd_test.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright 2018 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 "BufferHubEventFdTest"
-
-#include <sys/epoll.h>
-#include <sys/eventfd.h>
-
-#include <array>
-#include <condition_variable>
-#include <mutex>
-#include <thread>
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <log/log.h>
-#include <ui/BufferHubEventFd.h>
-
-namespace android {
-
-namespace {
-
-const int kTimeout = 100;
-const std::chrono::milliseconds kTimeoutMs(kTimeout);
-const int kTestRuns = 5;
-
-using ::testing::Contains;
-using BufferHubEventFdTest = ::testing::Test;
-
-} // namespace
-
-TEST_F(BufferHubEventFdTest, EventFd_testSingleEpollFd) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-
-    base::unique_fd epollFd(epoll_create(64));
-    ASSERT_GE(epollFd.get(), 0);
-
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-
-    std::array<epoll_event, 1> events;
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    eventFd.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-
-    // The epoll fd is edge triggered, so it only responds to the eventFd once.
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    // Check that it can receive consecutive signal.
-    eventFd.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    // Check that it can receive consecutive signal from a duplicated eventfd.
-    BufferHubEventFd dupEventFd(dup(eventFd.get()));
-    ASSERT_TRUE(dupEventFd.isValid());
-    dupEventFd.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-    dupEventFd.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testCreateEpollFdAndAddSignaledEventFd) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-    eventFd.signal();
-
-    base::unique_fd epollFd(epoll_create(64));
-    ASSERT_GE(epollFd.get(), 0);
-
-    // Make sure that the epoll set has not been signal yet.
-    std::array<epoll_event, 1> events;
-    ASSERT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    // Check that adding an signaled fd into this epoll set will trigger the epoll set.
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-
-    // The epoll fd is edge triggered, so it only responds to the eventFd once.
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testAddSignaledEventFdToEpollFd) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-
-    base::unique_fd epollFd(epoll_create(64));
-    ASSERT_GE(epollFd.get(), 0);
-
-    eventFd.signal();
-
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-
-    std::array<epoll_event, 1> events;
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-
-    // The epoll fd is edge triggered, so it only responds to the eventFd once.
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testConsecutiveSignalsFromAEventFd) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-    base::unique_fd epollFd(epoll_create(64));
-    ASSERT_GE(epollFd.get(), 0);
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-
-    std::array<epoll_event, 1> events;
-    for (int i = 0; i < kTestRuns; ++i) {
-        eventFd.signal();
-        EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-        EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-    }
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testConsecutiveSignalsFromADuplicatedEventFd) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-    base::unique_fd epollFd(epoll_create(64));
-    ASSERT_GE(epollFd.get(), 0);
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-
-    BufferHubEventFd dupEventFd(dup(eventFd.get()));
-    ASSERT_TRUE(dupEventFd.isValid());
-
-    std::array<epoll_event, 1> events;
-    for (int i = 0; i < kTestRuns; ++i) {
-        dupEventFd.signal();
-        EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-        EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-    }
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testClear) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-
-    base::unique_fd epollFd(epoll_create(64));
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-
-    ASSERT_GE(epollFd.get(), 0);
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-
-    eventFd.signal();
-    eventFd.clear();
-
-    std::array<epoll_event, 1> events;
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testDupEventFd) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-
-    base::unique_fd epollFd(epoll_create(64));
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-
-    ASSERT_GE(epollFd.get(), 0);
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-
-    // Technically, the dupliated eventFd and the original eventFd are pointing
-    // to the same kernel object. This test signals the duplicated eventFd but epolls the origianl
-    // eventFd.
-    BufferHubEventFd dupedEventFd(dup(eventFd.get()));
-    ASSERT_GE(dupedEventFd.get(), 0);
-
-    std::array<epoll_event, 1> events;
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    dupedEventFd.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-
-    // The epoll fd is edge triggered, so it only responds to the eventFd once.
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    dupedEventFd.signal();
-
-    dupedEventFd.clear();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testTwoEpollFds) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-
-    base::unique_fd epollFd1(epoll_create(64));
-    base::unique_fd epollFd2(epoll_create(64));
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-
-    ASSERT_GE(epollFd1.get(), 0);
-    ASSERT_GE(epollFd2.get(), 0);
-
-    // Register the same eventFd to two EpollFds.
-    ASSERT_EQ(epoll_ctl(epollFd1.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-    ASSERT_EQ(epoll_ctl(epollFd2.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-
-    std::array<epoll_event, 1> events;
-    EXPECT_EQ(epoll_wait(epollFd1.get(), events.data(), events.size(), 0), 0);
-    EXPECT_EQ(epoll_wait(epollFd2.get(), events.data(), events.size(), 0), 0);
-
-    eventFd.signal();
-    EXPECT_EQ(epoll_wait(epollFd1.get(), events.data(), events.size(), 0), 1);
-    EXPECT_EQ(epoll_wait(epollFd2.get(), events.data(), events.size(), 0), 1);
-
-    // The epoll fd is edge triggered, so it only responds to the eventFd once.
-    EXPECT_EQ(epoll_wait(epollFd1.get(), events.data(), events.size(), 0), 0);
-    EXPECT_EQ(epoll_wait(epollFd2.get(), events.data(), events.size(), 0), 0);
-
-    eventFd.signal();
-    EXPECT_EQ(epoll_wait(epollFd1.get(), events.data(), events.size(), 0), 1);
-
-    eventFd.clear();
-    EXPECT_EQ(epoll_wait(epollFd1.get(), events.data(), events.size(), 0), 0);
-    EXPECT_EQ(epoll_wait(epollFd2.get(), events.data(), events.size(), 0), 0);
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testTwoEventFds) {
-    BufferHubEventFd eventFd1;
-    BufferHubEventFd eventFd2;
-
-    ASSERT_TRUE(eventFd1.isValid());
-    ASSERT_TRUE(eventFd2.isValid());
-
-    base::unique_fd epollFd(epoll_create(64));
-    epoll_event e1 = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 1}};
-    epoll_event e2 = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 2}};
-
-    ASSERT_GE(epollFd.get(), 0);
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd1.get(), &e1), 0);
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd2.get(), &e2), 0);
-
-    std::array<epoll_event, 2> events;
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    // Signal one by one.
-    eventFd1.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-    EXPECT_EQ(events[0].data.u32, e1.data.u32);
-
-    eventFd2.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-    EXPECT_EQ(events[0].data.u32, e2.data.u32);
-
-    // Signal both.
-    eventFd1.signal();
-    eventFd2.signal();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 2);
-
-    uint32_t u32s[] = {events[0].data.u32, events[1].data.u32};
-    EXPECT_THAT(u32s, Contains(e1.data.u32));
-    EXPECT_THAT(u32s, Contains(e2.data.u32));
-
-    // The epoll fd is edge triggered, so it only responds to the eventFd once.
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 0);
-
-    eventFd1.signal();
-    eventFd2.signal();
-    eventFd2.clear();
-    EXPECT_EQ(epoll_wait(epollFd.get(), events.data(), events.size(), 0), 1);
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testPollingThreadWithTwoEventFds) {
-    BufferHubEventFd eventFd1;
-    BufferHubEventFd eventFd2;
-
-    ASSERT_TRUE(eventFd1.isValid());
-    ASSERT_TRUE(eventFd2.isValid());
-
-    base::unique_fd epollFd(epoll_create(64));
-    epoll_event e1 = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 1}};
-    epoll_event e2 = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 2}};
-
-    ASSERT_GE(epollFd.get(), 0);
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd1.get(), &e1), 0);
-    ASSERT_EQ(epoll_ctl(epollFd.get(), EPOLL_CTL_ADD, eventFd2.get(), &e2), 0);
-
-    int countEvent1 = 0;
-    int countEvent2 = 0;
-    std::atomic<bool> stop{false};
-    std::mutex mx;
-    std::condition_variable cv;
-
-    std::thread pollingThread([&] {
-        std::array<epoll_event, 2> events;
-        while (true) {
-            if (stop.load()) {
-                break;
-            }
-            int ret = epoll_wait(epollFd.get(), events.data(), events.size(), kTimeout);
-            ALOGE_IF(ret < 0 && errno != ETIMEDOUT, "Epoll failed.");
-
-            std::lock_guard<std::mutex> lock(mx);
-            for (int i = 0; i < ret; i++) {
-                if (events[i].data.u32 == e1.data.u32) {
-                    countEvent1++;
-                    cv.notify_one();
-                } else if (events[i].data.u32 == e2.data.u32) {
-                    countEvent2++;
-                    cv.notify_one();
-                }
-            }
-        }
-    });
-
-    {
-        std::unique_lock<std::mutex> lock(mx);
-
-        eventFd1.signal();
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEvent1 == 1; }));
-
-        eventFd1.signal();
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEvent1 == 2; }));
-
-        eventFd2.signal();
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEvent2 == 1; }));
-
-        eventFd1.clear();
-        eventFd2.clear();
-        EXPECT_EQ(countEvent1, 2);
-        EXPECT_EQ(countEvent2, 1);
-
-        eventFd1.signal();
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEvent1 == 3; }));
-
-        eventFd2.signal();
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEvent2 == 2; }));
-    }
-
-    stop.store(true);
-    pollingThread.join();
-}
-
-TEST_F(BufferHubEventFdTest, EventFd_testTwoPollingThreads) {
-    BufferHubEventFd eventFd;
-    ASSERT_TRUE(eventFd.isValid());
-
-    base::unique_fd epollFd1(epoll_create(64));
-    base::unique_fd epollFd2(epoll_create(64));
-    epoll_event e = {.events = EPOLLIN | EPOLLET, .data = {.u32 = 0}};
-
-    ASSERT_GE(epollFd1.get(), 0);
-    ASSERT_GE(epollFd2.get(), 0);
-
-    // Register the same eventFd to two EpollFds.
-    ASSERT_EQ(epoll_ctl(epollFd1.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-    ASSERT_EQ(epoll_ctl(epollFd2.get(), EPOLL_CTL_ADD, eventFd.get(), &e), 0);
-
-    int countEpoll1 = 0;
-    int countEpoll2 = 0;
-    std::atomic<bool> stop{false};
-    std::mutex mx;
-    std::condition_variable cv;
-
-    std::thread pollingThread1([&] {
-        std::array<epoll_event, 1> events;
-        while (!stop.load()) {
-            int ret = epoll_wait(epollFd1.get(), events.data(), events.size(), kTimeout);
-            ALOGE_IF(ret < 0 && errno != ETIMEDOUT, "Epoll failed.");
-
-            if (ret > 0) {
-                std::lock_guard<std::mutex> lock(mx);
-                countEpoll1++;
-                cv.notify_one();
-            }
-        }
-    });
-
-    std::thread pollingThread2([&] {
-        std::array<epoll_event, 1> events;
-        while (!stop.load()) {
-            int ret = epoll_wait(epollFd2.get(), events.data(), events.size(), kTimeout);
-            ALOGE_IF(ret < 0 && errno != ETIMEDOUT, "Epoll failed.");
-
-            if (ret > 0) {
-                std::lock_guard<std::mutex> lock(mx);
-                countEpoll2++;
-                cv.notify_one();
-            }
-        }
-    });
-
-    {
-        std::unique_lock<std::mutex> lock(mx);
-
-        eventFd.signal();
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEpoll1 == 1; }));
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEpoll2 == 1; }));
-
-        eventFd.signal();
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEpoll1 == 2; }));
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEpoll2 == 2; }));
-
-        eventFd.clear();
-        EXPECT_EQ(countEpoll1, 2);
-        EXPECT_EQ(countEpoll2, 2);
-
-        eventFd.signal();
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEpoll1 == 3; }));
-        EXPECT_TRUE(cv.wait_for(lock, kTimeoutMs, [&] { return countEpoll2 == 3; }));
-    }
-
-    stop.store(true);
-    pollingThread1.join();
-    pollingThread2.join();
-}
-
-} // namespace android
diff --git a/libs/ui/tests/BufferHubMetadata_test.cpp b/libs/ui/tests/BufferHubMetadata_test.cpp
deleted file mode 100644
index eb978ca..0000000
--- a/libs/ui/tests/BufferHubMetadata_test.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2018 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 <gtest/gtest.h>
-#include <ui/BufferHubMetadata.h>
-
-namespace android {
-namespace dvr {
-
-constexpr size_t kEmptyUserMetadataSize = 0;
-
-class BufferHubMetadataTest : public ::testing::Test {};
-
-TEST_F(BufferHubMetadataTest, Create_UserMetdataSizeTooBig) {
-    BufferHubMetadata m1 = BufferHubMetadata::create(std::numeric_limits<uint32_t>::max());
-    EXPECT_FALSE(m1.isValid());
-}
-
-TEST_F(BufferHubMetadataTest, Create_Success) {
-    BufferHubMetadata m1 = BufferHubMetadata::create(kEmptyUserMetadataSize);
-    EXPECT_TRUE(m1.isValid());
-    EXPECT_NE(m1.metadataHeader(), nullptr);
-}
-
-TEST_F(BufferHubMetadataTest, Import_Success) {
-    BufferHubMetadata m1 = BufferHubMetadata::create(kEmptyUserMetadataSize);
-    EXPECT_TRUE(m1.isValid());
-    EXPECT_NE(m1.metadataHeader(), nullptr);
-
-    unique_fd h2 = unique_fd(dup(m1.ashmemFd().get()));
-    EXPECT_NE(h2.get(), -1);
-
-    BufferHubMetadata m2 = BufferHubMetadata::import(std::move(h2));
-    EXPECT_EQ(h2.get(), -1);
-    EXPECT_TRUE(m1.isValid());
-    BufferHubDefs::MetadataHeader* mh1 = m1.metadataHeader();
-    EXPECT_NE(mh1, nullptr);
-
-    // Check if the newly allocated buffer is initialized in released state (i.e.
-    // state equals to 0U).
-    EXPECT_TRUE(mh1->bufferState.load() == 0U);
-
-    EXPECT_TRUE(m2.isValid());
-    BufferHubDefs::MetadataHeader* mh2 = m2.metadataHeader();
-    EXPECT_NE(mh2, nullptr);
-
-    // Check if the newly allocated buffer is initialized in released state (i.e.
-    // state equals to 0U).
-    EXPECT_TRUE(mh2->bufferState.load() == 0U);
-}
-
-TEST_F(BufferHubMetadataTest, MoveMetadataInvalidatesOldOne) {
-    BufferHubMetadata m1 = BufferHubMetadata::create(sizeof(int));
-    EXPECT_TRUE(m1.isValid());
-    EXPECT_NE(m1.metadataHeader(), nullptr);
-    EXPECT_NE(m1.ashmemFd().get(), -1);
-    EXPECT_EQ(m1.userMetadataSize(), sizeof(int));
-
-    BufferHubMetadata m2 = std::move(m1);
-
-    // After the move, the metadata header (a raw pointer) should be reset in the older buffer.
-    EXPECT_EQ(m1.metadataHeader(), nullptr);
-    EXPECT_NE(m2.metadataHeader(), nullptr);
-
-    EXPECT_EQ(m1.ashmemFd().get(), -1);
-    EXPECT_NE(m2.ashmemFd().get(), -1);
-
-    EXPECT_EQ(m1.userMetadataSize(), 0U);
-    EXPECT_EQ(m2.userMetadataSize(), sizeof(int));
-
-    BufferHubMetadata m3{std::move(m2)};
-
-    // After the move, the metadata header (a raw pointer) should be reset in the older buffer.
-    EXPECT_EQ(m2.metadataHeader(), nullptr);
-    EXPECT_NE(m3.metadataHeader(), nullptr);
-
-    EXPECT_EQ(m2.ashmemFd().get(), -1);
-    EXPECT_NE(m3.ashmemFd().get(), -1);
-
-    EXPECT_EQ(m2.userMetadataSize(), 0U);
-    EXPECT_EQ(m3.userMetadataSize(), sizeof(int));
-}
-
-}  // namespace dvr
-}  // namespace android
diff --git a/libs/ui/tests/GraphicBufferOverBinder_test.cpp b/libs/ui/tests/GraphicBufferOverBinder_test.cpp
index 7c0a44a..126a945 100644
--- a/libs/ui/tests/GraphicBufferOverBinder_test.cpp
+++ b/libs/ui/tests/GraphicBufferOverBinder_test.cpp
@@ -23,7 +23,6 @@
 #include <gui/BufferQueue.h>
 #include <gui/IGraphicBufferConsumer.h>
 #include <gui/IGraphicBufferProducer.h>
-#include <ui/BufferHubBuffer.h>
 #include <ui/GraphicBuffer.h>
 #include <utils/Log.h>
 
@@ -37,7 +36,6 @@
 static const String16 kTestServiceName = String16("GraphicBufferOverBinderTestService");
 enum GraphicBufferOverBinderTestServiceCode {
     GRAPHIC_BUFFER = IBinder::FIRST_CALL_TRANSACTION,
-    GRAPHIC_BUFFER_FROM_BUFFER_HUB_BUFFER,
 };
 
 class GraphicBufferOverBinderTestService : public BBinder {
@@ -46,21 +44,6 @@
         // GraphicBuffer
         mGraphicBuffer = new GraphicBuffer(kTestWidth, kTestHeight, kTestFormat, kTestLayerCount,
                                            kTestUsage);
-        ALOGI("mGraphicBuffer id %" PRIi32, mGraphicBuffer->getBufferId());
-
-        // BufferHub-backed GraphicBuffer
-        std::unique_ptr<BufferHubBuffer> bufferHubBuffer =
-                BufferHubBuffer::create(kTestWidth, kTestHeight, kTestLayerCount, kTestFormat,
-                                        kTestUsage, /*userMetadataSize=*/0);
-        mBufferhubBackedGraphicBuffer = new GraphicBuffer(std::move(bufferHubBuffer));
-        if (!mBufferhubBackedGraphicBuffer->isBufferHubBuffer()) {
-            ALOGE("Failed to back GraphicBuffer with BufferHub.");
-        }
-        if (bufferHubBuffer != nullptr) {
-            ALOGE("Failed to move BufferHubBuffer to GraphicBuffer");
-        }
-        ALOGI("mBufferhubBackedGraphicBuffer id %" PRIi32,
-              mBufferhubBackedGraphicBuffer->getBufferId());
     }
 
     ~GraphicBufferOverBinderTestService() = default;
@@ -71,9 +54,6 @@
             case GRAPHIC_BUFFER: {
                 return reply->write(*mGraphicBuffer);
             }
-            case GRAPHIC_BUFFER_FROM_BUFFER_HUB_BUFFER: {
-                return reply->write(*mBufferhubBackedGraphicBuffer);
-            }
             default:
                 return UNKNOWN_TRANSACTION;
         };
@@ -81,7 +61,6 @@
 
 protected:
     sp<GraphicBuffer> mGraphicBuffer;
-    sp<GraphicBuffer> mBufferhubBackedGraphicBuffer;
 };
 
 static int runBinderServer() {
@@ -138,17 +117,6 @@
     sp<GraphicBuffer> gb;
     EXPECT_EQ(GetGraphicBuffer(&gb, GRAPHIC_BUFFER), OK);
     EXPECT_NE(gb, nullptr);
-    EXPECT_FALSE(gb->isBufferHubBuffer());
-    void* vaddr;
-    EXPECT_EQ(gb->lock(kTestUsage, &vaddr), OK);
-    EXPECT_EQ(gb->unlock(), OK);
-}
-
-TEST_F(GraphicBufferOverBinderTest, SendGraphicBufferFromBufferHubBufferOverBinder) {
-    sp<GraphicBuffer> gb;
-    EXPECT_EQ(GetGraphicBuffer(&gb, GRAPHIC_BUFFER_FROM_BUFFER_HUB_BUFFER), NO_ERROR);
-    EXPECT_NE(gb, nullptr);
-    EXPECT_TRUE(gb->isBufferHubBuffer());
     void* vaddr;
     EXPECT_EQ(gb->lock(kTestUsage, &vaddr), OK);
     EXPECT_EQ(gb->unlock(), OK);
diff --git a/libs/ui/tests/GraphicBuffer_test.cpp b/libs/ui/tests/GraphicBuffer_test.cpp
index 5e0b094..19551b3 100644
--- a/libs/ui/tests/GraphicBuffer_test.cpp
+++ b/libs/ui/tests/GraphicBuffer_test.cpp
@@ -16,7 +16,6 @@
 
 #define LOG_TAG "GraphicBufferTest"
 
-#include <ui/BufferHubBuffer.h>
 #include <ui/GraphicBuffer.h>
 
 #include <gtest/gtest.h>
@@ -27,7 +26,6 @@
 
 constexpr uint32_t kTestWidth = 1024;
 constexpr uint32_t kTestHeight = 1;
-constexpr uint32_t kTestFormat = HAL_PIXEL_FORMAT_BLOB;
 constexpr uint32_t kTestLayerCount = 1;
 constexpr uint64_t kTestUsage = GraphicBuffer::USAGE_SW_WRITE_OFTEN;
 
@@ -68,88 +66,4 @@
     ASSERT_EQ(BAD_VALUE, gb2->initCheck());
 }
 
-TEST_F(GraphicBufferTest, CreateFromBufferHubBuffer) {
-    std::unique_ptr<BufferHubBuffer> b1 =
-            BufferHubBuffer::create(kTestWidth, kTestHeight, kTestLayerCount, kTestFormat,
-                                    kTestUsage, /*userMetadataSize=*/0);
-    ASSERT_NE(b1, nullptr);
-    EXPECT_TRUE(b1->isValid());
-
-    sp<GraphicBuffer> gb(new GraphicBuffer(std::move(b1)));
-    EXPECT_TRUE(gb->isBufferHubBuffer());
-
-    EXPECT_EQ(gb->getWidth(), kTestWidth);
-    EXPECT_EQ(gb->getHeight(), kTestHeight);
-    EXPECT_EQ(static_cast<uint32_t>(gb->getPixelFormat()), kTestFormat);
-    EXPECT_EQ(gb->getUsage(), kTestUsage);
-    EXPECT_EQ(gb->getLayerCount(), kTestLayerCount);
-}
-
-TEST_F(GraphicBufferTest, InvalidBufferIdForNoneBufferHubBuffer) {
-    sp<GraphicBuffer> gb(
-            new GraphicBuffer(kTestWidth, kTestHeight, kTestFormat, kTestLayerCount, kTestUsage));
-    EXPECT_FALSE(gb->isBufferHubBuffer());
-    EXPECT_EQ(gb->getBufferId(), -1);
-}
-
-TEST_F(GraphicBufferTest, BufferIdMatchesBufferHubBufferId) {
-    std::unique_ptr<BufferHubBuffer> b1 =
-            BufferHubBuffer::create(kTestWidth, kTestHeight, kTestLayerCount, kTestFormat,
-                                    kTestUsage, /*userMetadataSize=*/0);
-    EXPECT_NE(b1, nullptr);
-    EXPECT_TRUE(b1->isValid());
-
-    int b1_id = b1->id();
-    EXPECT_GE(b1_id, 0);
-
-    sp<GraphicBuffer> gb(new GraphicBuffer(std::move(b1)));
-    EXPECT_TRUE(gb->isBufferHubBuffer());
-    EXPECT_EQ(gb->getBufferId(), b1_id);
-}
-
-TEST_F(GraphicBufferTest, flattenAndUnflatten) {
-    std::unique_ptr<BufferHubBuffer> b1 =
-            BufferHubBuffer::create(kTestWidth, kTestHeight, kTestLayerCount, kTestFormat,
-                                    kTestUsage, /*userMetadataSize=*/0);
-    ASSERT_NE(b1, nullptr);
-    sp<GraphicBuffer> gb1(new GraphicBuffer(std::move(b1)));
-    gb1->setGenerationNumber(42);
-
-    size_t flattenedSize = gb1->getFlattenedSize();
-    EXPECT_EQ(flattenedSize, 48);
-    size_t fdCount = gb1->getFdCount();
-    EXPECT_EQ(fdCount, 0);
-
-    int data[flattenedSize];
-    int fds[0];
-
-    // Make copies of needed items since flatten modifies them.
-    size_t flattenedSizeCopy = flattenedSize;
-    size_t fdCountCopy = fdCount;
-    void* dataStart = data;
-    int* fdsStart = fds;
-    status_t err = gb1->flatten(dataStart, flattenedSizeCopy, fdsStart, fdCountCopy);
-    ASSERT_EQ(err, NO_ERROR);
-    EXPECT_EQ(flattenedSizeCopy, 0);
-    EXPECT_EQ(fdCountCopy, 0);
-
-    size_t unflattenSize = flattenedSize;
-    size_t unflattenFdCount = fdCount;
-    const void* unflattenData = static_cast<const void*>(dataStart);
-    const int* unflattenFdData = static_cast<const int*>(fdsStart);
-
-    GraphicBuffer* gb2 = new GraphicBuffer();
-    err = gb2->unflatten(unflattenData, unflattenSize, unflattenFdData, unflattenFdCount);
-    ASSERT_EQ(err, NO_ERROR);
-    EXPECT_TRUE(gb2->isBufferHubBuffer());
-
-    EXPECT_EQ(gb2->getWidth(), kTestWidth);
-    EXPECT_EQ(gb2->getHeight(), kTestHeight);
-    EXPECT_EQ(static_cast<uint32_t>(gb2->getPixelFormat()), kTestFormat);
-    EXPECT_EQ(gb2->getUsage(), kTestUsage);
-    EXPECT_EQ(gb2->getLayerCount(), kTestLayerCount);
-    EXPECT_EQ(gb1->getBufferId(), gb2->getBufferId());
-    EXPECT_EQ(gb2->getGenerationNumber(), 42);
-}
-
 } // namespace android
diff --git a/services/bufferhub/Android.bp b/services/bufferhub/Android.bp
deleted file mode 100644
index 2bb6aef..0000000
--- a/services/bufferhub/Android.bp
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// Copyright (C) 2018 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: "libbufferhubservice",
-    cflags: [
-        "-DLOG_TAG=\"libbufferhubservice\"",
-        "-Wall",
-        "-Werror",
-        "-Wextra",
-    ],
-    srcs: [
-        "BufferClient.cpp",
-        "BufferHubIdGenerator.cpp",
-        "BufferHubService.cpp",
-        "BufferNode.cpp",
-    ],
-    header_libs: [
-        "libdvr_headers",
-        "libnativewindow_headers",
-    ],
-    shared_libs: [
-        "android.frameworks.bufferhub@1.0",
-        "libcrypto",
-        "libcutils",
-        "libhidlbase",
-        "liblog",
-        "libui",
-        "libutils",
-    ],
-    export_include_dirs: [
-        "include"
-    ],
-}
-
-cc_binary {
-    name: "android.frameworks.bufferhub@1.0-service",
-    relative_install_path: "hw",
-    srcs: [
-        "main_bufferhub.cpp"
-    ],
-    header_libs: [
-        "libdvr_headers",
-        "libnativewindow_headers",
-    ],
-    shared_libs: [
-        "android.frameworks.bufferhub@1.0",
-        "libbufferhubservice",
-        "libcrypto",
-        "libcutils",
-        "libhidlbase",
-        "liblog",
-        "libui",
-        "libutils",
-    ],
-    cflags: [
-        "-DLOG_TAG=\"bufferhub\"",
-        "-Wall",
-        "-Werror",
-        "-Wextra",
-    ],
-    init_rc: ["android.frameworks.bufferhub@1.0-service.rc"],
-    vintf_fragments: ["android.frameworks.bufferhub@1.0-service.xml"],
-}
diff --git a/services/bufferhub/BufferClient.cpp b/services/bufferhub/BufferClient.cpp
deleted file mode 100644
index ec7e535..0000000
--- a/services/bufferhub/BufferClient.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2018 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 <bufferhub/BufferClient.h>
-#include <bufferhub/BufferHubService.h>
-#include <hidl/HidlSupport.h>
-#include <log/log.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-using hardware::hidl_handle;
-using hardware::Void;
-
-BufferClient* BufferClient::create(BufferHubService* service,
-                                   const std::shared_ptr<BufferNode>& node) {
-    if (!service) {
-        ALOGE("%s: service cannot be nullptr.", __FUNCTION__);
-        return nullptr;
-    } else if (!node) {
-        ALOGE("%s: node cannot be nullptr.", __FUNCTION__);
-        return nullptr;
-    }
-    return new BufferClient(service, node);
-}
-
-BufferClient::~BufferClient() {
-    {
-        std::lock_guard<std::mutex> lock(mClosedMutex);
-        if (!mClosed) {
-            ALOGW("%s: client of buffer #%d destroyed without close. Closing it now.", __FUNCTION__,
-                  mBufferNode->id());
-        }
-    }
-
-    close();
-}
-
-Return<BufferHubStatus> BufferClient::close() {
-    std::lock_guard<std::mutex> lock(mClosedMutex);
-    if (mClosed) {
-        return BufferHubStatus::CLIENT_CLOSED;
-    }
-
-    getService()->onClientClosed(this);
-    mBufferNode.reset();
-    mClosed = true;
-    return BufferHubStatus::NO_ERROR;
-}
-
-Return<void> BufferClient::duplicate(duplicate_cb _hidl_cb) {
-    std::lock_guard<std::mutex> lock(mClosedMutex);
-    if (mClosed) {
-        _hidl_cb(/*token=*/hidl_handle(), /*status=*/BufferHubStatus::CLIENT_CLOSED);
-        return Void();
-    }
-
-    if (!mBufferNode) {
-        // Should never happen
-        ALOGE("%s: node is missing.", __FUNCTION__);
-        _hidl_cb(/*token=*/hidl_handle(), /*status=*/BufferHubStatus::BUFFER_FREED);
-        return Void();
-    }
-
-    const hidl_handle token = getService()->registerToken(this);
-    _hidl_cb(/*token=*/token, /*status=*/BufferHubStatus::NO_ERROR);
-    return Void();
-}
-
-sp<BufferHubService> BufferClient::getService() {
-    sp<BufferHubService> service = mService.promote();
-    if (service == nullptr) {
-        // Should never happen. Kill the process.
-        LOG_FATAL("%s: service died.", __FUNCTION__);
-    }
-
-    return service;
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
\ No newline at end of file
diff --git a/services/bufferhub/BufferHubIdGenerator.cpp b/services/bufferhub/BufferHubIdGenerator.cpp
deleted file mode 100644
index 2c12f0e..0000000
--- a/services/bufferhub/BufferHubIdGenerator.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2018 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 <bufferhub/BufferHubIdGenerator.h>
-#include <log/log.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-BufferHubIdGenerator& BufferHubIdGenerator::getInstance() {
-    static BufferHubIdGenerator generator;
-
-    return generator;
-}
-
-int BufferHubIdGenerator::getId() {
-    std::lock_guard<std::mutex> lock(mIdsInUseMutex);
-
-    do {
-        if (++mLastId >= std::numeric_limits<int>::max()) {
-            mLastId = 0;
-        }
-    } while (mIdsInUse.find(mLastId) != mIdsInUse.end());
-
-    mIdsInUse.insert(mLastId);
-    return mLastId;
-}
-
-void BufferHubIdGenerator::freeId(int id) {
-    std::lock_guard<std::mutex> lock(mIdsInUseMutex);
-    auto iter = mIdsInUse.find(id);
-    if (iter != mIdsInUse.end()) {
-        mIdsInUse.erase(iter);
-    } else {
-        ALOGW("%s: Cannot free nonexistent id #%d", __FUNCTION__, id);
-    }
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
diff --git a/services/bufferhub/BufferHubService.cpp b/services/bufferhub/BufferHubService.cpp
deleted file mode 100644
index 7a3472f..0000000
--- a/services/bufferhub/BufferHubService.cpp
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * Copyright (C) 2018 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 <array>
-#include <iomanip>
-#include <random>
-#include <sstream>
-
-#include <android/hardware_buffer.h>
-#include <bufferhub/BufferHubService.h>
-#include <cutils/native_handle.h>
-#include <log/log.h>
-#include <openssl/hmac.h>
-#include <system/graphics-base.h>
-#include <ui/BufferHubDefs.h>
-
-using ::android::BufferHubDefs::MetadataHeader;
-using ::android::hardware::Void;
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-BufferHubService::BufferHubService() {
-    std::mt19937_64 randomEngine;
-    randomEngine.seed(time(nullptr));
-
-    mKey = randomEngine();
-}
-
-Return<void> BufferHubService::allocateBuffer(const HardwareBufferDescription& description,
-                                              const uint32_t userMetadataSize,
-                                              allocateBuffer_cb _hidl_cb) {
-    AHardwareBuffer_Desc desc;
-    memcpy(&desc, &description, sizeof(AHardwareBuffer_Desc));
-
-    std::shared_ptr<BufferNode> node =
-            std::make_shared<BufferNode>(desc.width, desc.height, desc.layers, desc.format,
-                                         desc.usage, userMetadataSize,
-                                         BufferHubIdGenerator::getInstance().getId());
-    if (node == nullptr || !node->isValid()) {
-        ALOGE("%s: creating BufferNode failed.", __FUNCTION__);
-        _hidl_cb(/*status=*/BufferHubStatus::ALLOCATION_FAILED, /*bufferClient=*/nullptr,
-                 /*bufferTraits=*/{});
-        return Void();
-    }
-
-    sp<BufferClient> client = BufferClient::create(this, node);
-    // Add it to list for bookkeeping and dumpsys.
-    std::lock_guard<std::mutex> lock(mClientSetMutex);
-    mClientSet.emplace(client);
-
-    // Allocate memory for bufferInfo of type hidl_handle on the stack. See
-    // http://aosp/286282 for the usage of NATIVE_HANDLE_DECLARE_STORAGE.
-    NATIVE_HANDLE_DECLARE_STORAGE(bufferInfoStorage, BufferHubDefs::kBufferInfoNumFds,
-                                  BufferHubDefs::kBufferInfoNumInts);
-    hidl_handle bufferInfo =
-            buildBufferInfo(bufferInfoStorage, node->id(), node->addNewActiveClientsBitToMask(),
-                            node->userMetadataSize(), node->metadata().ashmemFd(),
-                            node->eventFd().get());
-    // During the gralloc allocation carried out by BufferNode, gralloc allocator will populate the
-    // fields of its HardwareBufferDescription (i.e. strides) according to the actual
-    // gralloc implementation. We need to read those fields back and send them to the client via
-    // BufferTraits.
-    HardwareBufferDescription allocatedBufferDesc;
-    memcpy(&allocatedBufferDesc, &node->bufferDesc(), sizeof(AHardwareBuffer_Desc));
-    BufferTraits bufferTraits = {/*bufferDesc=*/allocatedBufferDesc,
-                                 /*bufferHandle=*/hidl_handle(node->bufferHandle()),
-                                 /*bufferInfo=*/std::move(bufferInfo)};
-
-    _hidl_cb(/*status=*/BufferHubStatus::NO_ERROR, /*bufferClient=*/client,
-             /*bufferTraits=*/std::move(bufferTraits));
-    return Void();
-}
-
-Return<void> BufferHubService::importBuffer(const hidl_handle& tokenHandle,
-                                            importBuffer_cb _hidl_cb) {
-    if (!tokenHandle.getNativeHandle() || tokenHandle->numFds != 0 || tokenHandle->numInts <= 1) {
-        // nullptr handle or wrong format
-        _hidl_cb(/*status=*/BufferHubStatus::INVALID_TOKEN, /*bufferClient=*/nullptr,
-                 /*bufferTraits=*/{});
-        return Void();
-    }
-
-    int tokenId = tokenHandle->data[0];
-
-    wp<BufferClient> originClientWp;
-    {
-        std::lock_guard<std::mutex> lock(mTokenMutex);
-        auto iter = mTokenMap.find(tokenId);
-        if (iter == mTokenMap.end()) {
-            // Token Id not exist
-            ALOGD("%s: token #%d not found.", __FUNCTION__, tokenId);
-            _hidl_cb(/*status=*/BufferHubStatus::INVALID_TOKEN, /*bufferClient=*/nullptr,
-                     /*bufferTraits=*/{});
-            return Void();
-        }
-
-        const std::vector<uint8_t>& tokenHMAC = iter->second.first;
-
-        int numIntsForHMAC = (int)ceil(tokenHMAC.size() * sizeof(uint8_t) / (double)sizeof(int));
-        if (tokenHandle->numInts - 1 != numIntsForHMAC) {
-            // HMAC size not match
-            ALOGD("%s: token #%d HMAC size not match. Expected: %d Actual: %d", __FUNCTION__,
-                  tokenId, numIntsForHMAC, tokenHandle->numInts - 1);
-            _hidl_cb(/*status=*/BufferHubStatus::INVALID_TOKEN, /*bufferClient=*/nullptr,
-                     /*bufferTraits=*/{});
-            return Void();
-        }
-
-        size_t hmacSize = tokenHMAC.size() * sizeof(uint8_t);
-        if (memcmp(tokenHMAC.data(), &tokenHandle->data[1], hmacSize) != 0) {
-            // HMAC not match
-            ALOGD("%s: token #%d HMAC not match.", __FUNCTION__, tokenId);
-            _hidl_cb(/*status=*/BufferHubStatus::INVALID_TOKEN, /*bufferClient=*/nullptr,
-                     /*bufferTraits=*/{});
-            return Void();
-        }
-
-        originClientWp = iter->second.second;
-        mTokenMap.erase(iter);
-    }
-
-    // Check if original client is dead
-    sp<BufferClient> originClient = originClientWp.promote();
-    if (!originClient) {
-        // Should not happen since token should be removed if already gone
-        ALOGE("%s: original client %p gone!", __FUNCTION__, originClientWp.unsafe_get());
-        _hidl_cb(/*status=*/BufferHubStatus::BUFFER_FREED, /*bufferClient=*/nullptr,
-                 /*bufferTraits=*/{});
-        return Void();
-    }
-
-    sp<BufferClient> client = new BufferClient(*originClient);
-    uint32_t clientStateMask = client->getBufferNode()->addNewActiveClientsBitToMask();
-    if (clientStateMask == 0U) {
-        // Reach max client count
-        ALOGE("%s: import failed, BufferNode#%u reached maximum clients.", __FUNCTION__,
-              client->getBufferNode()->id());
-        _hidl_cb(/*status=*/BufferHubStatus::MAX_CLIENT, /*bufferClient=*/nullptr,
-                 /*bufferTraits=*/{});
-        return Void();
-    }
-
-    std::lock_guard<std::mutex> lock(mClientSetMutex);
-    mClientSet.emplace(client);
-
-    std::shared_ptr<BufferNode> node = client->getBufferNode();
-
-    HardwareBufferDescription bufferDesc;
-    memcpy(&bufferDesc, &node->bufferDesc(), sizeof(HardwareBufferDescription));
-
-    // Allocate memory for bufferInfo of type hidl_handle on the stack. See
-    // http://aosp/286282 for the usage of NATIVE_HANDLE_DECLARE_STORAGE.
-    NATIVE_HANDLE_DECLARE_STORAGE(bufferInfoStorage, BufferHubDefs::kBufferInfoNumFds,
-                                  BufferHubDefs::kBufferInfoNumInts);
-    hidl_handle bufferInfo = buildBufferInfo(bufferInfoStorage, node->id(), clientStateMask,
-                                             node->userMetadataSize(), node->metadata().ashmemFd(),
-                                             node->eventFd().get());
-    BufferTraits bufferTraits = {/*bufferDesc=*/bufferDesc,
-                                 /*bufferHandle=*/hidl_handle(node->bufferHandle()),
-                                 /*bufferInfo=*/std::move(bufferInfo)};
-
-    _hidl_cb(/*status=*/BufferHubStatus::NO_ERROR, /*bufferClient=*/client,
-             /*bufferTraits=*/std::move(bufferTraits));
-    return Void();
-}
-
-Return<void> BufferHubService::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) {
-    if (fd.getNativeHandle() == nullptr || fd->numFds < 1) {
-        ALOGE("%s: missing fd for writing.", __FUNCTION__);
-        return Void();
-    }
-
-    FILE* out = fdopen(dup(fd->data[0]), "w");
-
-    if (args.size() != 0) {
-        fprintf(out,
-                "Note: lshal bufferhub currently does not support args. Input arguments are "
-                "ignored.\n");
-    }
-
-    std::ostringstream stream;
-
-    // Get the number of clients of each buffer.
-    // Map from bufferId to bufferNode_clientCount pair.
-    std::map<int, std::pair<const std::shared_ptr<BufferNode>, uint32_t>> clientCount;
-    {
-        std::lock_guard<std::mutex> lock(mClientSetMutex);
-        for (auto iter = mClientSet.begin(); iter != mClientSet.end(); ++iter) {
-            sp<BufferClient> client = iter->promote();
-            if (client != nullptr) {
-                const std::shared_ptr<BufferNode> node = client->getBufferNode();
-                auto mapIter = clientCount.find(node->id());
-                if (mapIter != clientCount.end()) {
-                    ++mapIter->second.second;
-                } else {
-                    clientCount.emplace(node->id(),
-                                        std::pair<std::shared_ptr<BufferNode>, uint32_t>(node, 1U));
-                }
-            }
-        }
-    }
-
-    stream << "Active Buffers:\n";
-    stream << std::right;
-    stream << std::setw(6) << "Id";
-    stream << " ";
-    stream << std::setw(9) << "#Clients";
-    stream << " ";
-    stream << std::setw(14) << "Geometry";
-    stream << " ";
-    stream << std::setw(6) << "Format";
-    stream << " ";
-    stream << std::setw(10) << "Usage";
-    stream << " ";
-    stream << std::setw(10) << "State";
-    stream << " ";
-    stream << std::setw(8) << "Index";
-    stream << std::endl;
-
-    for (auto iter = clientCount.begin(); iter != clientCount.end(); ++iter) {
-        const std::shared_ptr<BufferNode> node = std::move(iter->second.first);
-        const uint32_t clientCount = iter->second.second;
-        AHardwareBuffer_Desc desc = node->bufferDesc();
-
-        MetadataHeader* metadataHeader =
-                const_cast<BufferHubMetadata*>(&node->metadata())->metadataHeader();
-        const uint32_t state = metadataHeader->bufferState.load(std::memory_order_acquire);
-        const uint64_t index = metadataHeader->queueIndex;
-
-        stream << std::right;
-        stream << std::setw(6) << /*Id=*/node->id();
-        stream << " ";
-        stream << std::setw(9) << /*#Clients=*/clientCount;
-        stream << " ";
-        if (desc.format == HAL_PIXEL_FORMAT_BLOB) {
-            std::string size = std::to_string(desc.width) + " B";
-            stream << std::setw(14) << /*Geometry=*/size;
-        } else {
-            std::string dimensions = std::to_string(desc.width) + "x" +
-                    std::to_string(desc.height) + "x" + std::to_string(desc.layers);
-            stream << std::setw(14) << /*Geometry=*/dimensions;
-        }
-        stream << " ";
-        stream << std::setw(6) << /*Format=*/desc.format;
-        stream << " ";
-        stream << "0x" << std::hex << std::setfill('0');
-        stream << std::setw(8) << /*Usage=*/desc.usage;
-        stream << std::dec << std::setfill(' ');
-        stream << " ";
-        stream << "0x" << std::hex << std::setfill('0');
-        stream << std::setw(8) << /*State=*/state;
-        stream << std::dec << std::setfill(' ');
-        stream << " ";
-        stream << std::setw(8) << /*Index=*/index;
-        stream << std::endl;
-    }
-
-    stream << std::endl;
-
-    // Get the number of tokens of each buffer.
-    // Map from bufferId to tokenCount
-    std::map<int, uint32_t> tokenCount;
-    {
-        std::lock_guard<std::mutex> lock(mTokenMutex);
-        for (auto iter = mTokenMap.begin(); iter != mTokenMap.end(); ++iter) {
-            sp<BufferClient> client = iter->second.second.promote();
-            if (client != nullptr) {
-                const std::shared_ptr<BufferNode> node = client->getBufferNode();
-                auto mapIter = tokenCount.find(node->id());
-                if (mapIter != tokenCount.end()) {
-                    ++mapIter->second;
-                } else {
-                    tokenCount.emplace(node->id(), 1U);
-                }
-            }
-        }
-    }
-
-    stream << "Unused Tokens:\n";
-    stream << std::right;
-    stream << std::setw(8) << "Buffer Id";
-    stream << " ";
-    stream << std::setw(7) << "#Tokens";
-    stream << std::endl;
-
-    for (auto iter = tokenCount.begin(); iter != tokenCount.end(); ++iter) {
-        stream << std::right;
-        stream << std::setw(8) << /*Buffer Id=*/iter->first;
-        stream << " ";
-        stream << std::setw(7) << /*#Tokens=*/iter->second;
-        stream << std::endl;
-    }
-
-    fprintf(out, "%s", stream.str().c_str());
-
-    fclose(out);
-    return Void();
-}
-
-hidl_handle BufferHubService::registerToken(const wp<BufferClient>& client) {
-    // Find next available token id
-    std::lock_guard<std::mutex> lock(mTokenMutex);
-    do {
-        ++mLastTokenId;
-    } while (mTokenMap.find(mLastTokenId) != mTokenMap.end());
-
-    std::array<uint8_t, EVP_MAX_MD_SIZE> hmac;
-    uint32_t hmacSize = 0U;
-
-    HMAC(/*evp_md=*/EVP_sha256(), /*key=*/&mKey, /*key_len=*/kKeyLen,
-         /*data=*/(uint8_t*)&mLastTokenId, /*data_len=*/mTokenIdSize,
-         /*out=*/hmac.data(), /*out_len=*/&hmacSize);
-
-    int numIntsForHMAC = (int)ceil(hmacSize / (double)sizeof(int));
-    native_handle_t* handle = native_handle_create(/*numFds=*/0, /*numInts=*/1 + numIntsForHMAC);
-    handle->data[0] = mLastTokenId;
-    // Set all the the bits of last int to 0 since it might not be fully overwritten
-    handle->data[numIntsForHMAC] = 0;
-    memcpy(&handle->data[1], hmac.data(), hmacSize);
-
-    // returnToken owns the native_handle_t* thus doing lifecycle management
-    hidl_handle returnToken;
-    returnToken.setTo(handle, /*shoudOwn=*/true);
-
-    std::vector<uint8_t> hmacVec;
-    hmacVec.resize(hmacSize);
-    memcpy(hmacVec.data(), hmac.data(), hmacSize);
-    mTokenMap.emplace(mLastTokenId, std::pair(hmacVec, client));
-
-    return returnToken;
-}
-
-void BufferHubService::onClientClosed(const BufferClient* client) {
-    removeTokenByClient(client);
-
-    std::lock_guard<std::mutex> lock(mClientSetMutex);
-    auto iter = std::find(mClientSet.begin(), mClientSet.end(), client);
-    if (iter != mClientSet.end()) {
-        mClientSet.erase(iter);
-    }
-}
-
-// Implementation of this function should be consistent with the definition of bufferInfo handle in
-// ui/BufferHubDefs.h.
-hidl_handle BufferHubService::buildBufferInfo(char* bufferInfoStorage, int bufferId,
-                                              uint32_t clientBitMask, uint32_t userMetadataSize,
-                                              int metadataFd, int eventFd) {
-    native_handle_t* infoHandle =
-            native_handle_init(bufferInfoStorage, BufferHubDefs::kBufferInfoNumFds,
-                               BufferHubDefs::kBufferInfoNumInts);
-
-    infoHandle->data[0] = metadataFd;
-    infoHandle->data[1] = eventFd;
-    infoHandle->data[2] = bufferId;
-    // Use memcpy to convert to int without missing digit.
-    // TOOD(b/121345852): use bit_cast to unpack bufferInfo when C++20 becomes available.
-    memcpy(&infoHandle->data[3], &clientBitMask, sizeof(clientBitMask));
-    memcpy(&infoHandle->data[4], &userMetadataSize, sizeof(userMetadataSize));
-
-    hidl_handle bufferInfo;
-    bufferInfo.setTo(infoHandle, /*shouldOwn=*/false);
-
-    return bufferInfo;
-}
-
-void BufferHubService::removeTokenByClient(const BufferClient* client) {
-    std::lock_guard<std::mutex> lock(mTokenMutex);
-    auto iter = mTokenMap.begin();
-    while (iter != mTokenMap.end()) {
-        if (iter->second.second == client) {
-            auto oldIter = iter;
-            ++iter;
-            mTokenMap.erase(oldIter);
-        } else {
-            ++iter;
-        }
-    }
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
diff --git a/services/bufferhub/BufferNode.cpp b/services/bufferhub/BufferNode.cpp
deleted file mode 100644
index 04ca649..0000000
--- a/services/bufferhub/BufferNode.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-#include <errno.h>
-
-#include <bufferhub/BufferHubService.h>
-#include <bufferhub/BufferNode.h>
-#include <log/log.h>
-#include <ui/GraphicBufferAllocator.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-void BufferNode::initializeMetadata() {
-    // Using placement new here to reuse shared memory instead of new allocation
-    // Initialize the atomic variables to zero.
-    BufferHubDefs::MetadataHeader* metadataHeader = mMetadata.metadataHeader();
-    mBufferState = new (&metadataHeader->bufferState) std::atomic<uint32_t>(0);
-    mFenceState = new (&metadataHeader->fenceState) std::atomic<uint32_t>(0);
-    mActiveClientsBitMask = new (&metadataHeader->activeClientsBitMask) std::atomic<uint32_t>(0);
-    // The C++ standard recommends (but does not require) that lock-free atomic operations are
-    // also address-free, that is, suitable for communication between processes using shared
-    // memory.
-    LOG_ALWAYS_FATAL_IF(!std::atomic_is_lock_free(mBufferState) ||
-                                !std::atomic_is_lock_free(mFenceState) ||
-                                !std::atomic_is_lock_free(mActiveClientsBitMask),
-                        "Atomic variables in ashmen are not lock free.");
-}
-
-// Allocates a new BufferNode.
-BufferNode::BufferNode(uint32_t width, uint32_t height, uint32_t layerCount, uint32_t format,
-                       uint64_t usage, size_t userMetadataSize, int id)
-      : mId(id) {
-    uint32_t outStride = 0;
-    // graphicBufferId is not used in GraphicBufferAllocator::allocate
-    // TODO(b/112338294) After move to the service folder, stop using the
-    // hardcoded service name "bufferhub".
-    int ret = GraphicBufferAllocator::get().allocate(width, height, format, layerCount, usage,
-                                                     const_cast<const native_handle_t**>(
-                                                             &mBufferHandle),
-                                                     &outStride,
-                                                     /*graphicBufferId=*/0,
-                                                     /*requestor=*/"bufferhub");
-
-    if (ret != OK || mBufferHandle == nullptr) {
-        ALOGE("%s: Failed to allocate buffer: %s", __FUNCTION__, strerror(-ret));
-        return;
-    }
-
-    mBufferDesc.width = width;
-    mBufferDesc.height = height;
-    mBufferDesc.layers = layerCount;
-    mBufferDesc.format = format;
-    mBufferDesc.usage = usage;
-    mBufferDesc.stride = outStride;
-
-    mMetadata = BufferHubMetadata::create(userMetadataSize);
-    if (!mMetadata.isValid()) {
-        ALOGE("%s: Failed to allocate metadata.", __FUNCTION__);
-        return;
-    }
-    initializeMetadata();
-}
-
-BufferNode::~BufferNode() {
-    // Free the handle
-    if (mBufferHandle != nullptr) {
-        status_t ret = GraphicBufferAllocator::get().free(mBufferHandle);
-        if (ret != OK) {
-            ALOGE("%s: Failed to free handle; Got error: %d", __FUNCTION__, ret);
-        }
-    }
-
-    // Free the id, if valid
-    if (mId >= 0) {
-        BufferHubIdGenerator::getInstance().freeId(mId);
-    }
-}
-
-uint32_t BufferNode::getActiveClientsBitMask() const {
-    return mActiveClientsBitMask->load(std::memory_order_acquire);
-}
-
-uint32_t BufferNode::addNewActiveClientsBitToMask() {
-    uint32_t currentActiveClientsBitMask = getActiveClientsBitMask();
-    uint32_t clientStateMask = 0U;
-    uint32_t updatedActiveClientsBitMask = 0U;
-    do {
-        clientStateMask =
-                BufferHubDefs::findNextAvailableClientStateMask(currentActiveClientsBitMask);
-        if (clientStateMask == 0U) {
-            ALOGE("%s: reached the maximum number of channels per buffer node: %d.", __FUNCTION__,
-                  BufferHubDefs::kMaxNumberOfClients);
-            errno = E2BIG;
-            return 0U;
-        }
-        updatedActiveClientsBitMask = currentActiveClientsBitMask | clientStateMask;
-    } while (!(mActiveClientsBitMask->compare_exchange_weak(currentActiveClientsBitMask,
-                                                            updatedActiveClientsBitMask,
-                                                            std::memory_order_acq_rel,
-                                                            std::memory_order_acquire)));
-    return clientStateMask;
-}
-
-void BufferNode::removeClientsBitFromMask(const uint32_t& value) {
-    mActiveClientsBitMask->fetch_and(~value);
-}
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
diff --git a/services/bufferhub/android.frameworks.bufferhub@1.0-service.rc b/services/bufferhub/android.frameworks.bufferhub@1.0-service.rc
deleted file mode 100644
index 36fbede..0000000
--- a/services/bufferhub/android.frameworks.bufferhub@1.0-service.rc
+++ /dev/null
@@ -1,6 +0,0 @@
-service system_bufferhub /system/bin/hw/android.frameworks.bufferhub@1.0-service
-  class hal animation
-  user system
-  group system graphics
-  onrestart restart surfaceflinger
-  writepid /dev/cpuset/system-background/tasks
diff --git a/services/bufferhub/android.frameworks.bufferhub@1.0-service.xml b/services/bufferhub/android.frameworks.bufferhub@1.0-service.xml
deleted file mode 100644
index bd958d3..0000000
--- a/services/bufferhub/android.frameworks.bufferhub@1.0-service.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<manifest version="1.0" type="framework">
-    <hal>
-        <name>android.frameworks.bufferhub</name>
-        <transport>hwbinder</transport>
-        <version>1.0</version>
-        <interface>
-            <name>IBufferHub</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
-</manifest>
diff --git a/services/bufferhub/include/bufferhub/BufferClient.h b/services/bufferhub/include/bufferhub/BufferClient.h
deleted file mode 100644
index 644b403..0000000
--- a/services/bufferhub/include/bufferhub/BufferClient.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2018 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_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_CLIENT_H
-#define ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_CLIENT_H
-
-#include <mutex>
-
-#include <android/frameworks/bufferhub/1.0/IBufferClient.h>
-#include <bufferhub/BufferNode.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-using hardware::hidl_handle;
-using hardware::Return;
-
-// Forward declaration to avoid circular dependency
-class BufferHubService;
-
-class BufferClient : public IBufferClient {
-public:
-    // Creates a server-side buffer client from an existing BufferNode. Note that
-    // this function takes ownership of the shared_ptr.
-    // Returns a raw pointer to the BufferClient on success, nullptr on failure.
-    static BufferClient* create(BufferHubService* service, const std::shared_ptr<BufferNode>& node);
-
-    // Creates a BufferClient from an existing BufferClient. Will share the same BufferNode.
-    explicit BufferClient(const BufferClient& other)
-          : mService(other.mService), mBufferNode(other.mBufferNode) {}
-    ~BufferClient();
-
-    Return<BufferHubStatus> close() override;
-    Return<void> duplicate(duplicate_cb _hidl_cb) override;
-
-    // Non-binder functions
-    const std::shared_ptr<BufferNode>& getBufferNode() const { return mBufferNode; }
-
-private:
-    BufferClient(wp<BufferHubService> service, const std::shared_ptr<BufferNode>& node)
-          : mService(service), mBufferNode(node) {}
-
-    sp<BufferHubService> getService();
-
-    wp<BufferHubService> mService;
-
-    std::mutex mClosedMutex;
-    bool mClosed GUARDED_BY(mClosedMutex) = false;
-
-    std::shared_ptr<BufferNode> mBufferNode;
-};
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
-
-#endif
diff --git a/services/bufferhub/include/bufferhub/BufferHubIdGenerator.h b/services/bufferhub/include/bufferhub/BufferHubIdGenerator.h
deleted file mode 100644
index ef7c077..0000000
--- a/services/bufferhub/include/bufferhub/BufferHubIdGenerator.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2018 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_FRAMEWORKS_BUFFERHUB_V1_0_ID_GENERATOR_H
-#define ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_ID_GENERATOR_H
-
-#include <mutex>
-#include <set>
-
-#include <utils/Mutex.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-// A thread-safe, non-negative, incremental, int id generator.
-class BufferHubIdGenerator {
-public:
-    // Get the singleton instance of this class
-    static BufferHubIdGenerator& getInstance();
-
-    // Gets next available id. If next id is greater than std::numeric_limits<int32_t>::max(), it
-    // will try to get an id start from 0 again.
-    int getId();
-
-    // Free a specific id.
-    void freeId(int id);
-
-private:
-    BufferHubIdGenerator() = default;
-    ~BufferHubIdGenerator() = default;
-
-    // Start from -1 so all valid ids will be >= 0
-    int mLastId = -1;
-
-    std::mutex mIdsInUseMutex;
-    std::set<int> mIdsInUse GUARDED_BY(mIdsInUseMutex);
-};
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
-
-#endif // ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_ID_GENERATOR_H
diff --git a/services/bufferhub/include/bufferhub/BufferHubService.h b/services/bufferhub/include/bufferhub/BufferHubService.h
deleted file mode 100644
index edad20b..0000000
--- a/services/bufferhub/include/bufferhub/BufferHubService.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2018 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_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_HUB_SERVICE_H
-#define ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_HUB_SERVICE_H
-
-#include <map>
-#include <mutex>
-#include <set>
-#include <vector>
-
-#include <android/frameworks/bufferhub/1.0/IBufferHub.h>
-#include <bufferhub/BufferClient.h>
-#include <bufferhub/BufferHubIdGenerator.h>
-#include <utils/Mutex.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-using hardware::hidl_handle;
-using hardware::hidl_string;
-using hardware::hidl_vec;
-using hardware::Return;
-using hardware::graphics::common::V1_2::HardwareBufferDescription;
-
-class BufferHubService : public IBufferHub {
-public:
-    BufferHubService();
-
-    Return<void> allocateBuffer(const HardwareBufferDescription& description,
-                                const uint32_t userMetadataSize,
-                                allocateBuffer_cb _hidl_cb) override;
-    Return<void> importBuffer(const hidl_handle& tokenHandle, importBuffer_cb _hidl_cb) override;
-
-    Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override;
-
-    // Non-binder functions
-    // Internal help function for IBufferClient::duplicate.
-    hidl_handle registerToken(const wp<BufferClient>& client);
-
-    void onClientClosed(const BufferClient* client);
-
-private:
-    // Helper function to build BufferTraits.bufferInfo handle
-    hidl_handle buildBufferInfo(char* bufferInfoStorage, int bufferId, uint32_t clientBitMask,
-                                uint32_t userMetadataSize, int metadataFd, int eventFd);
-
-    // Helper function to remove all the token belongs to a specific client.
-    void removeTokenByClient(const BufferClient* client);
-
-    // List of active BufferClient for bookkeeping.
-    std::mutex mClientSetMutex;
-    std::set<wp<BufferClient>> mClientSet GUARDED_BY(mClientSetMutex);
-
-    // Token generation related
-    // A random number used as private key for HMAC
-    uint64_t mKey;
-    static constexpr size_t kKeyLen = sizeof(uint64_t);
-
-    std::mutex mTokenMutex;
-    // The first TokenId will be 1. TokenId could be negative.
-    int mLastTokenId GUARDED_BY(mTokenMutex) = 0;
-    static constexpr size_t mTokenIdSize = sizeof(int);
-    // A map from token id to the token-buffer_client pair. Using token id as the key to reduce
-    // looking up time
-    std::map<int, std::pair<std::vector<uint8_t>, const wp<BufferClient>>> mTokenMap
-            GUARDED_BY(mTokenMutex);
-};
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
-
-#endif // ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_HUB_SERVICE_H
diff --git a/services/bufferhub/include/bufferhub/BufferNode.h b/services/bufferhub/include/bufferhub/BufferNode.h
deleted file mode 100644
index 62a8d63..0000000
--- a/services/bufferhub/include/bufferhub/BufferNode.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_NODE_H_
-#define ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_NODE_H_
-
-#include <android/hardware_buffer.h>
-#include <bufferhub/BufferHubIdGenerator.h>
-#include <cutils/native_handle.h>
-#include <ui/BufferHubEventFd.h>
-#include <ui/BufferHubMetadata.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-class BufferNode {
-public:
-    // Allocates a new BufferNode.
-    BufferNode(uint32_t width, uint32_t height, uint32_t layerCount, uint32_t format,
-               uint64_t usage, size_t userMetadataSize, int id = -1);
-
-    ~BufferNode();
-
-    // Returns whether the object holds a valid metadata.
-    bool isValid() const { return mMetadata.isValid(); }
-
-    int id() const { return mId; }
-
-    size_t userMetadataSize() const { return mMetadata.userMetadataSize(); }
-
-    // Accessors of the buffer description and handle
-    const native_handle_t* bufferHandle() const { return mBufferHandle; }
-    const AHardwareBuffer_Desc& bufferDesc() const { return mBufferDesc; }
-
-    // Accessor of event fd.
-    const BufferHubEventFd& eventFd() const { return mEventFd; }
-
-    // Accessors of mMetadata.
-    const BufferHubMetadata& metadata() const { return mMetadata; }
-
-    // Gets the current value of mActiveClientsBitMask in mMetadata with
-    // std::memory_order_acquire, so that all previous releases of
-    // mActiveClientsBitMask from all threads will be returned here.
-    uint32_t getActiveClientsBitMask() const;
-
-    // Find and add a new client state mask to mActiveClientsBitMask in
-    // mMetadata.
-    // Return the new client state mask that is added to mActiveClientsBitMask.
-    // Return 0U if there are already 16 clients of the buffer.
-    uint32_t addNewActiveClientsBitToMask();
-
-    // Removes the value from active_clients_bit_mask in mMetadata with
-    // std::memory_order_release, so that the change will be visible to any
-    // acquire of mActiveClientsBitMask in any threads after the succeed of
-    // this operation.
-    void removeClientsBitFromMask(const uint32_t& value);
-
-private:
-    // Helper method for constructors to initialize atomic metadata header
-    // variables in shared memory.
-    void initializeMetadata();
-
-    // Gralloc buffer handles.
-    native_handle_t* mBufferHandle;
-    AHardwareBuffer_Desc mBufferDesc;
-
-    // Eventfd used for signalling buffer events among the clients of the buffer.
-    BufferHubEventFd mEventFd;
-
-    // Metadata in shared memory.
-    BufferHubMetadata mMetadata;
-
-    // A system-unique id generated by bufferhub from 0 to std::numeric_limits<int>::max().
-    // BufferNodes not created by bufferhub will have id < 0, meaning "not specified".
-    // TODO(b/118891412): remove default id = -1 and update comments after pdx is no longer in use
-    const int mId = -1;
-
-    // The following variables are atomic variables in mMetadata that are visible
-    // to Bn object and Bp objects. Please find more info in
-    // BufferHubDefs::MetadataHeader.
-
-    // mBufferState tracks the state of the buffer. Buffer can be in one of these
-    // four states: gained, posted, acquired, released.
-    std::atomic<uint32_t>* mBufferState = nullptr;
-
-    // TODO(b/112012161): add comments to mFenceState.
-    std::atomic<uint32_t>* mFenceState = nullptr;
-
-    // mActiveClientsBitMask tracks all the bp clients of the buffer. It is the
-    // union of all client_state_mask of all bp clients.
-    std::atomic<uint32_t>* mActiveClientsBitMask = nullptr;
-};
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
-
-#endif // ANDROID_FRAMEWORKS_BUFFERHUB_V1_0_BUFFER_NODE_H_
diff --git a/services/bufferhub/main_bufferhub.cpp b/services/bufferhub/main_bufferhub.cpp
deleted file mode 100644
index 084460d..0000000
--- a/services/bufferhub/main_bufferhub.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2018 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 <bufferhub/BufferHubService.h>
-#include <hidl/HidlTransportSupport.h>
-#include <hwbinder/IPCThreadState.h>
-#include <log/log.h>
-
-using android::sp;
-using android::frameworks::bufferhub::V1_0::IBufferHub;
-using android::frameworks::bufferhub::V1_0::implementation::BufferHubService;
-
-int main(int /*argc*/, char** /*argv*/) {
-    ALOGI("Bootstrap bufferhub HIDL service.");
-
-    android::hardware::configureRpcThreadpool(/*numThreads=*/1, /*willJoin=*/true);
-
-    sp<IBufferHub> service = new BufferHubService();
-    LOG_ALWAYS_FATAL_IF(service->registerAsService() != android::OK, "Failed to register service");
-
-    android::hardware::joinRpcThreadpool();
-
-    return 0;
-}
diff --git a/services/bufferhub/tests/Android.bp b/services/bufferhub/tests/Android.bp
deleted file mode 100644
index 3033e70..0000000
--- a/services/bufferhub/tests/Android.bp
+++ /dev/null
@@ -1,26 +0,0 @@
-cc_test {
-    name: "BufferHubServer_test",
-    srcs: [
-        "BufferNode_test.cpp",
-        "BufferHubIdGenerator_test.cpp",
-    ],
-    cflags: [
-        "-DLOG_TAG=\"BufferHubServer_test\"",
-        "-DTRACE=0",
-        "-DATRACE_TAG=ATRACE_TAG_GRAPHICS",
-        "-Wall",
-        "-Werror",
-    ],
-    compile_multilib: "first",
-    header_libs: [
-        "libdvr_headers",
-        "libnativewindow_headers",
-    ],
-    shared_libs: [
-        "libbufferhubservice",
-        "libui",
-    ],
-    static_libs: [
-        "libgmock",
-    ],
-}
diff --git a/services/bufferhub/tests/BufferHubIdGenerator_test.cpp b/services/bufferhub/tests/BufferHubIdGenerator_test.cpp
deleted file mode 100644
index fb6de0d..0000000
--- a/services/bufferhub/tests/BufferHubIdGenerator_test.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <bufferhub/BufferHubIdGenerator.h>
-#include <gtest/gtest.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-namespace {
-
-class BufferHubIdGeneratorTest : public testing::Test {
-protected:
-    BufferHubIdGenerator* mIdGenerator = &BufferHubIdGenerator::getInstance();
-};
-
-TEST_F(BufferHubIdGeneratorTest, TestGenerateAndFreeID) {
-    int id = mIdGenerator->getId();
-    EXPECT_GE(id, 0);
-
-    mIdGenerator->freeId(id);
-}
-
-TEST_F(BufferHubIdGeneratorTest, TestGenerateUniqueIncrementalID) {
-    // 10 IDs should not overflow the UniqueIdGenerator to cause a roll back to start, so the
-    // resulting IDs should still keep incresing.
-    const int kTestSize = 10;
-    int ids[kTestSize];
-    for (int i = 0; i < kTestSize; ++i) {
-        ids[i] = mIdGenerator->getId();
-        EXPECT_GE(ids[i], 0);
-        if (i >= 1) {
-            EXPECT_GT(ids[i], ids[i - 1]);
-        }
-    }
-
-    for (int i = 0; i < kTestSize; ++i) {
-        mIdGenerator->freeId(ids[i]);
-    }
-}
-
-} // namespace
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
\ No newline at end of file
diff --git a/services/bufferhub/tests/BufferNode_test.cpp b/services/bufferhub/tests/BufferNode_test.cpp
deleted file mode 100644
index 2dfd4fc..0000000
--- a/services/bufferhub/tests/BufferNode_test.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <errno.h>
-
-#include <bufferhub/BufferNode.h>
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <ui/BufferHubDefs.h>
-#include <ui/GraphicBufferMapper.h>
-
-namespace android {
-namespace frameworks {
-namespace bufferhub {
-namespace V1_0 {
-namespace implementation {
-
-namespace {
-
-using testing::NotNull;
-
-const uint32_t kWidth = 640;
-const uint32_t kHeight = 480;
-const uint32_t kLayerCount = 1;
-const uint32_t kFormat = 1;
-const uint64_t kUsage = 0;
-const size_t kUserMetadataSize = 0;
-
-class BufferNodeTest : public ::testing::Test {
-protected:
-    void SetUp() override {
-        mBufferNode =
-                new BufferNode(kWidth, kHeight, kLayerCount, kFormat, kUsage, kUserMetadataSize);
-        ASSERT_TRUE(mBufferNode->isValid());
-    }
-
-    void TearDown() override {
-        if (mBufferNode != nullptr) {
-            delete mBufferNode;
-        }
-    }
-
-    BufferNode* mBufferNode = nullptr;
-};
-
-TEST_F(BufferNodeTest, TestCreateBufferNode) {
-    EXPECT_EQ(mBufferNode->userMetadataSize(), kUserMetadataSize);
-    // Test the handle just allocated is good (i.e. able to be imported)
-    GraphicBufferMapper& mapper = GraphicBufferMapper::get();
-    const native_handle_t* outHandle;
-    status_t ret =
-            mapper.importBuffer(mBufferNode->bufferHandle(), mBufferNode->bufferDesc().width,
-                                mBufferNode->bufferDesc().height, mBufferNode->bufferDesc().layers,
-                                mBufferNode->bufferDesc().format, mBufferNode->bufferDesc().usage,
-                                mBufferNode->bufferDesc().stride, &outHandle);
-    EXPECT_EQ(ret, OK);
-    EXPECT_THAT(outHandle, NotNull());
-}
-
-TEST_F(BufferNodeTest, TestaddNewActiveClientsBitToMask_twoNewClients) {
-    uint32_t newClientStateMask1 = mBufferNode->addNewActiveClientsBitToMask();
-    EXPECT_EQ(mBufferNode->getActiveClientsBitMask(), newClientStateMask1);
-
-    // Request and add a new client_state_mask again.
-    // Active clients bit mask should be the union of the two new
-    // client_state_masks.
-    uint32_t newClientStateMask2 = mBufferNode->addNewActiveClientsBitToMask();
-    EXPECT_EQ(mBufferNode->getActiveClientsBitMask(), newClientStateMask1 | newClientStateMask2);
-}
-
-TEST_F(BufferNodeTest, TestaddNewActiveClientsBitToMask_32NewClients) {
-    uint32_t newClientStateMask = 0U;
-    uint32_t currentMask = 0U;
-    uint32_t expectedMask = 0U;
-
-    for (int i = 0; i < BufferHubDefs::kMaxNumberOfClients; ++i) {
-        newClientStateMask = mBufferNode->addNewActiveClientsBitToMask();
-        EXPECT_NE(newClientStateMask, 0U);
-        EXPECT_FALSE(newClientStateMask & currentMask);
-        expectedMask = currentMask | newClientStateMask;
-        currentMask = mBufferNode->getActiveClientsBitMask();
-        EXPECT_EQ(currentMask, expectedMask);
-    }
-
-    // Method should fail upon requesting for more than maximum allowable clients.
-    newClientStateMask = mBufferNode->addNewActiveClientsBitToMask();
-    EXPECT_EQ(newClientStateMask, 0U);
-    EXPECT_EQ(errno, E2BIG);
-}
-
-TEST_F(BufferNodeTest, TestRemoveActiveClientsBitFromMask) {
-    mBufferNode->addNewActiveClientsBitToMask();
-    uint32_t currentMask = mBufferNode->getActiveClientsBitMask();
-    uint32_t newClientStateMask = mBufferNode->addNewActiveClientsBitToMask();
-    EXPECT_NE(mBufferNode->getActiveClientsBitMask(), currentMask);
-
-    mBufferNode->removeClientsBitFromMask(newClientStateMask);
-    EXPECT_EQ(mBufferNode->getActiveClientsBitMask(), currentMask);
-
-    // Remove the test_mask again to the active client bit mask should not modify
-    // the value of active clients bit mask.
-    mBufferNode->removeClientsBitFromMask(newClientStateMask);
-    EXPECT_EQ(mBufferNode->getActiveClientsBitMask(), currentMask);
-}
-
-} // namespace
-
-} // namespace implementation
-} // namespace V1_0
-} // namespace bufferhub
-} // namespace frameworks
-} // namespace android
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 4ec61b0..a5bb473 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -328,6 +328,18 @@
     return dispatchEntry;
 }
 
+static void addGestureMonitors(const std::vector<Monitor>& monitors,
+                               std::vector<TouchedMonitor>& outTouchedMonitors, float xOffset = 0,
+                               float yOffset = 0) {
+    if (monitors.empty()) {
+        return;
+    }
+    outTouchedMonitors.reserve(monitors.size() + outTouchedMonitors.size());
+    for (const Monitor& monitor : monitors) {
+        outTouchedMonitors.emplace_back(monitor, xOffset, yOffset);
+    }
+}
+
 static std::array<uint8_t, 128> getRandomKey() {
     std::array<uint8_t, 128> key;
     if (RAND_bytes(key.data(), key.size()) != 1) {
@@ -741,7 +753,7 @@
 }
 
 std::vector<TouchedMonitor> InputDispatcher::findTouchedGestureMonitorsLocked(
-        int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) {
+        int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) const {
     std::vector<TouchedMonitor> touchedMonitors;
 
     std::vector<Monitor> monitors = getValueByKey(mGestureMonitorsByDisplay, displayId);
@@ -755,18 +767,6 @@
     return touchedMonitors;
 }
 
-void InputDispatcher::addGestureMonitors(const std::vector<Monitor>& monitors,
-                                         std::vector<TouchedMonitor>& outTouchedMonitors,
-                                         float xOffset, float yOffset) {
-    if (monitors.empty()) {
-        return;
-    }
-    outTouchedMonitors.reserve(monitors.size() + outTouchedMonitors.size());
-    for (const Monitor& monitor : monitors) {
-        outTouchedMonitors.emplace_back(monitor, xOffset, yOffset);
-    }
-}
-
 void InputDispatcher::dropInboundEventLocked(const EventEntry& entry, DropReason dropReason) {
     const char* reason;
     switch (dropReason) {
@@ -1267,10 +1267,8 @@
         }
     } else {
         if (mInputTargetWaitCause != INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY) {
-            if (DEBUG_FOCUS) {
-                ALOGD("Waiting for application to become ready for input: %s.  Reason: %s",
-                      getApplicationWindowLabel(applicationHandle, windowHandle).c_str(), reason);
-            }
+            ALOGI("Waiting for application to become ready for input: %s.  Reason: %s",
+                  getApplicationWindowLabel(applicationHandle, windowHandle).c_str(), reason);
             nsecs_t timeout;
             if (windowHandle != nullptr) {
                 timeout = windowHandle->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT);
@@ -1506,11 +1504,9 @@
     if (newGesture) {
         bool down = maskedAction == AMOTION_EVENT_ACTION_DOWN;
         if (switchedDevice && mTempTouchState.down && !down && !isHoverAction) {
-            if (DEBUG_FOCUS) {
-                ALOGD("Dropping event because a pointer for a different device is already down "
-                      "in display %" PRId32,
-                      displayId);
-            }
+            ALOGI("Dropping event because a pointer for a different device is already down "
+                  "in display %" PRId32,
+                  displayId);
             // TODO: test multiple simultaneous input streams.
             injectionResult = INPUT_EVENT_INJECTION_FAILED;
             switchedDevice = false;
@@ -1524,11 +1520,9 @@
         mTempTouchState.displayId = displayId;
         isSplit = false;
     } else if (switchedDevice && maskedAction == AMOTION_EVENT_ACTION_MOVE) {
-        if (DEBUG_FOCUS) {
-            ALOGI("Dropping move event because a pointer for a different device is already active "
-                  "in display %" PRId32,
-                  displayId);
-        }
+        ALOGI("Dropping move event because a pointer for a different device is already active "
+              "in display %" PRId32,
+              displayId);
         // TODO: test multiple simultaneous input streams.
         injectionResult = INPUT_EVENT_INJECTION_PERMISSION_DENIED;
         switchedDevice = false;
@@ -1712,11 +1706,9 @@
         }
         bool hasGestureMonitor = !mTempTouchState.gestureMonitors.empty();
         if (!haveForegroundWindow && !hasGestureMonitor) {
-            if (DEBUG_FOCUS) {
-                ALOGD("Dropping event because there is no touched foreground window in display "
-                      "%" PRId32 " or gesture monitor to receive it.",
-                      displayId);
-            }
+            ALOGI("Dropping event because there is no touched foreground window in display "
+                  "%" PRId32 " or gesture monitor to receive it.",
+                  displayId);
             injectionResult = INPUT_EVENT_INJECTION_FAILED;
             goto Failed;
         }
@@ -1993,13 +1985,13 @@
     int32_t displayId = windowHandle->getInfo()->displayId;
     const std::vector<sp<InputWindowHandle>> windowHandles = getWindowHandlesLocked(displayId);
     for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
-        if (otherHandle == windowHandle) {
+        if (haveSameToken(otherHandle, windowHandle)) {
             break;
         }
 
         const InputWindowInfo* otherInfo = otherHandle->getInfo();
-        if (otherInfo->displayId == displayId && otherInfo->visible &&
-            !otherInfo->isTrustedOverlay() && otherInfo->frameContainsPoint(x, y)) {
+        if (otherInfo->visible && !otherInfo->isTrustedOverlay() &&
+            otherInfo->frameContainsPoint(x, y)) {
             return true;
         }
     }
@@ -2011,13 +2003,13 @@
     const std::vector<sp<InputWindowHandle>> windowHandles = getWindowHandlesLocked(displayId);
     const InputWindowInfo* windowInfo = windowHandle->getInfo();
     for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
-        if (otherHandle == windowHandle) {
+        if (haveSameToken(otherHandle, windowHandle)) {
             break;
         }
 
         const InputWindowInfo* otherInfo = otherHandle->getInfo();
-        if (otherInfo->displayId == displayId && otherInfo->visible &&
-            !otherInfo->isTrustedOverlay() && otherInfo->overlaps(windowInfo)) {
+        if (otherInfo->visible && !otherInfo->isTrustedOverlay() &&
+            otherInfo->overlaps(windowInfo)) {
             return true;
         }
     }
@@ -4101,6 +4093,9 @@
                     dump += StringPrintf(", ownerPid=%d, ownerUid=%d, dispatchingTimeout=%0.3fms\n",
                                          windowInfo->ownerPid, windowInfo->ownerUid,
                                          windowInfo->dispatchingTimeout / 1000000.0);
+                    dump += StringPrintf(INDENT4 "    flags: %s\n",
+                                         inputWindowFlagsToString(windowInfo->layoutParamsFlags)
+                                                 .c_str());
                 }
             } else {
                 dump += INDENT2 "Windows: <none>\n";
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index cbba7e1..9fb1cd4 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -367,11 +367,8 @@
                                            nsecs_t* nextWakeupTime,
                                            bool* outConflictingPointerActions) REQUIRES(mLock);
     std::vector<TouchedMonitor> findTouchedGestureMonitorsLocked(
-            int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows)
+            int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) const
             REQUIRES(mLock);
-    void addGestureMonitors(const std::vector<Monitor>& monitors,
-                            std::vector<TouchedMonitor>& outTouchedMonitors, float xOffset = 0,
-                            float yOffset = 0);
 
     void addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle, int32_t targetFlags,
                                BitSet32 pointerIds, std::vector<InputTarget>& inputTargets)
diff --git a/services/powermanager/Android.bp b/services/powermanager/Android.bp
index b0d3e3b..c62f327 100644
--- a/services/powermanager/Android.bp
+++ b/services/powermanager/Android.bp
@@ -2,9 +2,11 @@
     name: "libpowermanager",
 
     srcs: [
-        "IPowerManager.cpp",
-        "Temperature.cpp",
+        "BatterySaverPolicyConfig.cpp",
         "CoolingDevice.cpp",
+        "PowerSaveState.cpp",
+        "Temperature.cpp",
+        "WorkSource.cpp",
         ":libpowermanager_aidl",
     ],
 
@@ -46,10 +48,10 @@
     ],
     shared_libs: [
         "libbase",
+        "libbinder",
         "libhidlbase",
         "liblog",
         "libpowermanager",
-        "libbinder",
         "libutils",
     ],
 }
diff --git a/services/powermanager/BatterySaverPolicyConfig.cpp b/services/powermanager/BatterySaverPolicyConfig.cpp
new file mode 100644
index 0000000..ee55b6b
--- /dev/null
+++ b/services/powermanager/BatterySaverPolicyConfig.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2020 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 "BatterySaverPolicyConfig"
+
+#include <android/BatterySaverPolicyConfig.h>
+#include <binder/Parcel.h>
+#include <utils/Log.h>
+
+namespace android::os {
+
+status_t BatterySaverPolicyConfig::readDeviceSpecificSettings(const android::Parcel *parcel) {
+    int32_t num = 0;
+    status_t ret = parcel->readInt32(&num);
+    if (ret != OK) {
+        return ret;
+    }
+    for (int i = 0; i < num; i++) {
+        String16 key, val;
+        ret = parcel->readString16(&key) ?:
+              parcel->readString16(&val);
+        if (ret != OK) {
+           return ret;
+        }
+        mDeviceSpecificSettings.emplace_back(key, val);
+    }
+    return ret;
+}
+
+status_t BatterySaverPolicyConfig::readFromParcel(const android::Parcel *parcel) {
+    if (parcel == nullptr) {
+        ALOGE("%s: Null parcel", __func__);
+        return BAD_VALUE;
+    }
+
+    return parcel->readFloat(&mAdjustBrightnessFactor)
+        ?: parcel->readBool(&mAdvertiseIsEnabled)
+        ?: parcel->readBool(&mDeferFullBackup)
+        ?: parcel->readBool(&mDeferKeyValueBackup)
+        ?: readDeviceSpecificSettings(parcel)
+        ?: parcel->readBool(&mDisableAnimation)
+        ?: parcel->readBool(&mDisableAod)
+        ?: parcel->readBool(&mDisableLaunchBoost)
+        ?: parcel->readBool(&mDisableOptionalSensors)
+        ?: parcel->readBool(&mDisableSoundTrigger)
+        ?: parcel->readBool(&mDisableVibration)
+        ?: parcel->readBool(&mEnableAdjustBrightness)
+        ?: parcel->readBool(&mEnableDataSaver)
+        ?: parcel->readBool(&mEnableFirewall)
+        ?: parcel->readBool(&mEnableNightMode)
+        ?: parcel->readBool(&mEnableQuickDoze)
+        ?: parcel->readBool(&mForceAllAppsStandby)
+        ?: parcel->readBool(&mForceBackgroundCheck)
+        ?: parcel->readInt32(reinterpret_cast<int32_t *>(&mLocationMode));
+}
+
+status_t BatterySaverPolicyConfig::writeDeviceSpecificSettings(android::Parcel *parcel) const {
+    status_t ret = parcel->writeInt32(mDeviceSpecificSettings.size());
+    if (ret != OK) {
+        return ret;
+    }
+    for (auto& settings : mDeviceSpecificSettings) {
+        ret = parcel->writeString16(settings.first) ?:
+              parcel->writeString16(settings.second);
+        if (ret != OK) {
+           return ret;
+        }
+    }
+    return ret;
+}
+
+status_t BatterySaverPolicyConfig::writeToParcel(android::Parcel *parcel) const {
+    if (parcel == nullptr) {
+        ALOGE("%s: Null parcel", __func__);
+        return BAD_VALUE;
+    }
+
+    return parcel->writeFloat(mAdjustBrightnessFactor)
+        ?: parcel->writeBool(mAdvertiseIsEnabled)
+        ?: parcel->writeBool(mDeferFullBackup)
+        ?: parcel->writeBool(mDeferKeyValueBackup)
+        ?: writeDeviceSpecificSettings(parcel)
+        ?: parcel->writeBool(mDisableAnimation)
+        ?: parcel->writeBool(mDisableAod)
+        ?: parcel->writeBool(mDisableLaunchBoost)
+        ?: parcel->writeBool(mDisableOptionalSensors)
+        ?: parcel->writeBool(mDisableSoundTrigger)
+        ?: parcel->writeBool(mDisableVibration)
+        ?: parcel->writeBool(mEnableAdjustBrightness)
+        ?: parcel->writeBool(mEnableDataSaver)
+        ?: parcel->writeBool(mEnableFirewall)
+        ?: parcel->writeBool(mEnableNightMode)
+        ?: parcel->writeBool(mEnableQuickDoze)
+        ?: parcel->writeBool(mForceAllAppsStandby)
+        ?: parcel->writeBool(mForceBackgroundCheck)
+        ?: parcel->writeInt32(static_cast<int32_t>(mLocationMode));
+}
+
+} // namespace android::os
diff --git a/services/powermanager/IPowerManager.cpp b/services/powermanager/IPowerManager.cpp
deleted file mode 100644
index ea3a831..0000000
--- a/services/powermanager/IPowerManager.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2011 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 "IPowerManager"
-//#define LOG_NDEBUG 0
-#include <utils/Log.h>
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <binder/Parcel.h>
-
-#include <powermanager/IPowerManager.h>
-
-namespace android {
-
-class BpPowerManager : public BpInterface<IPowerManager>
-{
-public:
-    explicit BpPowerManager(const sp<IBinder>& impl)
-        : BpInterface<IPowerManager>(impl)
-    {
-    }
-
-    virtual status_t acquireWakeLock(int flags, const sp<IBinder>& lock, const String16& tag,
-            const String16& packageName, bool isOneWay)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-
-        data.writeStrongBinder(lock);
-        data.writeInt32(flags);
-        data.writeString16(tag);
-        data.writeString16(packageName);
-        data.writeInt32(0); // no WorkSource
-        data.writeString16(NULL, 0); // no history tag
-        return remote()->transact(ACQUIRE_WAKE_LOCK, data, &reply,
-                isOneWay ? IBinder::FLAG_ONEWAY : 0);
-    }
-
-    virtual status_t acquireWakeLockWithUid(int flags, const sp<IBinder>& lock, const String16& tag,
-            const String16& packageName, int uid, bool isOneWay)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-
-        data.writeStrongBinder(lock);
-        data.writeInt32(flags);
-        data.writeString16(tag);
-        data.writeString16(packageName);
-        data.writeInt32(uid); // uid to blame for the work
-        return remote()->transact(ACQUIRE_WAKE_LOCK_UID, data, &reply,
-                isOneWay ? IBinder::FLAG_ONEWAY : 0);
-    }
-
-    virtual status_t releaseWakeLock(const sp<IBinder>& lock, int flags, bool isOneWay)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-        data.writeStrongBinder(lock);
-        data.writeInt32(flags);
-        return remote()->transact(RELEASE_WAKE_LOCK, data, &reply,
-                isOneWay ? IBinder::FLAG_ONEWAY : 0);
-    }
-
-    virtual status_t updateWakeLockUids(const sp<IBinder>& lock, int len, const int *uids,
-            bool isOneWay) {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-        data.writeStrongBinder(lock);
-        data.writeInt32Array(len, uids);
-        return remote()->transact(UPDATE_WAKE_LOCK_UIDS, data, &reply,
-                isOneWay ? IBinder::FLAG_ONEWAY : 0);
-    }
-
-    virtual status_t powerHint(int hintId, int param)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-        data.writeInt32(hintId);
-        data.writeInt32(param);
-        // This FLAG_ONEWAY is in the .aidl, so there is no way to disable it
-        return remote()->transact(POWER_HINT, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    virtual status_t goToSleep(int64_t event_time_ms, int reason, int flags)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-        data.writeInt64(event_time_ms);
-        data.writeInt32(reason);
-        data.writeInt32(flags);
-        return remote()->transact(GO_TO_SLEEP, data, &reply, 0);
-    }
-
-    virtual status_t reboot(bool confirm, const String16& reason, bool wait)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-        data.writeInt32(confirm);
-        data.writeString16(reason);
-        data.writeInt32(wait);
-        return remote()->transact(REBOOT, data, &reply, 0);
-    }
-
-    virtual status_t shutdown(bool confirm, const String16& reason, bool wait)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-        data.writeInt32(confirm);
-        data.writeString16(reason);
-        data.writeInt32(wait);
-        return remote()->transact(SHUTDOWN, data, &reply, 0);
-    }
-
-    virtual status_t crash(const String16& message)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IPowerManager::getInterfaceDescriptor());
-        data.writeString16(message);
-        return remote()->transact(CRASH, data, &reply, 0);
-    }
-};
-
-IMPLEMENT_META_INTERFACE(PowerManager, "android.os.IPowerManager");
-
-// ----------------------------------------------------------------------------
-
-}; // namespace android
diff --git a/services/powermanager/PowerSaveState.cpp b/services/powermanager/PowerSaveState.cpp
new file mode 100644
index 0000000..6d1830a
--- /dev/null
+++ b/services/powermanager/PowerSaveState.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 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 "PowerSaveState"
+
+#include <android/PowerSaveState.h>
+#include <binder/Parcel.h>
+#include <utils/Log.h>
+
+namespace android::os {
+
+status_t PowerSaveState::readFromParcel(const android::Parcel *parcel) {
+    if (parcel == nullptr) {
+        ALOGE("%s: Null parcel", __func__);
+        return BAD_VALUE;
+    }
+
+    return parcel->readBool(&mBatterySaverEnabled)
+        ?: parcel->readBool(&mGlobalBatterySaverEnabled)
+        ?: parcel->readInt32(reinterpret_cast<int32_t *>(&mLocationMode))
+        ?: parcel->readFloat(&mBrightnessFactor);
+}
+
+status_t PowerSaveState::writeToParcel(android::Parcel *parcel) const {
+    if (parcel == nullptr) {
+        ALOGE("%s: Null parcel", __func__);
+        return BAD_VALUE;
+    }
+
+    return parcel->writeBool(mBatterySaverEnabled)
+        ?: parcel->writeBool(mGlobalBatterySaverEnabled)
+        ?: parcel->writeInt32(static_cast<int32_t>(mLocationMode))
+        ?: parcel->writeFloat(mBrightnessFactor);
+}
+
+} // namespace android::os
diff --git a/services/powermanager/WorkSource.cpp b/services/powermanager/WorkSource.cpp
new file mode 100644
index 0000000..1006a06
--- /dev/null
+++ b/services/powermanager/WorkSource.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 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 "WorkSource"
+
+#include <android/WorkSource.h>
+#include <binder/Parcel.h>
+#include <utils/Log.h>
+
+namespace android::os {
+
+status_t WorkSource::readFromParcel(const android::Parcel *parcel) {
+    if (parcel == nullptr) {
+        ALOGE("%s: Null parcel", __func__);
+        return BAD_VALUE;
+    }
+    int32_t num;
+    status_t ret = parcel->readInt32(&num)
+                ?: parcel->readInt32Vector(&mUids)
+                ?: parcel->readString16Vector(&mNames);
+
+    return ret;
+}
+
+status_t WorkSource::writeToParcel(android::Parcel *parcel) const {
+    if (parcel == nullptr) {
+        ALOGE("%s: Null parcel", __func__);
+        return BAD_VALUE;
+    }
+
+    return parcel->writeInt32(mUids.size())
+        ?: parcel->writeInt32Vector(mUids)
+        ?: parcel->writeString16Vector(mNames);
+}
+
+} // namespace android::os
diff --git a/services/powermanager/include/android/BatterySaverPolicyConfig.h b/services/powermanager/include/android/BatterySaverPolicyConfig.h
new file mode 100644
index 0000000..728c8a0
--- /dev/null
+++ b/services/powermanager/include/android/BatterySaverPolicyConfig.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2020 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_OS_BATTERY_SAVER_POLICY_CONFIG_H
+#define ANDROID_OS_BATTERY_SAVER_POLICY_CONFIG_H
+
+#include <math.h>
+#include <binder/Parcelable.h>
+#include <utils/RefBase.h>
+
+namespace android::os {
+
+enum class LocationMode : int32_t;
+/**
+ * BatterySaverPolicyConfig is a structure of configs to set Battery Saver policy flags.
+ * This file needs to be kept in sync with
+ * frameworks/base/core/java/android/os/BatterySaverPolicyConfig.java
+ */
+struct BatterySaverPolicyConfig : public android::Parcelable {
+
+    BatterySaverPolicyConfig(float adjustBrightnessFactor = 1.0f,
+                             bool advertiseIsEnabled = false,
+                             bool deferFullBackup = false,
+                             bool deferKeyValueBackup = false,
+                             std::vector<std::pair<String16, String16>> deviceSpecificSettings = {},
+                             bool disableAnimation = false,
+                             bool disableAod = false,
+                             bool disableLaunchBoost = false,
+                             bool disableOptionalSensors = false,
+                             bool disableSoundTrigger = false,
+                             bool disableVibration = false,
+                             bool enableAdjustBrightness = false,
+                             bool enableDataSaver = false,
+                             bool enableFirewall = false,
+                             bool enableNightMode = false,
+                             bool enableQuickDoze = false,
+                             bool forceAllAppsStandby = false,
+                             bool forceBackgroundCheck = false,
+                             LocationMode locationMode = static_cast<LocationMode>(0))
+        : mAdjustBrightnessFactor(adjustBrightnessFactor),
+          mAdvertiseIsEnabled(advertiseIsEnabled),
+          mDeferFullBackup(deferFullBackup),
+          mDeferKeyValueBackup(deferKeyValueBackup),
+          mDeviceSpecificSettings(deviceSpecificSettings),
+          mDisableAnimation(disableAnimation),
+          mDisableAod(disableAod),
+          mDisableLaunchBoost(disableLaunchBoost),
+          mDisableOptionalSensors(disableOptionalSensors),
+          mDisableSoundTrigger(disableSoundTrigger),
+          mDisableVibration(disableVibration),
+          mEnableAdjustBrightness(enableAdjustBrightness),
+          mEnableDataSaver(enableDataSaver),
+          mEnableFirewall(enableFirewall),
+          mEnableNightMode(enableNightMode),
+          mEnableQuickDoze(enableQuickDoze),
+          mForceAllAppsStandby(forceAllAppsStandby),
+          mForceBackgroundCheck(forceBackgroundCheck),
+          mLocationMode(locationMode) {
+    }
+
+    status_t readFromParcel(const android::Parcel* parcel) override;
+    status_t writeToParcel(android::Parcel* parcel) const override;
+    bool operator == (const BatterySaverPolicyConfig &bsp) const {
+        return fabs(mAdjustBrightnessFactor - bsp.mAdjustBrightnessFactor) == 0.0f &&
+               mAdvertiseIsEnabled == bsp.mAdvertiseIsEnabled &&
+               mDeferFullBackup == bsp.mDeferFullBackup &&
+               mDeferKeyValueBackup == bsp.mDeferKeyValueBackup &&
+               mDeviceSpecificSettings == bsp.mDeviceSpecificSettings &&
+               mDisableAnimation == bsp.mDisableAnimation &&
+               mDisableAod == bsp.mDisableAod &&
+               mDisableLaunchBoost == bsp.mDisableLaunchBoost &&
+               mDisableOptionalSensors == bsp.mDisableOptionalSensors &&
+               mDisableSoundTrigger == bsp.mDisableSoundTrigger &&
+               mDisableVibration == bsp.mDisableVibration &&
+               mEnableAdjustBrightness == bsp.mEnableAdjustBrightness &&
+               mEnableDataSaver == bsp.mEnableDataSaver &&
+               mEnableFirewall == bsp.mEnableFirewall &&
+               mEnableNightMode == bsp.mEnableNightMode &&
+               mEnableQuickDoze == bsp.mEnableQuickDoze &&
+               mForceAllAppsStandby == bsp.mForceAllAppsStandby &&
+               mForceBackgroundCheck == bsp.mForceBackgroundCheck &&
+               mLocationMode == bsp.mLocationMode;
+    }
+
+private:
+    status_t readDeviceSpecificSettings(const android::Parcel *parcel);
+    status_t writeDeviceSpecificSettings(android::Parcel *parcel) const;
+    /** Adjust screen brightness factor */
+    float mAdjustBrightnessFactor;
+    /** Is advertise enabled */
+    bool mAdvertiseIsEnabled;
+    /** Defer full backup */
+    bool mDeferFullBackup;
+    /** Defer key value backup */
+    bool mDeferKeyValueBackup;
+    /** Device specific settings */
+    std::vector<std::pair<String16, String16>> mDeviceSpecificSettings;
+    /** Disable animation */
+    bool mDisableAnimation;
+    /** Disable Aod */
+    bool mDisableAod;
+    /** Disable launch boost */
+    bool mDisableLaunchBoost;
+    /** Disable optional sensors */
+    bool mDisableOptionalSensors;
+    /** Disable sound trigger */
+    bool mDisableSoundTrigger;
+    /** Disable vibration */
+    bool mDisableVibration;
+    /** Enable adjust brightness */
+    bool mEnableAdjustBrightness;
+    /** Enable data saver */
+    bool mEnableDataSaver;
+    /** Enable firewall */
+    bool mEnableFirewall;
+    /** Enable night mode */
+    bool mEnableNightMode;
+    /** Enable quick doze */
+    bool mEnableQuickDoze;
+    /** Force all Apps standby */
+    bool mForceAllAppsStandby;
+    /** Force Background check */
+    bool mForceBackgroundCheck;
+    /** Location mode */
+    LocationMode mLocationMode;
+};
+
+} // namespace android::os
+
+#endif /* ANDROID_OS_BATTERY_SAVER_POLICY_CONFIG_H */
diff --git a/services/powermanager/include/android/LocationMode.h b/services/powermanager/include/android/LocationMode.h
new file mode 100644
index 0000000..42933d4
--- /dev/null
+++ b/services/powermanager/include/android/LocationMode.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2020 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_OS_LOCATION_MODE_H
+#define ANDROID_OS_LOCATION_MODE_H
+
+namespace android::os {
+
+enum class LocationMode : int32_t {
+    NO_CHANGE = IPowerManager::LOCATION_MODE_NO_CHANGE,
+    GPS_DISABLED_WHEN_SCREEN_OFF = IPowerManager::LOCATION_MODE_GPS_DISABLED_WHEN_SCREEN_OFF,
+    ALL_DISABLED_WHEN_SCREEN_OFF = IPowerManager::LOCATION_MODE_ALL_DISABLED_WHEN_SCREEN_OFF,
+    FOREGROUND_ONLY = IPowerManager::LOCATION_MODE_FOREGROUND_ONLY,
+    THROTTLE_REQUESTS_WHEN_SCREEN_OFF =
+                IPowerManager::LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF,
+    MIN = IPowerManager::LOCATION_MODE_NO_CHANGE,
+    MAX = IPowerManager::LOCATION_MODE_THROTTLE_REQUESTS_WHEN_SCREEN_OFF,
+};
+
+} // namespace android::os
+
+#endif /* ANDROID_OS_LOCATION_MODE_H */
diff --git a/services/powermanager/include/android/PowerSaveState.h b/services/powermanager/include/android/PowerSaveState.h
new file mode 100644
index 0000000..b421f6a
--- /dev/null
+++ b/services/powermanager/include/android/PowerSaveState.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2020 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_OS_POWER_SAVE_STATE_H
+#define ANDROID_OS_POWER_SAVE_STATE_H
+
+#include <math.h>
+#include <binder/Parcelable.h>
+#include <utils/RefBase.h>
+
+namespace android::os {
+
+enum class LocationMode : int32_t;
+/**
+ * PowerSaveState is a structure to encapsulate PowerSaveState status.
+ * This file needs to be kept in sync with frameworks/base/core/java/android/os/PowerSaveState.java
+ */
+struct PowerSaveState : public android::Parcelable {
+
+    PowerSaveState(bool batterySaverEnabled = false,
+                   bool globalBatterySaverEnabled = false,
+                   LocationMode locationMode = static_cast<LocationMode>(0),
+                   float brightnessFactor = 0.5f)
+            : mBatterySaverEnabled(batterySaverEnabled),
+              mGlobalBatterySaverEnabled(globalBatterySaverEnabled),
+              mLocationMode(locationMode),
+              mBrightnessFactor(brightnessFactor) {
+    }
+
+    bool getBatterySaverEnabled() const { return mBatterySaverEnabled; }
+    bool getGlobalBatterySaverEnabled() const { return mGlobalBatterySaverEnabled; }
+    LocationMode getLocationMode() const { return mLocationMode; }
+    float getBrightnessFactor() const { return mBrightnessFactor; }
+    bool operator == (const PowerSaveState &ps) const {
+        return mBatterySaverEnabled == ps.mBatterySaverEnabled &&
+               mGlobalBatterySaverEnabled == ps.mGlobalBatterySaverEnabled &&
+               mLocationMode == ps.mLocationMode &&
+               fabs(mBrightnessFactor - ps.mBrightnessFactor) == 0.0f;
+    }
+
+    status_t readFromParcel(const android::Parcel* parcel) override;
+    status_t writeToParcel(android::Parcel* parcel) const override;
+
+private:
+    /** Whether we should enable battery saver for this service. */
+    bool mBatterySaverEnabled;
+    /** Whether battery saver mode is enabled. */
+    bool mGlobalBatterySaverEnabled;
+    /** Location mode */
+    LocationMode mLocationMode;
+    /** Screen brightness factor. */
+    float mBrightnessFactor;
+};
+
+} // namespace android::os
+
+#endif /* ANDROID_OS_POWER_SAVE_STATE_H */
diff --git a/services/powermanager/include/android/WorkSource.h b/services/powermanager/include/android/WorkSource.h
new file mode 100644
index 0000000..f12847d
--- /dev/null
+++ b/services/powermanager/include/android/WorkSource.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2020 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_OS_WORKSOURCE_H
+#define ANDROID_OS_WORKSOURCE_H
+
+#include <optional>
+#include <binder/Parcelable.h>
+#include <utils/RefBase.h>
+
+namespace android::os {
+
+/**
+ * WorkSource is a structure to describes the source of some work that may be done by someone else.
+ * This file needs to be kept in sync with frameworks/base/core/java/android/os/WorkSource.java
+ */
+struct WorkSource : public android::Parcelable {
+    WorkSource(
+               std::vector<int32_t> uids = {},
+               std::optional<std::vector<std::optional<String16>>> names = std::nullopt)
+        : mUids(uids),
+          mNames(names) {
+    }
+    std::vector<int32_t> getUids() const { return mUids; }
+    std::optional<std::vector<std::optional<String16>>> getNames() const { return mNames; }
+    bool operator == (const WorkSource &ws) const {
+        return mUids == ws.mUids && mNames == ws.mNames;
+    }
+    status_t readFromParcel(const android::Parcel* parcel) override;
+    status_t writeToParcel(android::Parcel* parcel) const override;
+
+private:
+    /** WorkSource UID array */
+    std::vector<int32_t> mUids = {};
+    /** WorkSource Tag array */
+    std::optional<std::vector<std::optional<String16>>> mNames = {};
+};
+
+} // namespace android::os
+
+#endif /* ANDROID_OS_WORKSOURCE_H */
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 34d0cb2..b7ea089 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -912,9 +912,8 @@
 
     const nsecs_t renderEngineStart = systemTime();
     status_t status =
-            renderEngine.drawLayers(clientCompositionDisplay, clientCompositionLayerPointers,
-                                    buf->getNativeBuffer(), /*useFramebufferCache=*/true,
-                                    std::move(fd), &readyFence);
+            renderEngine.drawLayers(clientCompositionDisplay, clientCompositionLayerPointers, buf,
+                                    /*useFramebufferCache=*/true, std::move(fd), &readyFence);
 
     if (status != NO_ERROR && mClientCompositionRequestCache) {
         // If rendering was not successful, remove the request from the cache.
diff --git a/services/surfaceflinger/DisplayHardware/DisplayIdentification.cpp b/services/surfaceflinger/DisplayHardware/DisplayIdentification.cpp
index 4dfc743..f9281a7 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayIdentification.cpp
+++ b/services/surfaceflinger/DisplayHardware/DisplayIdentification.cpp
@@ -71,12 +71,8 @@
 
 DeviceProductInfo buildDeviceProductInfo(const Edid& edid) {
     DeviceProductInfo info;
-    std::copy(edid.displayName.begin(), edid.displayName.end(), info.name.begin());
-    info.name[edid.displayName.size()] = '\0';
-
-    const auto productId = std::to_string(edid.productId);
-    std::copy(productId.begin(), productId.end(), info.productId.begin());
-    info.productId[productId.size()] = '\0';
+    info.name.assign(edid.displayName);
+    info.productId = std::to_string(edid.productId);
     info.manufacturerPnpId = edid.pnpId;
 
     constexpr uint8_t kModelYearFlag = 0xff;
@@ -96,12 +92,6 @@
         info.manufactureOrModelDate = date;
     }
 
-    if (edid.cea861Block && edid.cea861Block->hdmiVendorDataBlock) {
-        const auto& address = edid.cea861Block->hdmiVendorDataBlock->physicalAddress;
-        info.relativeAddress = {address.a, address.b, address.c, address.d};
-    } else {
-        info.relativeAddress = DeviceProductInfo::NO_RELATIVE_ADDRESS;
-    }
     return info;
 }
 
@@ -238,7 +228,6 @@
 
     constexpr size_t kDescriptorCount = 4;
     constexpr size_t kDescriptorLength = 18;
-    static_assert(kDescriptorLength - kEdidHeaderLength < DeviceProductInfo::TEXT_BUFFER_SIZE);
 
     for (size_t i = 0; i < kDescriptorCount; i++) {
         if (view.size() < kDescriptorLength) {
diff --git a/services/surfaceflinger/DisplayHardware/DisplayIdentification.h b/services/surfaceflinger/DisplayHardware/DisplayIdentification.h
index 9e6c549..fc2f72e 100644
--- a/services/surfaceflinger/DisplayHardware/DisplayIdentification.h
+++ b/services/surfaceflinger/DisplayHardware/DisplayIdentification.h
@@ -70,7 +70,7 @@
 };
 
 struct HdmiVendorDataBlock {
-    HdmiPhysicalAddress physicalAddress;
+    std::optional<HdmiPhysicalAddress> physicalAddress;
 };
 
 struct Cea861ExtensionBlock : ExtensionBlock {
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 97ec987..5f1486b 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -381,6 +381,10 @@
     const size_t defaultListSize = ISurfaceComposer::MAX_LAYERS;
     auto listSize = property_get_int32("debug.sf.max_igbp_list_size", int32_t(defaultListSize));
     mMaxGraphicBufferProducerListSize = (listSize > 0) ? size_t(listSize) : defaultListSize;
+    mGraphicBufferProducerListSizeLogThreshold =
+            std::max(static_cast<int>(0.95 *
+                                      static_cast<double>(mMaxGraphicBufferProducerListSize)),
+                     1);
 
     property_get("debug.sf.luma_sampling", value, "1");
     mLumaSampling = atoi(value);
@@ -3206,6 +3210,11 @@
                                 "Suspected IGBP leak: %zu IGBPs (%zu max), %zu Layers",
                                 mGraphicBufferProducerList.size(),
                                 mMaxGraphicBufferProducerListSize, mNumLayers.load());
+            if (mGraphicBufferProducerList.size() > mGraphicBufferProducerListSizeLogThreshold) {
+                ALOGW("Suspected IGBP leak: %zu IGBPs (%zu max), %zu Layers",
+                      mGraphicBufferProducerList.size(), mMaxGraphicBufferProducerListSize,
+                      mNumLayers.load());
+            }
         }
         mLayersAdded = true;
     }
@@ -4677,7 +4686,7 @@
         StringAppendF(&result, "Composition layers\n");
         mDrawingState.traverseInZOrder([&](Layer* layer) {
             auto* compositionState = layer->getCompositionState();
-            if (!compositionState) return;
+            if (!compositionState || !compositionState->isVisible) return;
 
             android::base::StringAppendF(&result, "* Layer %p (%s)\n", layer,
                                          layer->getDebugName() ? layer->getDebugName()
@@ -5741,8 +5750,8 @@
 
 void SurfaceFlinger::renderScreenImplLocked(const RenderArea& renderArea,
                                             TraverseLayersFunction traverseLayers,
-                                            ANativeWindowBuffer* buffer, bool useIdentityTransform,
-                                            int* outSyncFd) {
+                                            const sp<GraphicBuffer>& buffer,
+                                            bool useIdentityTransform, int* outSyncFd) {
     ATRACE_CALL();
 
     const auto reqWidth = renderArea.getReqWidth();
@@ -5833,7 +5842,7 @@
 
 status_t SurfaceFlinger::captureScreenImplLocked(const RenderArea& renderArea,
                                                  TraverseLayersFunction traverseLayers,
-                                                 ANativeWindowBuffer* buffer,
+                                                 const sp<GraphicBuffer>& buffer,
                                                  bool useIdentityTransform, bool forSystem,
                                                  int* outSyncFd, bool& outCapturedSecureLayers) {
     ATRACE_CALL();
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 76d6b8c..ec103b1 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -702,7 +702,7 @@
     using TraverseLayersFunction = std::function<void(const LayerVector::Visitor&)>;
 
     void renderScreenImplLocked(const RenderArea& renderArea, TraverseLayersFunction traverseLayers,
-                                ANativeWindowBuffer* buffer, bool useIdentityTransform,
+                                const sp<GraphicBuffer>& buffer, bool useIdentityTransform,
                                 int* outSyncFd);
     status_t captureScreenCommon(RenderArea& renderArea, TraverseLayersFunction traverseLayers,
                                  sp<GraphicBuffer>* outBuffer, const ui::PixelFormat reqPixelFormat,
@@ -714,7 +714,7 @@
     const sp<DisplayDevice> getDisplayByLayerStack(uint64_t layerStack);
     status_t captureScreenImplLocked(const RenderArea& renderArea,
                                      TraverseLayersFunction traverseLayers,
-                                     ANativeWindowBuffer* buffer, bool useIdentityTransform,
+                                     const sp<GraphicBuffer>& buffer, bool useIdentityTransform,
                                      bool forSystem, int* outSyncFd, bool& outCapturedSecureLayers);
     void traverseLayersInDisplay(const sp<const DisplayDevice>& display,
                                  const LayerVector::Visitor& visitor);
@@ -1007,6 +1007,10 @@
     // Can't be unordered_set because wp<> isn't hashable
     std::set<wp<IBinder>> mGraphicBufferProducerList;
     size_t mMaxGraphicBufferProducerListSize = ISurfaceComposer::MAX_LAYERS;
+    // If there are more GraphicBufferProducers tracked by SurfaceFlinger than
+    // this threshold, then begin logging.
+    size_t mGraphicBufferProducerListSizeLogThreshold =
+            static_cast<size_t>(0.95 * static_cast<double>(MAX_LAYERS));
 
     // protected by mStateLock (but we could use another lock)
     bool mLayersRemoved = false;
diff --git a/services/surfaceflinger/tests/unittests/CompositionTest.cpp b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
index 2dcaf63..ad159b2 100644
--- a/services/surfaceflinger/tests/unittests/CompositionTest.cpp
+++ b/services/surfaceflinger/tests/unittests/CompositionTest.cpp
@@ -348,7 +348,7 @@
         EXPECT_CALL(*test->mRenderEngine, drawLayers)
                 .WillRepeatedly([](const renderengine::DisplaySettings& displaySettings,
                                    const std::vector<const renderengine::LayerSettings*>&,
-                                   ANativeWindowBuffer*, const bool, base::unique_fd&&,
+                                   const sp<GraphicBuffer>&, const bool, base::unique_fd&&,
                                    base::unique_fd*) -> status_t {
                     EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
                     EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
@@ -397,7 +397,7 @@
         EXPECT_CALL(*test->mRenderEngine, drawLayers)
                 .WillRepeatedly([](const renderengine::DisplaySettings& displaySettings,
                                    const std::vector<const renderengine::LayerSettings*>&,
-                                   ANativeWindowBuffer*, const bool, base::unique_fd&&,
+                                   const sp<GraphicBuffer>&, const bool, base::unique_fd&&,
                                    base::unique_fd*) -> status_t {
                     EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
                     EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
@@ -648,7 +648,7 @@
         EXPECT_CALL(*test->mRenderEngine, drawLayers)
                 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
                              const std::vector<const renderengine::LayerSettings*>& layerSettings,
-                             ANativeWindowBuffer*, const bool, base::unique_fd&&,
+                             const sp<GraphicBuffer>&, const bool, base::unique_fd&&,
                              base::unique_fd*) -> status_t {
                     EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
                     EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
@@ -697,7 +697,7 @@
         EXPECT_CALL(*test->mRenderEngine, drawLayers)
                 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
                              const std::vector<const renderengine::LayerSettings*>& layerSettings,
-                             ANativeWindowBuffer*, const bool, base::unique_fd&&,
+                             const sp<GraphicBuffer>&, const bool, base::unique_fd&&,
                              base::unique_fd*) -> status_t {
                     EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
                     EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
@@ -775,7 +775,7 @@
         EXPECT_CALL(*test->mRenderEngine, drawLayers)
                 .WillOnce([](const renderengine::DisplaySettings& displaySettings,
                              const std::vector<const renderengine::LayerSettings*>& layerSettings,
-                             ANativeWindowBuffer*, const bool, base::unique_fd&&,
+                             const sp<GraphicBuffer>&, const bool, base::unique_fd&&,
                              base::unique_fd*) -> status_t {
                     EXPECT_EQ(DEFAULT_DISPLAY_MAX_LUMINANCE, displaySettings.maxLuminance);
                     EXPECT_EQ(Rect(DEFAULT_DISPLAY_WIDTH, DEFAULT_DISPLAY_HEIGHT),
diff --git a/services/surfaceflinger/tests/unittests/DisplayIdentificationTest.cpp b/services/surfaceflinger/tests/unittests/DisplayIdentificationTest.cpp
index 2a0e913..b530f8e 100644
--- a/services/surfaceflinger/tests/unittests/DisplayIdentificationTest.cpp
+++ b/services/surfaceflinger/tests/unittests/DisplayIdentificationTest.cpp
@@ -209,11 +209,12 @@
     EXPECT_EQ(41, edid->manufactureWeek);
     ASSERT_TRUE(edid->cea861Block);
     ASSERT_TRUE(edid->cea861Block->hdmiVendorDataBlock);
+    ASSERT_TRUE(edid->cea861Block->hdmiVendorDataBlock->physicalAddress);
     auto physicalAddress = edid->cea861Block->hdmiVendorDataBlock->physicalAddress;
-    EXPECT_EQ(2, physicalAddress.a);
-    EXPECT_EQ(0, physicalAddress.b);
-    EXPECT_EQ(0, physicalAddress.c);
-    EXPECT_EQ(0, physicalAddress.d);
+    EXPECT_EQ(2, physicalAddress->a);
+    EXPECT_EQ(0, physicalAddress->b);
+    EXPECT_EQ(0, physicalAddress->c);
+    EXPECT_EQ(0, physicalAddress->d);
 
     edid = parseEdid(getPanasonicTvEdid());
     ASSERT_TRUE(edid);
@@ -226,11 +227,12 @@
     EXPECT_EQ(0, edid->manufactureWeek);
     ASSERT_TRUE(edid->cea861Block);
     ASSERT_TRUE(edid->cea861Block->hdmiVendorDataBlock);
+    ASSERT_TRUE(edid->cea861Block->hdmiVendorDataBlock->physicalAddress);
     physicalAddress = edid->cea861Block->hdmiVendorDataBlock->physicalAddress;
-    EXPECT_EQ(2, physicalAddress.a);
-    EXPECT_EQ(0, physicalAddress.b);
-    EXPECT_EQ(0, physicalAddress.c);
-    EXPECT_EQ(0, physicalAddress.d);
+    EXPECT_EQ(2, physicalAddress->a);
+    EXPECT_EQ(0, physicalAddress->b);
+    EXPECT_EQ(0, physicalAddress->c);
+    EXPECT_EQ(0, physicalAddress->d);
 
     edid = parseEdid(getHisenseTvEdid());
     ASSERT_TRUE(edid);
@@ -243,11 +245,12 @@
     EXPECT_EQ(18, edid->manufactureWeek);
     ASSERT_TRUE(edid->cea861Block);
     ASSERT_TRUE(edid->cea861Block->hdmiVendorDataBlock);
+    ASSERT_TRUE(edid->cea861Block->hdmiVendorDataBlock->physicalAddress);
     physicalAddress = edid->cea861Block->hdmiVendorDataBlock->physicalAddress;
-    EXPECT_EQ(1, physicalAddress.a);
-    EXPECT_EQ(2, physicalAddress.b);
-    EXPECT_EQ(3, physicalAddress.c);
-    EXPECT_EQ(4, physicalAddress.d);
+    EXPECT_EQ(1, physicalAddress->a);
+    EXPECT_EQ(2, physicalAddress->b);
+    EXPECT_EQ(3, physicalAddress->c);
+    EXPECT_EQ(4, physicalAddress->d);
 
     edid = parseEdid(getCtlDisplayEdid());
     ASSERT_TRUE(edid);
@@ -312,86 +315,79 @@
     using ManufactureYear = DeviceProductInfo::ManufactureYear;
     using ManufactureWeekAndYear = DeviceProductInfo::ManufactureWeekAndYear;
     using ModelYear = DeviceProductInfo::ModelYear;
-    using RelativeAddress = DeviceProductInfo::RelativeAddress;
 
     {
         const auto displayIdInfo = parseDisplayIdentificationData(0, getInternalEdid());
         ASSERT_TRUE(displayIdInfo);
         ASSERT_TRUE(displayIdInfo->deviceProductInfo);
         const auto& info = *displayIdInfo->deviceProductInfo;
-        EXPECT_STREQ("", info.name.data());
+        EXPECT_EQ("", info.name);
         EXPECT_STREQ("SEC", info.manufacturerPnpId.data());
-        EXPECT_STREQ("12610", info.productId.data());
+        EXPECT_EQ("12610", info.productId);
         ASSERT_TRUE(std::holds_alternative<ManufactureYear>(info.manufactureOrModelDate));
         EXPECT_EQ(2011, std::get<ManufactureYear>(info.manufactureOrModelDate).year);
-        EXPECT_EQ(DeviceProductInfo::NO_RELATIVE_ADDRESS, info.relativeAddress);
     }
     {
         const auto displayIdInfo = parseDisplayIdentificationData(0, getExternalEdid());
         ASSERT_TRUE(displayIdInfo);
         ASSERT_TRUE(displayIdInfo->deviceProductInfo);
         const auto& info = *displayIdInfo->deviceProductInfo;
-        EXPECT_STREQ("HP ZR30w", info.name.data());
+        EXPECT_EQ("HP ZR30w", info.name);
         EXPECT_STREQ("HWP", info.manufacturerPnpId.data());
-        EXPECT_STREQ("10348", info.productId.data());
+        EXPECT_EQ("10348", info.productId);
         ASSERT_TRUE(std::holds_alternative<ManufactureWeekAndYear>(info.manufactureOrModelDate));
         const auto& date = std::get<ManufactureWeekAndYear>(info.manufactureOrModelDate);
         EXPECT_EQ(2012, date.year);
         EXPECT_EQ(2, date.week);
-        EXPECT_EQ(DeviceProductInfo::NO_RELATIVE_ADDRESS, info.relativeAddress);
     }
     {
         const auto displayIdInfo = parseDisplayIdentificationData(0, getExternalEedid());
         ASSERT_TRUE(displayIdInfo);
         ASSERT_TRUE(displayIdInfo->deviceProductInfo);
         const auto& info = *displayIdInfo->deviceProductInfo;
-        EXPECT_STREQ("SAMSUNG", info.name.data());
+        EXPECT_EQ("SAMSUNG", info.name);
         EXPECT_STREQ("SAM", info.manufacturerPnpId.data());
-        EXPECT_STREQ("2302", info.productId.data());
+        EXPECT_EQ("2302", info.productId);
         ASSERT_TRUE(std::holds_alternative<ManufactureWeekAndYear>(info.manufactureOrModelDate));
         const auto& date = std::get<ManufactureWeekAndYear>(info.manufactureOrModelDate);
         EXPECT_EQ(2011, date.year);
         EXPECT_EQ(41, date.week);
-        EXPECT_EQ((RelativeAddress{{2, 0, 0, 0}}), info.relativeAddress);
     }
     {
         const auto displayIdInfo = parseDisplayIdentificationData(0, getPanasonicTvEdid());
         ASSERT_TRUE(displayIdInfo);
         ASSERT_TRUE(displayIdInfo->deviceProductInfo);
         const auto& info = *displayIdInfo->deviceProductInfo;
-        EXPECT_STREQ("Panasonic-TV", info.name.data());
+        EXPECT_EQ("Panasonic-TV", info.name);
         EXPECT_STREQ("MEI", info.manufacturerPnpId.data());
-        EXPECT_STREQ("41622", info.productId.data());
+        EXPECT_EQ("41622", info.productId);
         ASSERT_TRUE(std::holds_alternative<ManufactureYear>(info.manufactureOrModelDate));
         const auto& date = std::get<ManufactureYear>(info.manufactureOrModelDate);
         EXPECT_EQ(2019, date.year);
-        EXPECT_EQ((RelativeAddress{{2, 0, 0, 0}}), info.relativeAddress);
     }
     {
         const auto displayIdInfo = parseDisplayIdentificationData(0, getHisenseTvEdid());
         ASSERT_TRUE(displayIdInfo);
         ASSERT_TRUE(displayIdInfo->deviceProductInfo);
         const auto& info = *displayIdInfo->deviceProductInfo;
-        EXPECT_STREQ("Hisense", info.name.data());
+        EXPECT_EQ("Hisense", info.name);
         EXPECT_STREQ("HEC", info.manufacturerPnpId.data());
-        EXPECT_STREQ("0", info.productId.data());
+        EXPECT_EQ("0", info.productId);
         ASSERT_TRUE(std::holds_alternative<ManufactureWeekAndYear>(info.manufactureOrModelDate));
         const auto& date = std::get<ManufactureWeekAndYear>(info.manufactureOrModelDate);
         EXPECT_EQ(2019, date.year);
         EXPECT_EQ(18, date.week);
-        EXPECT_EQ((RelativeAddress{{1, 2, 3, 4}}), info.relativeAddress);
     }
     {
         const auto displayIdInfo = parseDisplayIdentificationData(0, getCtlDisplayEdid());
         ASSERT_TRUE(displayIdInfo);
         ASSERT_TRUE(displayIdInfo->deviceProductInfo);
         const auto& info = *displayIdInfo->deviceProductInfo;
-        EXPECT_STREQ("LP2361", info.name.data());
+        EXPECT_EQ("LP2361", info.name);
         EXPECT_STREQ("CTL", info.manufacturerPnpId.data());
-        EXPECT_STREQ("9373", info.productId.data());
+        EXPECT_EQ("9373", info.productId);
         ASSERT_TRUE(std::holds_alternative<ModelYear>(info.manufactureOrModelDate));
         EXPECT_EQ(2013, std::get<ModelYear>(info.manufactureOrModelDate).year);
-        EXPECT_EQ(DeviceProductInfo::NO_RELATIVE_ADDRESS, info.relativeAddress);
     }
 }
 
diff --git a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
index 6995ee0..47bc24e 100644
--- a/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
+++ b/services/surfaceflinger/tests/unittests/TestableSurfaceFlinger.h
@@ -321,9 +321,10 @@
 
     auto onMessageReceived(int32_t what) { return mFlinger->onMessageReceived(what); }
 
-    auto captureScreenImplLocked(
-            const RenderArea& renderArea, SurfaceFlinger::TraverseLayersFunction traverseLayers,
-            ANativeWindowBuffer* buffer, bool useIdentityTransform, bool forSystem, int* outSyncFd) {
+    auto captureScreenImplLocked(const RenderArea& renderArea,
+                                 SurfaceFlinger::TraverseLayersFunction traverseLayers,
+                                 const sp<GraphicBuffer>& buffer, bool useIdentityTransform,
+                                 bool forSystem, int* outSyncFd) {
         bool ignored;
         return mFlinger->captureScreenImplLocked(renderArea, traverseLayers, buffer,
                                                  useIdentityTransform, forSystem, outSyncFd,