patches: Update for Bliss 11.2 Stable

Signed-off-by: Jackeagle <jackeagle102@gmail.com>
Change-Id: I6f7c6beee6581a349627f4f449f99f5c894e37e7
diff --git a/patches/build/make/0001-Revert-Add-roomservice.patch b/patches/build/make/0001-Revert-Add-roomservice.patch
index 70da11d..454b033 100644
--- a/patches/build/make/0001-Revert-Add-roomservice.patch
+++ b/patches/build/make/0001-Revert-Add-roomservice.patch
@@ -1,15 +1,17 @@
-From c1b3a197dff1d1bd37aaddce051fc11ddbb41549 Mon Sep 17 00:00:00 2001
-From: Koushik Dutta <koushd@gmail.com>
-Date: Wed, 23 Aug 2017 16:13:18 +0200
+From 1f6865d33d38d2d903cd08243449a46867256210 Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:32:54 -0700
 Subject: [PATCH] Revert "Add roomservice"
 
 This reverts commit 17246d24480f9b1f2278d9b785e989d1d2597a7c.
+
+Change-Id: I2aca743bd57b64dc40ff8f5376ef6e11b79d1788
 ---
  envsetup.sh | 23 -----------------------
  1 file changed, 23 deletions(-)
 
 diff --git a/envsetup.sh b/envsetup.sh
-index 5f45a11574..d8cf3c882f 100644
+index 5f45a1157..d8cf3c882 100644
 --- a/envsetup.sh
 +++ b/envsetup.sh
 @@ -632,20 +632,6 @@ function lunch()
diff --git a/patches/build/make/0001-Revert-Remove-root-folder-bt_firmware-in-GSI.patch b/patches/build/make/0001-Revert-Remove-root-folder-bt_firmware-in-GSI.patch
deleted file mode 100644
index b594a95..0000000
--- a/patches/build/make/0001-Revert-Remove-root-folder-bt_firmware-in-GSI.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From 70b81271bf7e27121ecb982aeb568e1eaf920b52 Mon Sep 17 00:00:00 2001
-From: Pierre-Hugues Husson <phh@phh.me>
-Date: Tue, 27 Mar 2018 23:26:49 +0200
-Subject: [PATCH 1/2] Revert "Remove root folder bt_firmware in GSI"
-
-This reverts commit 292b8433cb48ef4ceb2330e57e11b8f644d9d1ee.
-
-Essential 8.1 firmware requires this
----
- target/board/generic_arm64_ab/BoardConfig.mk         | 2 +-
- target/board/generic_arm64_ab/sepolicy/file.te       | 1 +
- target/board/generic_arm64_ab/sepolicy/file_contexts | 1 +
- 3 files changed, 3 insertions(+), 1 deletion(-)
-
-diff --git a/target/board/generic_arm64_ab/BoardConfig.mk b/target/board/generic_arm64_ab/BoardConfig.mk
-index fc6b582..8200196 100644
---- a/target/board/generic_arm64_ab/BoardConfig.mk
-+++ b/target/board/generic_arm64_ab/BoardConfig.mk
-@@ -33,7 +33,7 @@ TARGET_NO_RECOVERY := true
- BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
- 
- # TODO(jiyong) These might be SoC specific.
--BOARD_ROOT_EXTRA_FOLDERS += firmware firmware/radio persist
-+BOARD_ROOT_EXTRA_FOLDERS += bt_firmware firmware firmware/radio persist
- BOARD_ROOT_EXTRA_SYMLINKS := /vendor/lib/dsp:/dsp
- 
- # Set this to create /cache mount point for non-A/B devices that mounts /cache.
-diff --git a/target/board/generic_arm64_ab/sepolicy/file.te b/target/board/generic_arm64_ab/sepolicy/file.te
-index 7adfdfa..4645533 100644
---- a/target/board/generic_arm64_ab/sepolicy/file.te
-+++ b/target/board/generic_arm64_ab/sepolicy/file.te
-@@ -1,5 +1,6 @@
- # TODO(b/36764215): remove this file when the generic system image
- # no longer has these directories
-+type bt_firmware_file, file_type;
- type persist_file, file_type;
- 
- # Default type for anything under /firmware.
-diff --git a/target/board/generic_arm64_ab/sepolicy/file_contexts b/target/board/generic_arm64_ab/sepolicy/file_contexts
-index 0a80559..92a4ff8 100644
---- a/target/board/generic_arm64_ab/sepolicy/file_contexts
-+++ b/target/board/generic_arm64_ab/sepolicy/file_contexts
-@@ -2,6 +2,7 @@
- # no longer has these directories. They are specific to QCOM.
- 
- # /
-+/bt_firmware(/.*)?      u:object_r:bt_firmware_file:s0
- /tombstones             u:object_r:rootfs:s0
- /dsp                    u:object_r:rootfs:s0
- 
--- 
-2.7.4
-
diff --git a/patches/build/make/0002-Set-ro.build.fingerprint-in-system-etc-prop.default.patch b/patches/build/make/0002-Set-ro.build.fingerprint-in-system-etc-prop.default.patch
deleted file mode 100644
index 8ac02eb..0000000
--- a/patches/build/make/0002-Set-ro.build.fingerprint-in-system-etc-prop.default.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From cedcb09acfdacdb2953244d56533b156cad1fcf8 Mon Sep 17 00:00:00 2001
-From: Pierre-Hugues Husson <phh@phh.me>
-Date: Mon, 5 Mar 2018 22:27:50 +0100
-Subject: [PATCH 2/2] Set ro.build.fingerprint in system/etc/prop.default
-
-Change-Id: Idceb2a160f70b36aa6806ae60cbfb325367f3b75
----
- core/Makefile | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/core/Makefile b/core/Makefile
-index 0a2f6e3..059aa98 100644
---- a/core/Makefile
-+++ b/core/Makefile
-@@ -176,6 +176,7 @@ $(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop)
- 	$(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@
- 	$(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
- 	$(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
-+	$(hide) echo ro.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
- 	$(hide) build/make/tools/post_process_props.py $@
- ifdef property_overrides_split_enabled
- 	$(hide) mkdir -p $(TARGET_ROOT_OUT)
--- 
-2.7.4
-
diff --git a/patches/frameworks/av/0002-FIH-devices-Fix-Earpiece-audio-output.patch b/patches/frameworks/av/0001-FIH-devices-Fix-Earpiece-audio-output.patch
similarity index 93%
rename from patches/frameworks/av/0002-FIH-devices-Fix-Earpiece-audio-output.patch
rename to patches/frameworks/av/0001-FIH-devices-Fix-Earpiece-audio-output.patch
index dbdbf37..d0d75fc 100644
--- a/patches/frameworks/av/0002-FIH-devices-Fix-Earpiece-audio-output.patch
+++ b/patches/frameworks/av/0001-FIH-devices-Fix-Earpiece-audio-output.patch
@@ -1,7 +1,7 @@
-From 7e9375da9c53bebe4e7390044b7c8cbd4d1f9d88 Mon Sep 17 00:00:00 2001
+From 8508cdce9a6a1b3806972ca7c44ab49823863fdb Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Tue, 24 Apr 2018 00:14:28 +0200
-Subject: [PATCH 2/5] FIH devices: Fix "Earpiece" audio output
+Subject: [PATCH 1/4] FIH devices: Fix "Earpiece" audio output
 
 On some FIH devices (confirmed on Razer, and probably on Aquos SS2),
 Earpiece is not listed in attachedDevices, and devicePort's profile
@@ -12,11 +12,11 @@
 
 Change-Id: I4a88ba6d34d0fcd346eeea2ca903772f0271040a
 ---
- .../common/managerdefinitions/src/Serializer.cpp   | 25 +++++++++++++++++++---
+ .../managerdefinitions/src/Serializer.cpp     | 25 ++++++++++++++++---
  1 file changed, 22 insertions(+), 3 deletions(-)
 
 diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
-index a253113..380e2f8 100644
+index a2531131d..380e2f82b 100644
 --- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
 +++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
 @@ -191,16 +191,25 @@ const char AudioProfileTraits::Attributes::name[] = "name";
@@ -74,5 +74,5 @@
  }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/av/0001-SQUASH-Revert-Camera-Specific-AOSP-Reverts.patch b/patches/frameworks/av/0001-SQUASH-Revert-Camera-Specific-AOSP-Reverts.patch
deleted file mode 100644
index 0cde82c..0000000
--- a/patches/frameworks/av/0001-SQUASH-Revert-Camera-Specific-AOSP-Reverts.patch
+++ /dev/null
@@ -1,1716 +0,0 @@
-From f584caaf5f6cd31cc6b8e30a4b62893d6d85818e Mon Sep 17 00:00:00 2001
-From: Jackeagle <jackeagle102@gmail.com>
-Date: Thu, 18 Oct 2018 04:21:22 -0400
-Subject: [PATCH 1/5] [SQUASH] Revert Camera Specific AOSP Reverts
-
-Revert "Revert "CameraService: fix camera removal paths""
-
-This reverts commit e1922854c4bf71d9170011b904b701d1b38e303e.
-
-Revert "Revert "CameraService: Update camera and torch state lists also at runtime""
-
-This reverts commit cb343b767cd41829bb994c9c0e671a9c3e5d7cfb.
-
-Revert "Revert "Camera: Add API level to service proxy notification""
-
-This reverts commit 48888c68523e50038e92b8d73fa4d471fe266972.
-
-Revert "Revert "Camera: expose external camera to API1""
-
-This reverts commit 92607517666eca78bb94817f780977c7024cdda4.
-
-Revert "Revert "Camera: fix camera ID in flashlight control""
-
-This reverts commit 2c7225b2fe3017d1fd146e55420c6b616f44d16b.
-
-Revert "Revert "Camera: Support all API1 compatible camera devices""
-
-This reverts commit 842255a5aff37bb06d43a06bb44be0a67c4570ac.
-
-Revert "Revert "Camera: Filter logical camera ids to API1 app""
-
-This reverts commit 4e10dacc6a5edc0b4382e570173e9f7ff89af9bd.
----
- .../aidl/android/hardware/ICameraServiceProxy.aidl |   8 +-
- camera/ndk/impl/ACameraManager.cpp                 |   3 +
- .../camera/libcameraservice/CameraFlashlight.cpp   |  52 ++--
- .../camera/libcameraservice/CameraFlashlight.h     |  11 +-
- services/camera/libcameraservice/CameraService.cpp | 317 ++++++++++-----------
- services/camera/libcameraservice/CameraService.h   |  35 ++-
- .../camera/libcameraservice/api1/Camera2Client.cpp |   7 +-
- .../camera/libcameraservice/api1/Camera2Client.h   |   3 +-
- .../camera/libcameraservice/api1/CameraClient.cpp  |  14 +-
- .../libcameraservice/api1/client2/Parameters.cpp   |  56 +++-
- .../libcameraservice/api1/client2/Parameters.h     |   7 +
- .../libcameraservice/api2/CameraDeviceClient.cpp   |  59 ++--
- .../libcameraservice/api2/CameraDeviceClient.h     |   1 +
- .../libcameraservice/common/Camera2ClientBase.cpp  |  15 +-
- .../libcameraservice/common/Camera2ClientBase.h    |   3 +
- .../common/CameraProviderManager.cpp               | 173 ++++++++---
- .../common/CameraProviderManager.h                 |  30 +-
- 17 files changed, 476 insertions(+), 318 deletions(-)
-
-diff --git a/camera/aidl/android/hardware/ICameraServiceProxy.aidl b/camera/aidl/android/hardware/ICameraServiceProxy.aidl
-index 5dc23eb..7575948 100644
---- a/camera/aidl/android/hardware/ICameraServiceProxy.aidl
-+++ b/camera/aidl/android/hardware/ICameraServiceProxy.aidl
-@@ -46,8 +46,14 @@ interface ICameraServiceProxy
-     const int CAMERA_FACING_EXTERNAL = 2;
- 
-     /**
-+     * Values for notifyCameraState api level
-+     */
-+     const int CAMERA_API_LEVEL_1 = 1;
-+     const int CAMERA_API_LEVEL_2 = 2;
-+
-+    /**
-      * Update the status of a camera device.
-      */
-     oneway void notifyCameraState(String cameraId, int facing, int newCameraState,
--            String clientName);
-+            String clientName, int apiLevel);
- }
-diff --git a/camera/ndk/impl/ACameraManager.cpp b/camera/ndk/impl/ACameraManager.cpp
-index e409ddd..c59d0e7 100644
---- a/camera/ndk/impl/ACameraManager.cpp
-+++ b/camera/ndk/impl/ACameraManager.cpp
-@@ -340,6 +340,9 @@ void CameraManagerGlobal::onStatusChangedLocked(
-         msg->setString(kCameraIdKey, AString(cameraId));
-         msg->post();
-     }
-+    if (status == hardware::ICameraServiceListener::STATUS_NOT_PRESENT) {
-+        mDeviceStatusMap.erase(cameraId);
-+    }
- }
- 
- } // namespace android
-diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp
-index 9c45331..61b9acb 100644
---- a/services/camera/libcameraservice/CameraFlashlight.cpp
-+++ b/services/camera/libcameraservice/CameraFlashlight.cpp
-@@ -32,13 +32,15 @@
- 
- namespace android {
- 
-+using hardware::camera::common::V1_0::TorchModeStatus;
-+
- /////////////////////////////////////////////////////////////////////
- // CameraFlashlight implementation begins
- // used by camera service to control flashflight.
- /////////////////////////////////////////////////////////////////////
- 
- CameraFlashlight::CameraFlashlight(sp<CameraProviderManager> providerManager,
--        camera_module_callbacks_t* callbacks) :
-+        CameraProviderManager::StatusListener* callbacks) :
-         mProviderManager(providerManager),
-         mCallbacks(callbacks),
-         mFlashlightMapInitialized(false) {
-@@ -59,7 +61,7 @@ status_t CameraFlashlight::createFlashlightControl(const String8& cameraId) {
-     } else {
-         // Only HAL1 devices do not support setTorchMode
-         mFlashControl =
--                new CameraHardwareInterfaceFlashControl(mProviderManager, *mCallbacks);
-+                new CameraHardwareInterfaceFlashControl(mProviderManager, mCallbacks);
-     }
- 
-     return OK;
-@@ -118,19 +120,15 @@ status_t CameraFlashlight::setTorchMode(const String8& cameraId, bool enabled) {
-     return res;
- }
- 
--int CameraFlashlight::getNumberOfCameras() {
--    return mProviderManager->getAPI1CompatibleCameraCount();
--}
--
- status_t CameraFlashlight::findFlashUnits() {
-     Mutex::Autolock l(mLock);
-     status_t res;
- 
-     std::vector<String8> cameraIds;
--    int numberOfCameras = getNumberOfCameras();
-+    std::vector<std::string> ids = mProviderManager->getAPI1CompatibleCameraDeviceIds();
-+    int numberOfCameras = static_cast<int>(ids.size());
-     cameraIds.resize(numberOfCameras);
-     // No module, must be provider
--    std::vector<std::string> ids = mProviderManager->getAPI1CompatibleCameraDeviceIds();
-     for (size_t i = 0; i < cameraIds.size(); i++) {
-         cameraIds[i] = String8(ids[i].c_str());
-     }
-@@ -184,7 +182,8 @@ bool CameraFlashlight::hasFlashUnitLocked(const String8& cameraId) {
- 
-     ssize_t index = mHasFlashlightMap.indexOfKey(cameraId);
-     if (index == NAME_NOT_FOUND) {
--        ALOGE("%s: camera %s not present when findFlashUnits() was called",
-+        // Might be external camera
-+        ALOGW("%s: camera %s not present when findFlashUnits() was called",
-                 __FUNCTION__, cameraId.string());
-         return false;
-     }
-@@ -218,12 +217,13 @@ status_t CameraFlashlight::prepareDeviceOpen(const String8& cameraId) {
- 
-         if (mOpenedCameraIds.size() == 0) {
-             // notify torch unavailable for all cameras with a flash
--            int numCameras = getNumberOfCameras();
-+            std::vector<std::string> ids = mProviderManager->getAPI1CompatibleCameraDeviceIds();
-+            int numCameras = static_cast<int>(ids.size());
-             for (int i = 0; i < numCameras; i++) {
--                if (hasFlashUnitLocked(String8::format("%d", i))) {
--                    mCallbacks->torch_mode_status_change(mCallbacks,
--                            String8::format("%d", i).string(),
--                            TORCH_MODE_STATUS_NOT_AVAILABLE);
-+                String8 id8(ids[i].c_str());
-+                if (hasFlashUnitLocked(id8)) {
-+                    mCallbacks->onTorchStatusChanged(
-+                            id8, TorchModeStatus::NOT_AVAILABLE);
-                 }
-             }
-         }
-@@ -263,12 +263,13 @@ status_t CameraFlashlight::deviceClosed(const String8& cameraId) {
- 
-     if (isBackwardCompatibleMode(cameraId)) {
-         // notify torch available for all cameras with a flash
--        int numCameras = getNumberOfCameras();
-+        std::vector<std::string> ids = mProviderManager->getAPI1CompatibleCameraDeviceIds();
-+        int numCameras = static_cast<int>(ids.size());
-         for (int i = 0; i < numCameras; i++) {
--            if (hasFlashUnitLocked(String8::format("%d", i))) {
--                mCallbacks->torch_mode_status_change(mCallbacks,
--                        String8::format("%d", i).string(),
--                        TORCH_MODE_STATUS_AVAILABLE_OFF);
-+            String8 id8(ids[i].c_str());
-+            if (hasFlashUnitLocked(id8)) {
-+                mCallbacks->onTorchStatusChanged(
-+                        id8, TorchModeStatus::AVAILABLE_OFF);
-             }
-         }
-     }
-@@ -315,9 +316,9 @@ status_t ProviderFlashControl::setTorchMode(const String8& cameraId, bool enable
- 
- CameraHardwareInterfaceFlashControl::CameraHardwareInterfaceFlashControl(
-         sp<CameraProviderManager> manager,
--        const camera_module_callbacks_t& callbacks) :
-+        CameraProviderManager::StatusListener* callbacks) :
-         mProviderManager(manager),
--        mCallbacks(&callbacks),
-+        mCallbacks(callbacks),
-         mTorchEnabled(false) {
- }
- 
-@@ -333,8 +334,7 @@ CameraHardwareInterfaceFlashControl::~CameraHardwareInterfaceFlashControl() {
-         if (mCallbacks) {
-             ALOGV("%s: notify the framework that torch was turned off",
-                     __FUNCTION__);
--            mCallbacks->torch_mode_status_change(mCallbacks,
--                    mCameraId.string(), TORCH_MODE_STATUS_AVAILABLE_OFF);
-+            mCallbacks->onTorchStatusChanged(mCameraId, TorchModeStatus::AVAILABLE_OFF);
-         }
-     }
- }
-@@ -368,8 +368,7 @@ status_t CameraHardwareInterfaceFlashControl::setTorchMode(
-         // disabling the torch mode of currently opened device
-         disconnectCameraDevice();
-         mTorchEnabled = false;
--        mCallbacks->torch_mode_status_change(mCallbacks,
--            cameraId.string(), TORCH_MODE_STATUS_AVAILABLE_OFF);
-+        mCallbacks->onTorchStatusChanged(cameraId, TorchModeStatus::AVAILABLE_OFF);
-         return OK;
-     }
- 
-@@ -379,8 +378,7 @@ status_t CameraHardwareInterfaceFlashControl::setTorchMode(
-     }
- 
-     mTorchEnabled = true;
--    mCallbacks->torch_mode_status_change(mCallbacks,
--            cameraId.string(), TORCH_MODE_STATUS_AVAILABLE_ON);
-+    mCallbacks->onTorchStatusChanged(cameraId, TorchModeStatus::AVAILABLE_ON);
-     return OK;
- }
- 
-diff --git a/services/camera/libcameraservice/CameraFlashlight.h b/services/camera/libcameraservice/CameraFlashlight.h
-index c86ee85..1baaba2 100644
---- a/services/camera/libcameraservice/CameraFlashlight.h
-+++ b/services/camera/libcameraservice/CameraFlashlight.h
-@@ -19,7 +19,6 @@
- 
- #include <gui/GLConsumer.h>
- #include <gui/Surface.h>
--#include <hardware/camera_common.h>
- #include <utils/KeyedVector.h>
- #include <utils/SortedVector.h>
- #include "common/CameraProviderManager.h"
-@@ -55,7 +54,7 @@ class FlashControlBase : public virtual VirtualLightRefBase {
- class CameraFlashlight : public virtual VirtualLightRefBase {
-     public:
-         CameraFlashlight(sp<CameraProviderManager> providerManager,
--                camera_module_callbacks_t* callbacks);
-+                CameraProviderManager::StatusListener* callbacks);
-         virtual ~CameraFlashlight();
- 
-         // Find all flash units. This must be called before other methods. All
-@@ -93,13 +92,11 @@ class CameraFlashlight : public virtual VirtualLightRefBase {
-         // opening cameras)
-         bool isBackwardCompatibleMode(const String8& cameraId);
- 
--        int getNumberOfCameras();
--
-         sp<FlashControlBase> mFlashControl;
- 
-         sp<CameraProviderManager> mProviderManager;
- 
--        const camera_module_callbacks_t *mCallbacks;
-+        CameraProviderManager::StatusListener* mCallbacks;
-         SortedVector<String8> mOpenedCameraIds;
- 
-         // camera id -> if it has a flash unit
-@@ -134,7 +131,7 @@ class CameraHardwareInterfaceFlashControl : public FlashControlBase {
-     public:
-         CameraHardwareInterfaceFlashControl(
-                 sp<CameraProviderManager> manager,
--                const camera_module_callbacks_t& callbacks);
-+                CameraProviderManager::StatusListener* callbacks);
-         virtual ~CameraHardwareInterfaceFlashControl();
- 
-         // FlashControlBase
-@@ -166,7 +163,7 @@ class CameraHardwareInterfaceFlashControl : public FlashControlBase {
-         status_t hasFlashUnitLocked(const String8& cameraId, bool *hasFlash, bool keepDeviceOpen);
- 
-         sp<CameraProviderManager> mProviderManager;
--        const camera_module_callbacks_t *mCallbacks;
-+        CameraProviderManager::StatusListener* mCallbacks;
-         sp<CameraHardwareInterface> mDevice;
-         String8 mCameraId;
-         CameraParameters mParameters;
-diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
-index 01220e3..de0fac5 100644
---- a/services/camera/libcameraservice/CameraService.cpp
-+++ b/services/camera/libcameraservice/CameraService.cpp
-@@ -109,79 +109,13 @@ static void setLogLevel(int level) {
- 
- // ----------------------------------------------------------------------------
- 
--extern "C" {
--static void camera_device_status_change(
--        const struct camera_module_callbacks* callbacks,
--        int camera_id,
--        int new_status) {
--    sp<CameraService> cs = const_cast<CameraService*>(
--            static_cast<const CameraService*>(callbacks));
--    String8 id = String8::format("%d", camera_id);
--
--    CameraDeviceStatus newStatus{CameraDeviceStatus::NOT_PRESENT};
--    switch (new_status) {
--        case CAMERA_DEVICE_STATUS_NOT_PRESENT:
--            newStatus = CameraDeviceStatus::NOT_PRESENT;
--            break;
--        case CAMERA_DEVICE_STATUS_PRESENT:
--            newStatus = CameraDeviceStatus::PRESENT;
--            break;
--        case CAMERA_DEVICE_STATUS_ENUMERATING:
--            newStatus = CameraDeviceStatus::ENUMERATING;
--            break;
--        default:
--            ALOGW("Unknown device status change to %d", new_status);
--            break;
--    }
--    cs->onDeviceStatusChanged(id, newStatus);
--}
--
--static void torch_mode_status_change(
--        const struct camera_module_callbacks* callbacks,
--        const char* camera_id,
--        int new_status) {
--    if (!callbacks || !camera_id) {
--        ALOGE("%s invalid parameters. callbacks %p, camera_id %p", __FUNCTION__,
--                callbacks, camera_id);
--    }
--    sp<CameraService> cs = const_cast<CameraService*>(
--                                static_cast<const CameraService*>(callbacks));
--
--    TorchModeStatus status;
--    switch (new_status) {
--        case TORCH_MODE_STATUS_NOT_AVAILABLE:
--            status = TorchModeStatus::NOT_AVAILABLE;
--            break;
--        case TORCH_MODE_STATUS_AVAILABLE_OFF:
--            status = TorchModeStatus::AVAILABLE_OFF;
--            break;
--        case TORCH_MODE_STATUS_AVAILABLE_ON:
--            status = TorchModeStatus::AVAILABLE_ON;
--            break;
--        default:
--            ALOGE("Unknown torch status %d", new_status);
--            return;
--    }
--
--    cs->onTorchStatusChanged(
--        String8(camera_id),
--        status);
--}
--} // extern "C"
--
--// ----------------------------------------------------------------------------
--
- static const String16 sManageCameraPermission("android.permission.MANAGE_CAMERA");
- 
- CameraService::CameraService() :
-         mEventLog(DEFAULT_EVENT_LOG_LENGTH),
--        mNumberOfCameras(0), mNumberOfNormalCameras(0),
-+        mNumberOfCameras(0),
-         mSoundRef(0), mInitialized(false) {
-     ALOGI("CameraService started (pid=%d)", getpid());
--
--    this->camera_device_status_change = android::camera_device_status_change;
--    this->torch_mode_status_change = android::torch_mode_status_change;
--
-     mServiceLockWrapper = std::make_shared<WaitableMutexWrapper>(&mServiceLock);
- }
- 
-@@ -211,72 +145,43 @@ void CameraService::onFirstRef()
- 
- status_t CameraService::enumerateProviders() {
-     status_t res;
--    Mutex::Autolock l(mServiceLock);
- 
--    if (nullptr == mCameraProviderManager.get()) {
--        mCameraProviderManager = new CameraProviderManager();
--        res = mCameraProviderManager->initialize(this);
--        if (res != OK) {
--            ALOGE("%s: Unable to initialize camera provider manager: %s (%d)",
--                    __FUNCTION__, strerror(-res), res);
--            return res;
--        }
--    }
-+    std::vector<std::string> deviceIds;
-+    {
-+        Mutex::Autolock l(mServiceLock);
- 
--    mNumberOfCameras = mCameraProviderManager->getCameraCount();
--    mNumberOfNormalCameras =
--            mCameraProviderManager->getAPI1CompatibleCameraCount();
-+        if (nullptr == mCameraProviderManager.get()) {
-+            mCameraProviderManager = new CameraProviderManager();
-+            res = mCameraProviderManager->initialize(this);
-+            if (res != OK) {
-+                ALOGE("%s: Unable to initialize camera provider manager: %s (%d)",
-+                        __FUNCTION__, strerror(-res), res);
-+                return res;
-+            }
-+        }
- 
--    // Setup vendor tags before we call get_camera_info the first time
--    // because HAL might need to setup static vendor keys in get_camera_info
--    // TODO: maybe put this into CameraProviderManager::initialize()?
--    mCameraProviderManager->setUpVendorTags();
- 
--    if (nullptr == mFlashlight.get()) {
--        mFlashlight = new CameraFlashlight(mCameraProviderManager, this);
--    }
-+        // Setup vendor tags before we call get_camera_info the first time
-+        // because HAL might need to setup static vendor keys in get_camera_info
-+        // TODO: maybe put this into CameraProviderManager::initialize()?
-+        mCameraProviderManager->setUpVendorTags();
- 
--    res = mFlashlight->findFlashUnits();
--    if (res != OK) {
--        ALOGE("Failed to enumerate flash units: %s (%d)", strerror(-res), res);
--    }
--
--    for (auto& cameraId : mCameraProviderManager->getCameraDeviceIds()) {
--        String8 id8 = String8(cameraId.c_str());
--        bool cameraFound = false;
--        {
-+        if (nullptr == mFlashlight.get()) {
-+            mFlashlight = new CameraFlashlight(mCameraProviderManager, this);
-+        }
- 
--            Mutex::Autolock lock(mCameraStatesLock);
--            auto iter = mCameraStates.find(id8);
--            if (iter != mCameraStates.end()) {
--                cameraFound = true;
--            }
-+        res = mFlashlight->findFlashUnits();
-+        if (res != OK) {
-+            ALOGE("Failed to enumerate flash units: %s (%d)", strerror(-res), res);
-         }
- 
--        if (!cameraFound) {
--            hardware::camera::common::V1_0::CameraResourceCost cost;
--            res = mCameraProviderManager->getResourceCost(cameraId, &cost);
--            if (res != OK) {
--                ALOGE("Failed to query device resource cost: %s (%d)", strerror(-res), res);
--                continue;
--            }
--            std::set<String8> conflicting;
--            for (size_t i = 0; i < cost.conflictingDevices.size(); i++) {
--                conflicting.emplace(String8(cost.conflictingDevices[i].c_str()));
--            }
-+        deviceIds = mCameraProviderManager->getCameraDeviceIds();
-+    }
- 
--            {
--                Mutex::Autolock lock(mCameraStatesLock);
--                mCameraStates.emplace(id8,
--                    std::make_shared<CameraState>(id8, cost.resourceCost, conflicting));
--            }
--        }
- 
-+    for (auto& cameraId : deviceIds) {
-+        String8 id8 = String8(cameraId.c_str());
-         onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
--
--        if (mFlashlight->hasFlashUnit(id8)) {
--            mTorchStatusMap.add(id8, TorchModeStatus::AVAILABLE_OFF);
--        }
-     }
- 
-     return OK;
-@@ -312,6 +217,54 @@ void CameraService::onNewProviderRegistered() {
-     enumerateProviders();
- }
- 
-+void CameraService::updateCameraNumAndIds() {
-+    Mutex::Autolock l(mServiceLock);
-+    mNumberOfCameras = mCameraProviderManager->getCameraCount();
-+    mNormalDeviceIds =
-+            mCameraProviderManager->getAPI1CompatibleCameraDeviceIds();
-+}
-+
-+void CameraService::addStates(const String8 id) {
-+    std::string cameraId(id.c_str());
-+    hardware::camera::common::V1_0::CameraResourceCost cost;
-+    status_t res = mCameraProviderManager->getResourceCost(cameraId, &cost);
-+    if (res != OK) {
-+        ALOGE("Failed to query device resource cost: %s (%d)", strerror(-res), res);
-+        return;
-+    }
-+    std::set<String8> conflicting;
-+    for (size_t i = 0; i < cost.conflictingDevices.size(); i++) {
-+        conflicting.emplace(String8(cost.conflictingDevices[i].c_str()));
-+    }
-+
-+    {
-+        Mutex::Autolock lock(mCameraStatesLock);
-+        mCameraStates.emplace(id, std::make_shared<CameraState>(id, cost.resourceCost,
-+                                                                conflicting));
-+    }
-+
-+    if (mFlashlight->hasFlashUnit(id)) {
-+        Mutex::Autolock al(mTorchStatusMutex);
-+        mTorchStatusMap.add(id, TorchModeStatus::AVAILABLE_OFF);
-+    }
-+
-+    updateCameraNumAndIds();
-+    logDeviceAdded(id, "Device added");
-+}
-+
-+void CameraService::removeStates(const String8 id) {
-+    updateCameraNumAndIds();
-+    if (mFlashlight->hasFlashUnit(id)) {
-+        Mutex::Autolock al(mTorchStatusMutex);
-+        mTorchStatusMap.removeItem(id);
-+    }
-+
-+    {
-+        Mutex::Autolock lock(mCameraStatesLock);
-+        mCameraStates.erase(id);
-+    }
-+}
-+
- void CameraService::onDeviceStatusChanged(const String8& id,
-         CameraDeviceStatus newHalStatus) {
-     ALOGI("%s: Status changed for cameraId=%s, newStatus=%d", __FUNCTION__,
-@@ -323,8 +276,13 @@ void CameraService::onDeviceStatusChanged(const String8& id,
- 
-     if (state == nullptr) {
-         if (newStatus == StatusInternal::PRESENT) {
--            ALOGW("%s: Unknown camera ID %s, probably newly registered?",
-+            ALOGI("%s: Unknown camera ID %s, a new camera is added",
-                     __FUNCTION__, id.string());
-+
-+            // First add as absent to make sure clients are notified below
-+            addStates(id);
-+
-+            updateStatus(newStatus, id);
-         } else {
-             ALOGE("%s: Bad camera ID %s", __FUNCTION__, id.string());
-         }
-@@ -341,15 +299,16 @@ void CameraService::onDeviceStatusChanged(const String8& id,
-     if (newStatus == StatusInternal::NOT_PRESENT) {
-         logDeviceRemoved(id, String8::format("Device status changed from %d to %d", oldStatus,
-                 newStatus));
-+
-+        // Set the device status to NOT_PRESENT, clients will no longer be able to connect
-+        // to this device until the status changes
-+        updateStatus(StatusInternal::NOT_PRESENT, id);
-+
-         sp<BasicClient> clientToDisconnect;
-         {
-             // Don't do this in updateStatus to avoid deadlock over mServiceLock
-             Mutex::Autolock lock(mServiceLock);
- 
--            // Set the device status to NOT_PRESENT, clients will no longer be able to connect
--            // to this device until the status changes
--            updateStatus(StatusInternal::NOT_PRESENT, id);
--
-             // Remove cached shim parameters
-             state->setShimParams(CameraParameters());
- 
-@@ -371,6 +330,7 @@ void CameraService::onDeviceStatusChanged(const String8& id,
-             clientToDisconnect->disconnect();
-         }
- 
-+        removeStates(id);
-     } else {
-         if (oldStatus == StatusInternal::NOT_PRESENT) {
-             logDeviceAdded(id, String8::format("Device status changed from %d to %d", oldStatus,
-@@ -451,7 +411,7 @@ Status CameraService::getNumberOfCameras(int32_t type, int32_t* numCameras) {
-     Mutex::Autolock l(mServiceLock);
-     switch (type) {
-         case CAMERA_TYPE_BACKWARD_COMPATIBLE:
--            *numCameras = mNumberOfNormalCameras;
-+            *numCameras = static_cast<int>(mNormalDeviceIds.size());
-             break;
-         case CAMERA_TYPE_ALL:
-             *numCameras = mNumberOfCameras;
-@@ -481,7 +441,8 @@ Status CameraService::getCameraInfo(int cameraId,
-     }
- 
-     Status ret = Status::ok();
--    status_t err = mCameraProviderManager->getCameraInfo(std::to_string(cameraId), cameraInfo);
-+    status_t err = mCameraProviderManager->getCameraInfo(
-+            cameraIdIntToStrLocked(cameraId), cameraInfo);
-     if (err != OK) {
-         ret = STATUS_ERROR_FMT(ERROR_INVALID_OPERATION,
-                 "Error retrieving camera info from device %d: %s (%d)", cameraId,
-@@ -491,13 +452,19 @@ Status CameraService::getCameraInfo(int cameraId,
-     return ret;
- }
- 
--int CameraService::cameraIdToInt(const String8& cameraId) {
--    int id;
--    bool success = base::ParseInt(cameraId.string(), &id, 0);
--    if (!success) {
--        return -1;
-+std::string CameraService::cameraIdIntToStrLocked(int cameraIdInt) {
-+    if (cameraIdInt < 0 || cameraIdInt >= static_cast<int>(mNormalDeviceIds.size())) {
-+        ALOGE("%s: input id %d invalid: valid range  (0, %zu)",
-+                __FUNCTION__, cameraIdInt, mNormalDeviceIds.size());
-+        return std::string{};
-     }
--    return id;
-+
-+    return mNormalDeviceIds[cameraIdInt];
-+}
-+
-+String8 CameraService::cameraIdIntToStr(int cameraIdInt) {
-+    Mutex::Autolock lock(mServiceLock);
-+    return String8(cameraIdIntToStrLocked(cameraIdInt).c_str());
- }
- 
- Status CameraService::getCameraCharacteristics(const String16& cameraId,
-@@ -614,8 +581,8 @@ Status CameraService::filterGetInfoErrorCode(status_t err) {
- 
- Status CameraService::makeClient(const sp<CameraService>& cameraService,
-         const sp<IInterface>& cameraCb, const String16& packageName, const String8& cameraId,
--        int facing, int clientPid, uid_t clientUid, int servicePid, bool legacyMode,
--        int halVersion, int deviceVersion, apiLevel effectiveApiLevel,
-+        int api1CameraId, int facing, int clientPid, uid_t clientUid, int servicePid,
-+        bool legacyMode, int halVersion, int deviceVersion, apiLevel effectiveApiLevel,
-         /*out*/sp<BasicClient>* client) {
- 
-     if (halVersion < 0 || halVersion == deviceVersion) {
-@@ -625,8 +592,9 @@ Status CameraService::makeClient(const sp<CameraService>& cameraService,
-           case CAMERA_DEVICE_API_VERSION_1_0:
-             if (effectiveApiLevel == API_1) {  // Camera1 API route
-                 sp<ICameraClient> tmp = static_cast<ICameraClient*>(cameraCb.get());
--                *client = new CameraClient(cameraService, tmp, packageName, cameraIdToInt(cameraId),
--                        facing, clientPid, clientUid, getpid(), legacyMode);
-+                *client = new CameraClient(cameraService, tmp, packageName,
-+                        api1CameraId, facing, clientPid, clientUid,
-+                        getpid(), legacyMode);
-             } else { // Camera2 API route
-                 ALOGW("Camera using old HAL version: %d", deviceVersion);
-                 return STATUS_ERROR_FMT(ERROR_DEPRECATED_HAL,
-@@ -641,8 +609,10 @@ Status CameraService::makeClient(const sp<CameraService>& cameraService,
-           case CAMERA_DEVICE_API_VERSION_3_4:
-             if (effectiveApiLevel == API_1) { // Camera1 API route
-                 sp<ICameraClient> tmp = static_cast<ICameraClient*>(cameraCb.get());
--                *client = new Camera2Client(cameraService, tmp, packageName, cameraIdToInt(cameraId),
--                        facing, clientPid, clientUid, servicePid, legacyMode);
-+                *client = new Camera2Client(cameraService, tmp, packageName,
-+                        cameraId, api1CameraId,
-+                        facing, clientPid, clientUid,
-+                        servicePid, legacyMode);
-             } else { // Camera2 API route
-                 sp<hardware::camera2::ICameraDeviceCallbacks> tmp =
-                         static_cast<hardware::camera2::ICameraDeviceCallbacks*>(cameraCb.get());
-@@ -664,8 +634,9 @@ Status CameraService::makeClient(const sp<CameraService>& cameraService,
-             halVersion == CAMERA_DEVICE_API_VERSION_1_0) {
-             // Only support higher HAL version device opened as HAL1.0 device.
-             sp<ICameraClient> tmp = static_cast<ICameraClient*>(cameraCb.get());
--            *client = new CameraClient(cameraService, tmp, packageName, cameraIdToInt(cameraId),
--                    facing, clientPid, clientUid, servicePid, legacyMode);
-+            *client = new CameraClient(cameraService, tmp, packageName,
-+                    api1CameraId, facing, clientPid, clientUid,
-+                    servicePid, legacyMode);
-         } else {
-             // Other combinations (e.g. HAL3.x open as HAL2.x) are not supported yet.
-             ALOGE("Invalid camera HAL version %x: HAL %x device can only be"
-@@ -765,7 +736,8 @@ Status CameraService::initializeShimMetadata(int cameraId) {
-     Status ret = Status::ok();
-     sp<Client> tmp = nullptr;
-     if (!(ret = connectHelper<ICameraClient,Client>(
--            sp<ICameraClient>{nullptr}, id, static_cast<int>(CAMERA_HAL_API_VERSION_UNSPECIFIED),
-+            sp<ICameraClient>{nullptr}, id, cameraId,
-+            static_cast<int>(CAMERA_HAL_API_VERSION_UNSPECIFIED),
-             internalPackageName, uid, USE_CALLING_PID,
-             API_1, /*legacyMode*/ false, /*shimUpdateOnly*/ true,
-             /*out*/ tmp)
-@@ -1222,7 +1194,7 @@ status_t CameraService::handleEvictionsLocked(const String8& cameraId, int clien
- 
- Status CameraService::connect(
-         const sp<ICameraClient>& cameraClient,
--        int cameraId,
-+        int api1CameraId,
-         const String16& clientPackageName,
-         int clientUid,
-         int clientPid,
-@@ -1231,9 +1203,10 @@ Status CameraService::connect(
- 
-     ATRACE_CALL();
-     Status ret = Status::ok();
--    String8 id = String8::format("%d", cameraId);
-+
-+    String8 id = cameraIdIntToStr(api1CameraId);
-     sp<Client> client = nullptr;
--    ret = connectHelper<ICameraClient,Client>(cameraClient, id,
-+    ret = connectHelper<ICameraClient,Client>(cameraClient, id, api1CameraId,
-             CAMERA_HAL_API_VERSION_UNSPECIFIED, clientPackageName, clientUid, clientPid, API_1,
-             /*legacyMode*/ false, /*shimUpdateOnly*/ false,
-             /*out*/client);
-@@ -1250,18 +1223,18 @@ Status CameraService::connect(
- 
- Status CameraService::connectLegacy(
-         const sp<ICameraClient>& cameraClient,
--        int cameraId, int halVersion,
-+        int api1CameraId, int halVersion,
-         const String16& clientPackageName,
-         int clientUid,
-         /*out*/
-         sp<ICamera>* device) {
- 
-     ATRACE_CALL();
--    String8 id = String8::format("%d", cameraId);
-+    String8 id = cameraIdIntToStr(api1CameraId);
- 
-     Status ret = Status::ok();
-     sp<Client> client = nullptr;
--    ret = connectHelper<ICameraClient,Client>(cameraClient, id, halVersion,
-+    ret = connectHelper<ICameraClient,Client>(cameraClient, id, api1CameraId, halVersion,
-             clientPackageName, clientUid, USE_CALLING_PID, API_1,
-             /*legacyMode*/ true, /*shimUpdateOnly*/ false,
-             /*out*/client);
-@@ -1289,6 +1262,7 @@ Status CameraService::connectDevice(
-     String8 id = String8(cameraId);
-     sp<CameraDeviceClient> client = nullptr;
-     ret = connectHelper<hardware::camera2::ICameraDeviceCallbacks,CameraDeviceClient>(cameraCb, id,
-+            /*api1CameraId*/-1,
-             CAMERA_HAL_API_VERSION_UNSPECIFIED, clientPackageName,
-             clientUid, USE_CALLING_PID, API_2,
-             /*legacyMode*/ false, /*shimUpdateOnly*/ false,
-@@ -1306,8 +1280,8 @@ Status CameraService::connectDevice(
- 
- template<class CALLBACK, class CLIENT>
- Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8& cameraId,
--        int halVersion, const String16& clientPackageName, int clientUid, int clientPid,
--        apiLevel effectiveApiLevel, bool legacyMode, bool shimUpdateOnly,
-+        int api1CameraId, int halVersion, const String16& clientPackageName, int clientUid,
-+        int clientPid, apiLevel effectiveApiLevel, bool legacyMode, bool shimUpdateOnly,
-         /*out*/sp<CLIENT>& device) {
-     binder::Status ret = binder::Status::ok();
- 
-@@ -1390,8 +1364,10 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&
-         }
- 
-         sp<BasicClient> tmp = nullptr;
--        if(!(ret = makeClient(this, cameraCb, clientPackageName, cameraId, facing, clientPid,
--                clientUid, getpid(), legacyMode, halVersion, deviceVersion, effectiveApiLevel,
-+        if(!(ret = makeClient(this, cameraCb, clientPackageName,
-+                cameraId, api1CameraId, facing,
-+                clientPid, clientUid, getpid(), legacyMode,
-+                halVersion, deviceVersion, effectiveApiLevel,
-                 /*out*/&tmp)).isOk()) {
-             return ret;
-         }
-@@ -2102,7 +2078,8 @@ void CameraService::playSound(sound_kind kind) {
- CameraService::Client::Client(const sp<CameraService>& cameraService,
-         const sp<ICameraClient>& cameraClient,
-         const String16& clientPackageName,
--        const String8& cameraIdStr, int cameraFacing,
-+        const String8& cameraIdStr,
-+        int api1CameraId, int cameraFacing,
-         int clientPid, uid_t clientUid,
-         int servicePid) :
-         CameraService::BasicClient(cameraService,
-@@ -2111,7 +2088,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
-                 cameraIdStr, cameraFacing,
-                 clientPid, clientUid,
-                 servicePid),
--        mCameraId(CameraService::cameraIdToInt(cameraIdStr))
-+        mCameraId(api1CameraId)
- {
-     int callingPid = getCallingPid();
-     LOG1("Client::Client E (pid %d, id %d)", callingPid, mCameraId);
-@@ -2279,9 +2256,13 @@ status_t CameraService::BasicClient::startCameraOps() {
-     // Transition device availability listeners from PRESENT -> NOT_AVAILABLE
-     sCameraService->updateStatus(StatusInternal::NOT_AVAILABLE, mCameraIdStr);
- 
-+    int apiLevel = hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1;
-+    if (canCastToApiClient(API_2)) {
-+        apiLevel = hardware::ICameraServiceProxy::CAMERA_API_LEVEL_2;
-+    }
-     // Transition device state to OPEN
-     sCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_OPEN,
--            mCameraIdStr, mCameraFacing, mClientPackageName);
-+            mCameraIdStr, mCameraFacing, mClientPackageName, apiLevel);
- 
-     return OK;
- }
-@@ -2296,16 +2277,23 @@ status_t CameraService::BasicClient::finishCameraOps() {
-                 mClientPackageName);
-         mOpsActive = false;
- 
-+        // This function is called when a client disconnects. This should
-+        // release the camera, but actually only if it was in a proper
-+        // functional state, i.e. with status NOT_AVAILABLE
-         std::initializer_list<StatusInternal> rejected = {StatusInternal::PRESENT,
--                StatusInternal::ENUMERATING};
-+                StatusInternal::ENUMERATING, StatusInternal::NOT_PRESENT};
- 
-         // Transition to PRESENT if the camera is not in either of the rejected states
-         sCameraService->updateStatus(StatusInternal::PRESENT,
-                 mCameraIdStr, rejected);
- 
-+        int apiLevel = hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1;
-+        if (canCastToApiClient(API_2)) {
-+            apiLevel = hardware::ICameraServiceProxy::CAMERA_API_LEVEL_2;
-+        }
-         // Transition device state to CLOSED
-         sCameraService->updateProxyDeviceState(ICameraServiceProxy::CAMERA_STATE_CLOSED,
--                mCameraIdStr, mCameraFacing, mClientPackageName);
-+                mCameraIdStr, mCameraFacing, mClientPackageName, apiLevel);
-     }
-     // Always stop watching, even if no camera op is active
-     if (mOpsCallback != NULL) {
-@@ -2548,7 +2536,7 @@ void CameraService::UidPolicy::updateOverrideUid(uid_t uid, String16 callingPack
- 
- CameraService::CameraState::CameraState(const String8& id, int cost,
-         const std::set<String8>& conflicting) : mId(id),
--        mStatus(StatusInternal::PRESENT), mCost(cost), mConflicting(conflicting) {}
-+        mStatus(StatusInternal::NOT_PRESENT), mCost(cost), mConflicting(conflicting) {}
- 
- CameraService::CameraState::~CameraState() {}
- 
-@@ -2724,7 +2712,10 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) {
-     }
-     dprintf(fd, "\n== Service global info: ==\n\n");
-     dprintf(fd, "Number of camera devices: %d\n", mNumberOfCameras);
--    dprintf(fd, "Number of normal camera devices: %d\n", mNumberOfNormalCameras);
-+    dprintf(fd, "Number of normal camera devices: %zu\n", mNormalDeviceIds.size());
-+    for (size_t i = 0; i < mNormalDeviceIds.size(); i++) {
-+        dprintf(fd, "    Device %zu maps to \"%s\"\n", i, mNormalDeviceIds[i].c_str());
-+    }
-     String8 activeClientString = mActiveClientManager.toString();
-     dprintf(fd, "Active Camera Clients:\n%s", activeClientString.string());
-     dprintf(fd, "Allowed user IDs: %s\n", toString(mAllowedUsers).string());
-@@ -2979,11 +2970,11 @@ void CameraService::CameraState::updateStatus(StatusInternal status,
- }
- 
- void CameraService::updateProxyDeviceState(int newState,
--        const String8& cameraId, int facing, const String16& clientName) {
-+        const String8& cameraId, int facing, const String16& clientName, int apiLevel) {
-     sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
-     if (proxyBinder == nullptr) return;
-     String16 id(cameraId);
--    proxyBinder->notifyCameraState(id, newState, facing, clientName);
-+    proxyBinder->notifyCameraState(id, newState, facing, clientName, apiLevel);
- }
- 
- status_t CameraService::getTorchStatusLocked(
-diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
-index 6724c49..8d4bcdb 100644
---- a/services/camera/libcameraservice/CameraService.h
-+++ b/services/camera/libcameraservice/CameraService.h
-@@ -62,7 +62,6 @@ class CameraService :
-     public BinderService<CameraService>,
-     public virtual ::android::hardware::BnCameraService,
-     public virtual IBinder::DeathRecipient,
--    public camera_module_callbacks_t,
-     public virtual CameraProviderManager::StatusListener
- {
-     friend class BinderService<CameraService>;
-@@ -190,7 +189,8 @@ public:
-             int newState,
-             const String8& cameraId,
-             int facing,
--            const String16& clientName);
-+            const String16& clientName,
-+            int apiLevel);
- 
-     /////////////////////////////////////////////////////////////////////
-     // CameraDeviceFactory functionality
-@@ -334,6 +334,7 @@ public:
-                 const sp<hardware::ICameraClient>& cameraClient,
-                 const String16& clientPackageName,
-                 const String8& cameraIdStr,
-+                int api1CameraId,
-                 int cameraFacing,
-                 int clientPid,
-                 uid_t clientUid,
-@@ -555,6 +556,11 @@ private:
-     // Eumerate all camera providers in the system
-     status_t enumerateProviders();
- 
-+    // Add/remove a new camera to camera and torch state lists or remove an unplugged one
-+    // Caller must not hold mServiceLock
-+    void addStates(const String8 id);
-+    void removeStates(const String8 id);
-+
-     // Check if we can connect, before we acquire the service lock.
-     // The returned originalClientPid is the PID of the original process that wants to connect to
-     // camera.
-@@ -578,7 +584,7 @@ private:
-     // Single implementation shared between the various connect calls
-     template<class CALLBACK, class CLIENT>
-     binder::Status connectHelper(const sp<CALLBACK>& cameraCb, const String8& cameraId,
--            int halVersion, const String16& clientPackageName,
-+            int api1CameraId, int halVersion, const String16& clientPackageName,
-             int clientUid, int clientPid,
-             apiLevel effectiveApiLevel, bool legacyMode, bool shimUpdateOnly,
-             /*out*/sp<CLIENT>& device);
-@@ -643,9 +649,16 @@ private:
-     void finishConnectLocked(const sp<BasicClient>& client, const DescriptorPtr& desc);
- 
-     /**
--     * Returns the integer corresponding to the given camera ID string, or -1 on failure.
-+     * Returns the underlying camera Id string mapped to a camera id int
-+     * Empty string is returned when the cameraIdInt is invalid.
-+     */
-+    String8 cameraIdIntToStr(int cameraIdInt);
-+
-+    /**
-+     * Returns the underlying camera Id string mapped to a camera id int
-+     * Empty string is returned when the cameraIdInt is invalid.
-      */
--    static int cameraIdToInt(const String8& cameraId);
-+    std::string cameraIdIntToStrLocked(int cameraIdInt);
- 
-     /**
-      * Remove a single client corresponding to the given camera id from the list of active clients.
-@@ -713,8 +726,14 @@ private:
-      */
-     void dumpEventLog(int fd);
- 
-+    /**
-+     * This method will acquire mServiceLock
-+     */
-+    void updateCameraNumAndIds();
-+
-     int                 mNumberOfCameras;
--    int                 mNumberOfNormalCameras;
-+
-+    std::vector<std::string> mNormalDeviceIds;
- 
-     // sounds
-     sp<MediaPlayer>     newMediaPlayer(const char *file);
-@@ -824,8 +843,8 @@ private:
- 
-     static binder::Status makeClient(const sp<CameraService>& cameraService,
-             const sp<IInterface>& cameraCb, const String16& packageName, const String8& cameraId,
--            int facing, int clientPid, uid_t clientUid, int servicePid, bool legacyMode,
--            int halVersion, int deviceVersion, apiLevel effectiveApiLevel,
-+            int api1CameraId, int facing, int clientPid, uid_t clientUid, int servicePid,
-+            bool legacyMode, int halVersion, int deviceVersion, apiLevel effectiveApiLevel,
-             /*out*/sp<BasicClient>* client);
- 
-     status_t checkCameraAccess(const String16& opPackageName);
-diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
-index dd1cf2c..65faac9 100644
---- a/services/camera/libcameraservice/api1/Camera2Client.cpp
-+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
-@@ -49,16 +49,17 @@ static int getCallingPid() {
- Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
-         const sp<hardware::ICameraClient>& cameraClient,
-         const String16& clientPackageName,
--        int cameraId,
-+        const String8& cameraDeviceId,
-+        int api1CameraId,
-         int cameraFacing,
-         int clientPid,
-         uid_t clientUid,
-         int servicePid,
-         bool legacyMode):
-         Camera2ClientBase(cameraService, cameraClient, clientPackageName,
--                String8::format("%d", cameraId), cameraFacing,
-+                cameraDeviceId, api1CameraId, cameraFacing,
-                 clientPid, clientUid, servicePid),
--        mParameters(cameraId, cameraFacing)
-+        mParameters(api1CameraId, cameraFacing)
- {
-     ATRACE_CALL();
- 
-diff --git a/services/camera/libcameraservice/api1/Camera2Client.h b/services/camera/libcameraservice/api1/Camera2Client.h
-index c17cbd4..44929c3 100644
---- a/services/camera/libcameraservice/api1/Camera2Client.h
-+++ b/services/camera/libcameraservice/api1/Camera2Client.h
-@@ -91,7 +91,8 @@ public:
-     Camera2Client(const sp<CameraService>& cameraService,
-             const sp<hardware::ICameraClient>& cameraClient,
-             const String16& clientPackageName,
--            int cameraId,
-+            const String8& cameraDeviceId,
-+            int api1CameraId,
-             int cameraFacing,
-             int clientPid,
-             uid_t clientUid,
-diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp
-index e2c8b8b..2358c1e 100644
---- a/services/camera/libcameraservice/api1/CameraClient.cpp
-+++ b/services/camera/libcameraservice/api1/CameraClient.cpp
-@@ -42,7 +42,7 @@ CameraClient::CameraClient(const sp<CameraService>& cameraService,
-         int clientPid, int clientUid,
-         int servicePid, bool legacyMode):
-         Client(cameraService, cameraClient, clientPackageName,
--                String8::format("%d", cameraId), cameraFacing, clientPid,
-+                String8::format("%d", cameraId), cameraId, cameraFacing, clientPid,
-                 clientUid, servicePid)
- {
-     int callingPid = getCallingPid();
-@@ -264,7 +264,8 @@ binder::Status CameraClient::disconnect() {
-     mHardware->stopPreview();
-     sCameraService->updateProxyDeviceState(
-             hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
--            mCameraIdStr, mCameraFacing, mClientPackageName);
-+            mCameraIdStr, mCameraFacing, mClientPackageName,
-+            hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
-     mHardware->cancelPicture();
-     // Release the hardware resources.
-     mHardware->release();
-@@ -427,7 +428,8 @@ status_t CameraClient::startPreviewMode() {
-     if (result == NO_ERROR) {
-         sCameraService->updateProxyDeviceState(
-             hardware::ICameraServiceProxy::CAMERA_STATE_ACTIVE,
--            mCameraIdStr, mCameraFacing, mClientPackageName);
-+            mCameraIdStr, mCameraFacing, mClientPackageName,
-+            hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
-     }
-     return result;
- }
-@@ -470,7 +472,8 @@ void CameraClient::stopPreview() {
-     mHardware->stopPreview();
-     sCameraService->updateProxyDeviceState(
-         hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
--        mCameraIdStr, mCameraFacing, mClientPackageName);
-+        mCameraIdStr, mCameraFacing, mClientPackageName,
-+        hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
-     mPreviewBuffer.clear();
- }
- 
-@@ -981,7 +984,8 @@ void CameraClient::handleShutter(void) {
-     // idle now, until preview is restarted
-     sCameraService->updateProxyDeviceState(
-         hardware::ICameraServiceProxy::CAMERA_STATE_IDLE,
--        mCameraIdStr, mCameraFacing, mClientPackageName);
-+        mCameraIdStr, mCameraFacing, mClientPackageName,
-+        hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1);
- 
-     mLock.unlock();
- }
-diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
-index 7373b81..d66dec4 100644
---- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
-+++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
-@@ -761,12 +761,17 @@ status_t Parameters::initialize(const CameraMetadata *info, int deviceVersion) {
-     focusingAreas.clear();
-     focusingAreas.add(Parameters::Area(0,0,0,0,0));
- 
--    camera_metadata_ro_entry_t availableFocalLengths =
--        staticInfo(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, 0, 0, false);
--    if (!availableFocalLengths.count) return NO_INIT;
-+    if (fastInfo.isExternalCamera) {
-+        params.setFloat(CameraParameters::KEY_FOCAL_LENGTH, -1.0);
-+    } else {
-+        camera_metadata_ro_entry_t availableFocalLengths =
-+            staticInfo(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, 0, 0, false);
-+        if (!availableFocalLengths.count) return NO_INIT;
-+
-+        float minFocalLength = availableFocalLengths.data.f[0];
-+        params.setFloat(CameraParameters::KEY_FOCAL_LENGTH, minFocalLength);
-+    }
- 
--    float minFocalLength = availableFocalLengths.data.f[0];
--    params.setFloat(CameraParameters::KEY_FOCAL_LENGTH, minFocalLength);
- 
-     float horizFov, vertFov;
-     res = calculatePictureFovs(&horizFov, &vertFov);
-@@ -1104,9 +1109,15 @@ status_t Parameters::buildFastInfo() {
-             focusDistanceCalibration.data.u8[0] !=
-             ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED);
- 
-+
-+    camera_metadata_ro_entry_t hwLevel = staticInfo(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL);
-+    if (!hwLevel.count) return NO_INIT;
-+    fastInfo.isExternalCamera =
-+            hwLevel.data.u8[0] == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL;
-+
-     camera_metadata_ro_entry_t availableFocalLengths =
--        staticInfo(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS);
--    if (!availableFocalLengths.count) return NO_INIT;
-+        staticInfo(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, 0, 0, /*required*/false);
-+    if (!availableFocalLengths.count && !fastInfo.isExternalCamera) return NO_INIT;
- 
-     SortedVector<int32_t> availableFormats = getAvailableOutputFormats();
-     if (!availableFormats.size()) return NO_INIT;
-@@ -1191,10 +1202,14 @@ status_t Parameters::buildFastInfo() {
- 
-     // Find smallest (widest-angle) focal length to use as basis of still
-     // picture FOV reporting.
--    fastInfo.minFocalLength = availableFocalLengths.data.f[0];
--    for (size_t i = 1; i < availableFocalLengths.count; i++) {
--        if (fastInfo.minFocalLength > availableFocalLengths.data.f[i]) {
--            fastInfo.minFocalLength = availableFocalLengths.data.f[i];
-+    if (fastInfo.isExternalCamera) {
-+        fastInfo.minFocalLength = -1.0;
-+    } else {
-+        fastInfo.minFocalLength = availableFocalLengths.data.f[0];
-+        for (size_t i = 1; i < availableFocalLengths.count; i++) {
-+            if (fastInfo.minFocalLength > availableFocalLengths.data.f[i]) {
-+                fastInfo.minFocalLength = availableFocalLengths.data.f[i];
-+            }
-         }
-     }
- 
-@@ -2921,8 +2936,13 @@ status_t Parameters::getFilteredSizes(Size limit, Vector<Size> *sizes) {
-         if (sc.isInput == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT &&
-                 sc.format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED &&
-                 sc.width <= limit.width && sc.height <= limit.height) {
--            Size sz = {sc.width, sc.height};
--            sizes->push(sz);
-+            int64_t minFrameDuration = getMinFrameDurationNs(
-+                    {sc.width, sc.height}, HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED);
-+            if (minFrameDuration > MAX_PREVIEW_RECORD_DURATION_NS) {
-+                // Filter slow sizes from preview/record
-+                continue;
-+            }
-+            sizes->push({sc.width, sc.height});
-         }
-     }
- 
-@@ -3132,6 +3152,16 @@ Parameters::CropRegion Parameters::calculateCropRegion(bool previewOnly) const {
- 
- status_t Parameters::calculatePictureFovs(float *horizFov, float *vertFov)
-         const {
-+    if (fastInfo.isExternalCamera) {
-+        if (horizFov != NULL) {
-+            *horizFov = -1.0;
-+        }
-+        if (vertFov != NULL) {
-+            *vertFov = -1.0;
-+        }
-+        return OK;
-+    }
-+
-     camera_metadata_ro_entry_t sensorSize =
-             staticInfo(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, 2, 2);
-     if (!sensorSize.count) return NO_INIT;
-diff --git a/services/camera/libcameraservice/api1/client2/Parameters.h b/services/camera/libcameraservice/api1/client2/Parameters.h
-index f0bde5b..97f8ea7 100644
---- a/services/camera/libcameraservice/api1/client2/Parameters.h
-+++ b/services/camera/libcameraservice/api1/client2/Parameters.h
-@@ -209,6 +209,11 @@ struct Parameters {
-     static const int32_t FPS_MARGIN = 1;
-     // Max FPS for default parameters
-     static const int32_t MAX_DEFAULT_FPS = 30;
-+    // Minimum FPS for a size to be listed in supported preview/video sizes
-+    // Set to slightly less than 30.0 to have some tolerance margin
-+    static constexpr double MIN_PREVIEW_RECORD_FPS = 29.97;
-+    // Maximum frame duration for a size to be listed in supported preview/video sizes
-+    static constexpr int64_t MAX_PREVIEW_RECORD_DURATION_NS = 1e9 / MIN_PREVIEW_RECORD_FPS;
- 
-     // Full static camera info, object owned by someone else, such as
-     // Camera2Device.
-@@ -235,6 +240,7 @@ struct Parameters {
-             }
-         };
-         DefaultKeyedVector<uint8_t, OverrideModes> sceneModeOverrides;
-+        bool isExternalCamera;
-         float minFocalLength;
-         bool useFlexibleYuv;
-         Size maxJpegSize;
-@@ -383,6 +389,7 @@ private:
-     Vector<Size> availablePreviewSizes;
-     Vector<Size> availableVideoSizes;
-     // Get size list (that are no larger than limit) from static metadata.
-+    // This method filtered size with minFrameDuration < MAX_PREVIEW_RECORD_DURATION_NS
-     status_t getFilteredSizes(Size limit, Vector<Size> *sizes);
-     // Get max size (from the size array) that matches the given aspect ratio.
-     Size getMaxSizeForRatio(float ratio, const int32_t* sizeArray, size_t count);
-diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
-index 2297ed3..98d0534 100644
---- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
-+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
-@@ -49,6 +49,7 @@ CameraDeviceClientBase::CameraDeviceClientBase(
-         const sp<hardware::camera2::ICameraDeviceCallbacks>& remoteCallback,
-         const String16& clientPackageName,
-         const String8& cameraId,
-+        int api1CameraId,
-         int cameraFacing,
-         int clientPid,
-         uid_t clientUid,
-@@ -62,6 +63,8 @@ CameraDeviceClientBase::CameraDeviceClientBase(
-             clientUid,
-             servicePid),
-     mRemoteCallback(remoteCallback) {
-+    // We don't need it for API2 clients, but Camera2ClientBase requires it.
-+    (void) api1CameraId;
- }
- 
- // Interface used by CameraService
-@@ -75,7 +78,8 @@ CameraDeviceClient::CameraDeviceClient(const sp<CameraService>& cameraService,
-         uid_t clientUid,
-         int servicePid) :
-     Camera2ClientBase(cameraService, remoteCallback, clientPackageName,
--                cameraId, cameraFacing, clientPid, clientUid, servicePid),
-+                cameraId, /*API1 camera ID*/ -1,
-+                cameraFacing, clientPid, clientUid, servicePid),
-     mInputStream(),
-     mStreamingRequestId(REQUEST_ID_NONE),
-     mRequestIdCounter(0) {
-@@ -620,11 +624,19 @@ binder::Status CameraDeviceClient::createStream(
-         return STATUS_ERROR(CameraService::ERROR_DISCONNECTED, "Camera device no longer alive");
-     }
- 
--    if (!checkPhysicalCameraId(physicalCameraId)) {
--        String8 msg = String8::format("Camera %s: Camera doesn't support physicalCameraId %s.",
-+    if (physicalCameraId.size() > 0) {
-+        std::vector<std::string> physicalCameraIds;
-+        std::string physicalId(physicalCameraId.string());
-+        bool logicalCamera =
-+                CameraProviderManager::isLogicalCamera(mDevice->info(), &physicalCameraIds);
-+        if (!logicalCamera ||
-+                std::find(physicalCameraIds.begin(), physicalCameraIds.end(), physicalId) ==
-+                physicalCameraIds.end()) {
-+            String8 msg = String8::format("Camera %s: Camera doesn't support physicalCameraId %s.",
-                     mCameraIdStr.string(), physicalCameraId.string());
--        ALOGE("%s: %s", __FUNCTION__, msg.string());
--        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
-+            ALOGE("%s: %s", __FUNCTION__, msg.string());
-+            return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
-+        }
-     }
-     std::vector<sp<Surface>> surfaces;
-     std::vector<sp<IBinder>> binders;
-@@ -1140,43 +1152,6 @@ binder::Status CameraDeviceClient::createSurfaceFromGbp(
-     return binder::Status::ok();
- }
- 
--bool CameraDeviceClient::checkPhysicalCameraId(const String8& physicalCameraId) {
--    if (0 == physicalCameraId.size()) {
--        return true;
--    }
--
--    CameraMetadata staticInfo = mDevice->info();
--    camera_metadata_entry_t entryCap;
--    bool isLogicalCam = false;
--
--    entryCap = staticInfo.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
--    for (size_t i = 0; i < entryCap.count; ++i) {
--        uint8_t capability = entryCap.data.u8[i];
--        if (capability == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) {
--            isLogicalCam = true;
--        }
--    }
--    if (!isLogicalCam) {
--        return false;
--    }
--
--    camera_metadata_entry_t entryIds = staticInfo.find(ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS);
--    const uint8_t* ids = entryIds.data.u8;
--    size_t start = 0;
--    for (size_t i = 0; i < entryIds.count; ++i) {
--        if (ids[i] == '\0') {
--            if (start != i) {
--                String8 currentId((const char*)ids+start);
--                if (currentId == physicalCameraId) {
--                    return true;
--                }
--            }
--            start = i+1;
--        }
--    }
--    return false;
--}
--
- bool CameraDeviceClient::roundBufferDimensionNearest(int32_t width, int32_t height,
-         int32_t format, android_dataspace dataSpace, const CameraMetadata& info,
-         /*out*/int32_t* outWidth, /*out*/int32_t* outHeight) {
-diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.h b/services/camera/libcameraservice/api2/CameraDeviceClient.h
-index 5bec39c..5aaf5aa 100644
---- a/services/camera/libcameraservice/api2/CameraDeviceClient.h
-+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.h
-@@ -45,6 +45,7 @@ protected:
-             const sp<hardware::camera2::ICameraDeviceCallbacks>& remoteCallback,
-             const String16& clientPackageName,
-             const String8& cameraId,
-+            int api1CameraId,
-             int cameraFacing,
-             int clientPid,
-             uid_t clientUid,
-diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.cpp b/services/camera/libcameraservice/common/Camera2ClientBase.cpp
-index 5c6711a..ce006a7 100644
---- a/services/camera/libcameraservice/common/Camera2ClientBase.cpp
-+++ b/services/camera/libcameraservice/common/Camera2ClientBase.cpp
-@@ -48,15 +48,16 @@ Camera2ClientBase<TClientBase>::Camera2ClientBase(
-         const sp<TCamCallbacks>& remoteCallback,
-         const String16& clientPackageName,
-         const String8& cameraId,
-+        int api1CameraId,
-         int cameraFacing,
-         int clientPid,
-         uid_t clientUid,
-         int servicePid):
-         TClientBase(cameraService, remoteCallback, clientPackageName,
--                cameraId, cameraFacing, clientPid, clientUid, servicePid),
-+                cameraId, api1CameraId, cameraFacing, clientPid, clientUid, servicePid),
-         mSharedCameraCallbacks(remoteCallback),
-         mDeviceVersion(cameraService->getDeviceVersion(TClientBase::mCameraIdStr)),
--        mDeviceActive(false)
-+        mDeviceActive(false), mApi1CameraId(api1CameraId)
- {
-     ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
-             String8(clientPackageName).string(), clientPid, clientUid);
-@@ -252,7 +253,9 @@ void Camera2ClientBase<TClientBase>::notifyIdle() {
-     if (mDeviceActive) {
-         getCameraService()->updateProxyDeviceState(
-             hardware::ICameraServiceProxy::CAMERA_STATE_IDLE, TClientBase::mCameraIdStr,
--            TClientBase::mCameraFacing, TClientBase::mClientPackageName);
-+            TClientBase::mCameraFacing, TClientBase::mClientPackageName,
-+            ((mApi1CameraId < 0) ? hardware::ICameraServiceProxy::CAMERA_API_LEVEL_2 :
-+             hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1));
-     }
-     mDeviceActive = false;
- 
-@@ -268,7 +271,9 @@ void Camera2ClientBase<TClientBase>::notifyShutter(const CaptureResultExtras& re
-     if (!mDeviceActive) {
-         getCameraService()->updateProxyDeviceState(
-             hardware::ICameraServiceProxy::CAMERA_STATE_ACTIVE, TClientBase::mCameraIdStr,
--            TClientBase::mCameraFacing, TClientBase::mClientPackageName);
-+            TClientBase::mCameraFacing, TClientBase::mClientPackageName,
-+            ((mApi1CameraId < 0) ? hardware::ICameraServiceProxy::CAMERA_API_LEVEL_2 :
-+             hardware::ICameraServiceProxy::CAMERA_API_LEVEL_1));
-     }
-     mDeviceActive = true;
- 
-@@ -331,7 +336,7 @@ void Camera2ClientBase<TClientBase>::notifyRepeatingRequestError(long lastFrameN
- 
- template <typename TClientBase>
- int Camera2ClientBase<TClientBase>::getCameraId() const {
--    return std::stoi(TClientBase::mCameraIdStr.string());
-+    return mApi1CameraId;
- }
- 
- template <typename TClientBase>
-diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.h b/services/camera/libcameraservice/common/Camera2ClientBase.h
-index 4da422a..e74fbdf 100644
---- a/services/camera/libcameraservice/common/Camera2ClientBase.h
-+++ b/services/camera/libcameraservice/common/Camera2ClientBase.h
-@@ -49,6 +49,7 @@ public:
-                       const sp<TCamCallbacks>& remoteCallback,
-                       const String16& clientPackageName,
-                       const String8& cameraId,
-+                      int api1CameraId,
-                       int cameraFacing,
-                       int clientPid,
-                       uid_t clientUid,
-@@ -140,6 +141,8 @@ protected:
- 
-     bool                  mDeviceActive;
- 
-+    const int             mApi1CameraId; // -1 if client is API2
-+
- private:
-     template<typename TProviderPtr>
-     status_t              initializeImpl(TProviderPtr providerPtr, const String8& monitorTags);
-diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
-index 4bc78dd..21cfd44 100644
---- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
-+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
-@@ -20,11 +20,13 @@
- 
- #include "CameraProviderManager.h"
- 
-+#include <algorithm>
- #include <chrono>
- #include <inttypes.h>
- #include <hidl/ServiceManagement.h>
- #include <functional>
- #include <camera_metadata_hidden.h>
-+#include <android-base/parseint.h>
- 
- namespace android {
- 
-@@ -39,9 +41,6 @@ const std::string kLegacyProviderName("legacy/0");
- const std::string kExternalProviderName("external/0");
- #endif
- 
--// Slash-separated list of provider types to consider for use via the old camera API
--const std::string kStandardProviderTypes("internal/legacy");
--
- } // anonymous namespace
- 
- CameraProviderManager::HardwareServiceInteractionProxy
-@@ -83,18 +82,7 @@ int CameraProviderManager::getCameraCount() const {
-     std::lock_guard<std::mutex> lock(mInterfaceMutex);
-     int count = 0;
-     for (auto& provider : mProviders) {
--        count += provider->mUniqueDeviceCount;
--    }
--    return count;
--}
--
--int CameraProviderManager::getAPI1CompatibleCameraCount() const {
--    std::lock_guard<std::mutex> lock(mInterfaceMutex);
--    int count = 0;
--    for (auto& provider : mProviders) {
--        if (kStandardProviderTypes.find(provider->getType()) != std::string::npos) {
--            count += provider->mUniqueAPI1CompatibleCameraIds.size();
--        }
-+        count += provider->mUniqueCameraIds.size();
-     }
-     return count;
- }
-@@ -114,12 +102,33 @@ std::vector<std::string> CameraProviderManager::getAPI1CompatibleCameraDeviceIds
-     std::lock_guard<std::mutex> lock(mInterfaceMutex);
-     std::vector<std::string> deviceIds;
-     for (auto& provider : mProviders) {
--        if (kStandardProviderTypes.find(provider->getType()) != std::string::npos) {
--            for (auto& id : provider->mUniqueAPI1CompatibleCameraIds) {
--                deviceIds.push_back(id);
--            }
--        }
-+        std::vector<std::string> providerDeviceIds = provider->mUniqueAPI1CompatibleCameraIds;
-+
-+        // API1 app doesn't handle logical and physical camera devices well. So
-+        // for each [logical, physical1, physical2, ...] id combo, only take the
-+        // first id advertised by HAL, and filter out the rest.
-+        filterLogicalCameraIdsLocked(providerDeviceIds);
-+
-+        deviceIds.insert(deviceIds.end(), providerDeviceIds.begin(), providerDeviceIds.end());
-     }
-+
-+    std::sort(deviceIds.begin(), deviceIds.end(),
-+            [](const std::string& a, const std::string& b) -> bool {
-+                uint32_t aUint = 0, bUint = 0;
-+                bool aIsUint = base::ParseUint(a, &aUint);
-+                bool bIsUint = base::ParseUint(b, &bUint);
-+
-+                // Uint device IDs first
-+                if (aIsUint && bIsUint) {
-+                    return aUint < bUint;
-+                } else if (aIsUint) {
-+                    return true;
-+                } else if (bIsUint) {
-+                    return false;
-+                }
-+                // Simple string compare if both id are not uint
-+                return a < b;
-+            });
-     return deviceIds;
- }
- 
-@@ -172,11 +181,7 @@ status_t CameraProviderManager::getCameraInfo(const std::string &id,
- status_t CameraProviderManager::getCameraCharacteristics(const std::string &id,
-         CameraMetadata* characteristics) const {
-     std::lock_guard<std::mutex> lock(mInterfaceMutex);
--
--    auto deviceInfo = findDeviceInfoLocked(id, /*minVersion*/ {3,0}, /*maxVersion*/ {4,0});
--    if (deviceInfo == nullptr) return NAME_NOT_FOUND;
--
--    return deviceInfo->getCameraCharacteristics(characteristics);
-+    return getCameraCharacteristicsLocked(id, characteristics);
- }
- 
- status_t CameraProviderManager::getHighestSupportedVersion(const std::string &id,
-@@ -391,6 +396,37 @@ metadata_vendor_id_t CameraProviderManager::getProviderTagIdLocked(
-     return ret;
- }
- 
-+bool CameraProviderManager::isLogicalCamera(const CameraMetadata& staticInfo,
-+        std::vector<std::string>* physicalCameraIds) {
-+    bool isLogicalCam = false;
-+    camera_metadata_ro_entry_t entryCap;
-+
-+    entryCap = staticInfo.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
-+    for (size_t i = 0; i < entryCap.count; ++i) {
-+        uint8_t capability = entryCap.data.u8[i];
-+        if (capability == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) {
-+            isLogicalCam = true;
-+            break;
-+        }
-+    }
-+    if (!isLogicalCam) {
-+        return false;
-+    }
-+
-+    camera_metadata_ro_entry_t entryIds = staticInfo.find(ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS);
-+    const uint8_t* ids = entryIds.data.u8;
-+    size_t start = 0;
-+    for (size_t i = 0; i < entryIds.count; ++i) {
-+        if (ids[i] == '\0') {
-+            if (start != i) {
-+                physicalCameraIds->push_back((const char*)ids+start);
-+            }
-+            start = i+1;
-+        }
-+    }
-+    return true;
-+}
-+
- status_t CameraProviderManager::addProviderLocked(const std::string& newProvider, bool expected) {
-     for (const auto& providerInfo : mProviders) {
-         if (providerInfo->mProviderName == newProvider) {
-@@ -484,6 +520,8 @@ status_t CameraProviderManager::ProviderInfo::initialize() {
-     }
-     ALOGI("Connecting to new camera provider: %s, isRemote? %d",
-             mProviderName.c_str(), mInterface->isRemote());
-+    // cameraDeviceStatusChange callbacks may be called (and causing new devices added)
-+    // before setCallback returns
-     hardware::Return<Status> status = mInterface->setCallback(this);
-     if (!status.isOk()) {
-         ALOGE("%s: Transaction error setting up callbacks with camera provider '%s': %s",
-@@ -540,17 +578,10 @@ status_t CameraProviderManager::ProviderInfo::initialize() {
-         }
-     }
- 
--    for (auto& device : mDevices) {
--        mUniqueCameraIds.insert(device->mId);
--        if (device->isAPI1Compatible()) {
--            mUniqueAPI1CompatibleCameraIds.insert(device->mId);
--        }
--    }
--    mUniqueDeviceCount = mUniqueCameraIds.size();
--
-     ALOGI("Camera provider %s ready with %zu camera devices",
-             mProviderName.c_str(), mDevices.size());
- 
-+    mInitialized = true;
-     return OK;
- }
- 
-@@ -598,15 +629,36 @@ status_t CameraProviderManager::ProviderInfo::addDevice(const std::string& name,
-     }
-     if (deviceInfo == nullptr) return BAD_VALUE;
-     deviceInfo->mStatus = initialStatus;
-+    bool isAPI1Compatible = deviceInfo->isAPI1Compatible();
- 
-     mDevices.push_back(std::move(deviceInfo));
- 
-+    mUniqueCameraIds.insert(id);
-+    if (isAPI1Compatible) {
-+        mUniqueAPI1CompatibleCameraIds.push_back(id);
-+    }
-+
-     if (parsedId != nullptr) {
-         *parsedId = id;
-     }
-     return OK;
- }
- 
-+void CameraProviderManager::ProviderInfo::removeDevice(std::string id) {
-+    for (auto it = mDevices.begin(); it != mDevices.end(); it++) {
-+        if ((*it)->mId == id) {
-+            mUniqueCameraIds.erase(id);
-+            if ((*it)->isAPI1Compatible()) {
-+                mUniqueAPI1CompatibleCameraIds.erase(std::remove(
-+                        mUniqueAPI1CompatibleCameraIds.begin(),
-+                        mUniqueAPI1CompatibleCameraIds.end(), id));
-+            }
-+            mDevices.erase(it);
-+            break;
-+        }
-+    }
-+}
-+
- status_t CameraProviderManager::ProviderInfo::dump(int fd, const Vector<String16>&) const {
-     dprintf(fd, "== Camera Provider HAL %s (v2.4, %s) static info: %zu devices: ==\n",
-             mProviderName.c_str(), mInterface->isRemote() ? "remote" : "passthrough",
-@@ -666,6 +718,7 @@ hardware::Return<void> CameraProviderManager::ProviderInfo::cameraDeviceStatusCh
-         CameraDeviceStatus newStatus) {
-     sp<StatusListener> listener;
-     std::string id;
-+    bool initialized = false;
-     {
-         std::lock_guard<std::mutex> lock(mLock);
-         bool known = false;
-@@ -688,11 +741,17 @@ hardware::Return<void> CameraProviderManager::ProviderInfo::cameraDeviceStatusCh
-                 return hardware::Void();
-             }
-             addDevice(cameraDeviceName, newStatus, &id);
-+        } else if (newStatus == CameraDeviceStatus::NOT_PRESENT) {
-+            removeDevice(id);
-         }
-         listener = mManager->getStatusListener();
-+        initialized = mInitialized;
-     }
-     // Call without lock held to allow reentrancy into provider manager
--    if (listener != nullptr) {
-+    // Don't send the callback if providerInfo hasn't been initialized.
-+    // CameraService will initialize device status after provider is
-+    // initialized
-+    if (listener != nullptr && initialized) {
-         listener->onDeviceStatusChanged(String8(id.c_str()), newStatus);
-     }
-     return hardware::Void();
-@@ -1396,5 +1455,51 @@ status_t HidlVendorTagDescriptor::createDescriptorFromHidl(
-     return OK;
- }
- 
-+status_t CameraProviderManager::getCameraCharacteristicsLocked(const std::string &id,
-+        CameraMetadata* characteristics) const {
-+    auto deviceInfo = findDeviceInfoLocked(id, /*minVersion*/ {3,0}, /*maxVersion*/ {4,0});
-+    if (deviceInfo == nullptr) return NAME_NOT_FOUND;
-+
-+    return deviceInfo->getCameraCharacteristics(characteristics);
-+}
-+
-+void CameraProviderManager::filterLogicalCameraIdsLocked(
-+        std::vector<std::string>& deviceIds) const
-+{
-+    std::unordered_set<std::string> removedIds;
-+
-+    for (auto& deviceId : deviceIds) {
-+        CameraMetadata info;
-+        status_t res = getCameraCharacteristicsLocked(deviceId, &info);
-+        if (res != OK) {
-+            ALOGE("%s: Failed to getCameraCharacteristics for id %s", __FUNCTION__,
-+                    deviceId.c_str());
-+            return;
-+        }
-+
-+        // idCombo contains the ids of a logical camera and its physical cameras
-+        std::vector<std::string> idCombo;
-+        bool logicalCamera = CameraProviderManager::isLogicalCamera(info, &idCombo);
-+        if (!logicalCamera) {
-+            continue;
-+        }
-+        idCombo.push_back(deviceId);
-+
-+        for (auto& id : deviceIds) {
-+            auto foundId = std::find(idCombo.begin(), idCombo.end(), id);
-+            if (foundId == idCombo.end()) {
-+                continue;
-+            }
-+
-+            idCombo.erase(foundId);
-+            removedIds.insert(idCombo.begin(), idCombo.end());
-+            break;
-+        }
-+    }
-+
-+    deviceIds.erase(std::remove_if(deviceIds.begin(), deviceIds.end(),
-+            [&removedIds](const std::string& s) {return removedIds.find(s) != removedIds.end();}),
-+            deviceIds.end());
-+}
- 
- } // namespace android
-diff --git a/services/camera/libcameraservice/common/CameraProviderManager.h b/services/camera/libcameraservice/common/CameraProviderManager.h
-index 0f1f07b..b8b8b8c 100644
---- a/services/camera/libcameraservice/common/CameraProviderManager.h
-+++ b/services/camera/libcameraservice/common/CameraProviderManager.h
-@@ -18,7 +18,7 @@
- #define ANDROID_SERVERS_CAMERA_CAMERAPROVIDER_H
- 
- #include <vector>
--#include <set>
-+#include <unordered_set>
- #include <string>
- #include <mutex>
- 
-@@ -125,16 +125,14 @@ public:
-      */
-     int getCameraCount() const;
- 
-+    std::vector<std::string> getCameraDeviceIds() const;
-+
-     /**
-      * Retrieve the number of API1 compatible cameras; these are internal and
-      * backwards-compatible. This is the set of cameras that will be
--     * accessible via the old camera API, with IDs in range of
--     * [0, getAPI1CompatibleCameraCount()-1]. This value is not expected to change dynamically.
-+     * accessible via the old camera API.
-+     * The return value may change dynamically due to external camera hotplug.
-      */
--    int getAPI1CompatibleCameraCount() const;
--
--    std::vector<std::string> getCameraDeviceIds() const;
--
-     std::vector<std::string> getAPI1CompatibleCameraDeviceIds() const;
- 
-     /**
-@@ -232,6 +230,13 @@ public:
-             hardware::hidl_version minVersion = hardware::hidl_version{0,0},
-             hardware::hidl_version maxVersion = hardware::hidl_version{1000,0}) const;
- 
-+    /*
-+     * Check if a camera with staticInfo is a logical camera. And if yes, return
-+     * the physical camera ids.
-+     */
-+    static bool isLogicalCamera(const CameraMetadata& staticInfo,
-+            std::vector<std::string>* physicalCameraIds);
-+
- private:
-     // All private members, unless otherwise noted, expect mInterfaceMutex to be locked before use
-     mutable std::mutex mInterfaceMutex;
-@@ -314,9 +319,9 @@ private:
-             static status_t setTorchMode(InterfaceT& interface, bool enabled);
-         };
-         std::vector<std::unique_ptr<DeviceInfo>> mDevices;
--        std::set<std::string> mUniqueCameraIds;
-+        std::unordered_set<std::string> mUniqueCameraIds;
-         int mUniqueDeviceCount;
--        std::set<std::string> mUniqueAPI1CompatibleCameraIds;
-+        std::vector<std::string> mUniqueAPI1CompatibleCameraIds;
- 
-         // HALv1-specific camera fields, including the actual device interface
-         struct DeviceInfo1 : public DeviceInfo {
-@@ -366,6 +371,8 @@ private:
- 
-         CameraProviderManager *mManager;
- 
-+        bool mInitialized = false;
-+
-         // Templated method to instantiate the right kind of DeviceInfo and call the
-         // right CameraProvider getCameraDeviceInterface_* method.
-         template<class DeviceInfoT>
-@@ -387,6 +394,8 @@ private:
- 
-         // Generate vendor tag id
-         static metadata_vendor_id_t generateVendorTagId(const std::string &name);
-+
-+        void removeDevice(std::string id);
-     };
- 
-     // Utility to find a DeviceInfo by ID; pointer is only valid while mInterfaceMutex is held
-@@ -412,6 +421,9 @@ private:
-     static const char* torchStatusToString(
-         const hardware::camera::common::V1_0::TorchModeStatus&);
- 
-+    status_t getCameraCharacteristicsLocked(const std::string &id,
-+            CameraMetadata* characteristics) const;
-+    void filterLogicalCameraIdsLocked(std::vector<std::string>& deviceIds) const;
- };
- 
- } // namespace android
--- 
-2.7.4
-
diff --git a/patches/frameworks/av/0003-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch b/patches/frameworks/av/0002-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch
similarity index 85%
rename from patches/frameworks/av/0003-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch
rename to patches/frameworks/av/0002-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch
index 321830f..8eb7c4e 100644
--- a/patches/frameworks/av/0003-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch
+++ b/patches/frameworks/av/0002-Fix-WiFi-Display-on-Huawei-devices-EMUI-8.0.patch
@@ -1,7 +1,7 @@
-From 7aa8d87cafe358617bfcb1999842c81dfbb6ae9d Mon Sep 17 00:00:00 2001
+From 9c84cfa568c5d5629e514deb2b48ce5f42275895 Mon Sep 17 00:00:00 2001
 From: Alexander Pohl <pohl199885@gmail.com>
 Date: Fri, 15 Jun 2018 19:58:07 +0200
-Subject: [PATCH 3/5] Fix WiFi-Display on Huawei devices (EMUI 8.0)
+Subject: [PATCH 2/4] Fix WiFi-Display on Huawei devices (EMUI 8.0)
 
 Huaweis media stack doesn't handle intra-refresh-mode, so skip the error instead.
 
@@ -11,7 +11,7 @@
  1 file changed, 2 insertions(+), 3 deletions(-)
 
 diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
-index 8949dae..fbee52b 100644
+index 8949daecd..fbee52b8e 100644
 --- a/media/libstagefright/ACodec.cpp
 +++ b/media/libstagefright/ACodec.cpp
 @@ -4279,9 +4279,8 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) {
@@ -27,5 +27,5 @@
      }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/av/0004-Kirin-Remove-lock-to-prevent-self-lock.patch b/patches/frameworks/av/0003-Kirin-Remove-lock-to-prevent-self-lock.patch
similarity index 82%
rename from patches/frameworks/av/0004-Kirin-Remove-lock-to-prevent-self-lock.patch
rename to patches/frameworks/av/0003-Kirin-Remove-lock-to-prevent-self-lock.patch
index 0986aee..79977cd 100644
--- a/patches/frameworks/av/0004-Kirin-Remove-lock-to-prevent-self-lock.patch
+++ b/patches/frameworks/av/0003-Kirin-Remove-lock-to-prevent-self-lock.patch
@@ -1,7 +1,7 @@
-From 05646ef62dfeb4286ce99ae50edd7c49510248ba Mon Sep 17 00:00:00 2001
+From 7338690836a48da7303d111a0f38f98996a9cdd5 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Sun, 19 Aug 2018 22:59:06 +0200
-Subject: [PATCH 4/5] Kirin:: Remove lock to prevent self-lock
+Subject: [PATCH 3/4] Kirin:: Remove lock to prevent self-lock
 
 With Huawei Camera HAL, we get the following call order:
 cameraserver CameraService::enumerateProviders (*)
@@ -17,10 +17,10 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
-index de0fac5..e04b359 100644
+index fb740053e..b62d22080 100644
 --- a/services/camera/libcameraservice/CameraService.cpp
 +++ b/services/camera/libcameraservice/CameraService.cpp
-@@ -218,7 +218,7 @@ void CameraService::onNewProviderRegistered() {
+@@ -233,7 +233,7 @@ void CameraService::onNewProviderRegistered() {
  }
  
  void CameraService::updateCameraNumAndIds() {
@@ -30,5 +30,5 @@
      mNormalDeviceIds =
              mCameraProviderManager->getAPI1CompatibleCameraDeviceIds();
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/av/0005-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch b/patches/frameworks/av/0004-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch
similarity index 77%
rename from patches/frameworks/av/0005-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch
rename to patches/frameworks/av/0004-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch
index 7606db7..36c2509 100644
--- a/patches/frameworks/av/0005-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch
+++ b/patches/frameworks/av/0004-We-might-not-have-a-mFlashlight-at-this-state-but-th.patch
@@ -1,7 +1,7 @@
-From 962f7af622371eb8c0a170764facf92d9e1ddd74 Mon Sep 17 00:00:00 2001
+From c195131280ea47a045dbc78a9f6a83eb880b733d Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Sun, 19 Aug 2018 23:05:26 +0200
-Subject: [PATCH 5/5] We might not have a mFlashlight at this state, but that's
+Subject: [PATCH 4/4] We might not have a mFlashlight at this state, but that's
  ok
 
 ---
@@ -9,10 +9,10 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
-index e04b359..178285d 100644
+index b62d22080..0f2c4cac7 100644
 --- a/services/camera/libcameraservice/CameraService.cpp
 +++ b/services/camera/libcameraservice/CameraService.cpp
-@@ -243,7 +243,7 @@ void CameraService::addStates(const String8 id) {
+@@ -258,7 +258,7 @@ void CameraService::addStates(const String8 id) {
                                                                  conflicting));
      }
  
@@ -22,5 +22,5 @@
          mTorchStatusMap.add(id, TorchModeStatus::AVAILABLE_OFF);
      }
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0001-Utils-Import-restart-systemui-api.patch b/patches/frameworks/base/0001-Utils-Import-restart-systemui-api.patch
new file mode 100644
index 0000000..91a6cd2
--- /dev/null
+++ b/patches/frameworks/base/0001-Utils-Import-restart-systemui-api.patch
@@ -0,0 +1,134 @@
+From 797c4020f25fb4a76dee82f5fc7008aada330d2f Mon Sep 17 00:00:00 2001
+From: SpiritCroc <dev@spiritcroc.de>
+Date: Sun, 11 Nov 2018 14:59:35 -0700
+Subject: [PATCH 01/26] Utils: Import restart systemui api
+
+Change-Id: Ief06016032e14fe15ec8348722546c54e0d379c7
+---
+ .../internal/util/omni/DeviceUtils.java       | 61 +++++++++++++++++++
+ core/res/res/values/bliss_strings.xml         |  4 ++
+ core/res/res/values/bliss_symbols.xml         |  4 ++
+ 3 files changed, 69 insertions(+)
+
+diff --git a/core/java/com/android/internal/util/omni/DeviceUtils.java b/core/java/com/android/internal/util/omni/DeviceUtils.java
+index 811b52d57cc..59db7500a1c 100644
+--- a/core/java/com/android/internal/util/omni/DeviceUtils.java
++++ b/core/java/com/android/internal/util/omni/DeviceUtils.java
+@@ -15,8 +15,12 @@
+ */
+ package com.android.internal.util.omni;
+ 
++import android.app.ActivityManager;
++import android.app.AlertDialog;
++import android.app.IActivityManager;
+ import android.bluetooth.BluetoothAdapter;
+ import android.content.Context;
++import android.content.DialogInterface;
+ import android.content.pm.ApplicationInfo;
+ import android.content.pm.PackageInfo;
+ import android.content.pm.PackageManager;
+@@ -29,6 +33,7 @@ import android.hardware.camera2.CameraManager;
+ import android.hardware.SensorManager;
+ import android.net.ConnectivityManager;
+ import android.nfc.NfcAdapter;
++import android.os.AsyncTask;
+ import android.os.RemoteException;
+ import android.os.SystemProperties;
+ import android.os.Vibrator;
+@@ -45,6 +50,7 @@ import com.android.internal.telephony.PhoneConstants;
+ import static android.hardware.Sensor.TYPE_LIGHT;
+ import static android.hardware.Sensor.TYPE_PROXIMITY;
+ 
++import com.android.internal.R;
+ import java.util.List;
+ import java.util.Locale;
+ 
+@@ -221,4 +227,59 @@ public class DeviceUtils {
+             e.printStackTrace();
+         }
+     }
++
++    public static void restartSystemUi(Context context) {
++        new RestartSystemUiTask(context).execute();
++    }
++
++     public static void showSystemUiRestartDialog(Context context) {
++        new AlertDialog.Builder(context)
++                .setTitle(R.string.systemui_restart_title)
++                .setMessage(R.string.systemui_restart_message)
++                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
++                    public void onClick(DialogInterface dialog, int id) {
++                        restartSystemUi(context);
++                    }
++                })
++                .setNegativeButton(R.string.cancel, null)
++                .show();
++    }
++
++     private static class RestartSystemUiTask extends AsyncTask<Void, Void, Void> {
++         private Context mContext;
++         public RestartSystemUiTask(Context context) {
++            super();
++            mContext = context;
++        }
++
++         @Override
++        protected Void doInBackground(Void... params) {
++            try {
++                ActivityManager am =
++                        (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
++                IActivityManager ams = ActivityManager.getService();
++                for (ActivityManager.RunningAppProcessInfo app: am.getRunningAppProcesses()) {
++                    if ("com.android.systemui".equals(app.processName)) {
++                        ams.killApplicationProcess(app.processName, app.uid);
++                        break;
++                    }
++                }
++                //Class ActivityManagerNative = Class.forName("android.app.ActivityManagerNative");
++                //Method getDefault = ActivityManagerNative.getDeclaredMethod("getDefault", null);
++                //Object amn = getDefault.invoke(null, null);
++                //Method killApplicationProcess = amn.getClass().getDeclaredMethod("killApplicationProcess", String.class, int.class);
++                //mContext.stopService(new Intent().setComponent(new ComponentName("com.android.systemui", "com.android.systemui.SystemUIService")));
++                //am.killBackgroundProcesses("com.android.systemui");
++                //for (ActivityManager.RunningAppProcessInfo app : am.getRunningAppProcesses()) {
++                //    if ("com.android.systemui".equals(app.processName)) {
++                //        killApplicationProcess.invoke(amn, app.processName, app.uid);
++                //        break;
++                //    }
++                //}
++            } catch (Exception e) {
++                e.printStackTrace();
++            }
++            return null;
++        }
++    }
+ }
+diff --git a/core/res/res/values/bliss_strings.xml b/core/res/res/values/bliss_strings.xml
+index 9ba4f1844ca..da16771ba18 100644
+--- a/core/res/res/values/bliss_strings.xml
++++ b/core/res/res/values/bliss_strings.xml
+@@ -54,4 +54,8 @@
+     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+     <string name="permdesc_fakePackageSignature">Allows the app to pretend to be a different app. Malicious applications might be able to use this to access private application data. Legitimate uses include an emulator pretending to be what it emulates. Grant this permission with caution only!</string>
+ 
++    <!-- SystemUI Restart -->
++    <string name="systemui_restart_title">SystemUI restart required</string>
++    <string name="systemui_restart_message">For all changes to take effect, a SystemUI restart is required. Restart SystemUI now?</string>
++
+ </resources>
+diff --git a/core/res/res/values/bliss_symbols.xml b/core/res/res/values/bliss_symbols.xml
+index 35d9555b2f9..f8e2bdb5bf6 100644
+--- a/core/res/res/values/bliss_symbols.xml
++++ b/core/res/res/values/bliss_symbols.xml
+@@ -145,4 +145,8 @@
+   <!-- Oreo's recents component activity -->
+   <java-symbol type="string" name="config_recentsComponentNameOreo" />
+ 
++  <!-- SystemUI Restart -->
++  <java-symbol type="string" name="systemui_restart_title" />
++  <java-symbol type="string" name="systemui_restart_message" />
++
+ </resources>
+-- 
+2.17.1
+
diff --git a/patches/frameworks/base/0001-Revert-Telephony-Stop-using-rssnr-it-falsly-shows-wr.patch b/patches/frameworks/base/0002-Revert-Telephony-Stop-using-rssnr-it-falsly-shows-wr.patch
similarity index 84%
rename from patches/frameworks/base/0001-Revert-Telephony-Stop-using-rssnr-it-falsly-shows-wr.patch
rename to patches/frameworks/base/0002-Revert-Telephony-Stop-using-rssnr-it-falsly-shows-wr.patch
index a2c13bb..b3b9044 100644
--- a/patches/frameworks/base/0001-Revert-Telephony-Stop-using-rssnr-it-falsly-shows-wr.patch
+++ b/patches/frameworks/base/0002-Revert-Telephony-Stop-using-rssnr-it-falsly-shows-wr.patch
@@ -1,7 +1,7 @@
-From 06588b0051026c442e024a832ea29b991ff6525c Mon Sep 17 00:00:00 2001
+From d5d060f229203c48962b0580946fe115775d3338 Mon Sep 17 00:00:00 2001
 From: Jackeagle <jackeagle102@gmail.com>
 Date: Thu, 18 Oct 2018 04:55:17 -0400
-Subject: [PATCH 01/26] Revert "Telephony: Stop using rssnr, it falsly shows
+Subject: [PATCH 02/26] Revert "Telephony: Stop using rssnr, it falsly shows
  wrong signal bars"
 
 This reverts commit b9ff83d0b1d5a81d55057ae2fa892e5d0f1083be.
@@ -10,7 +10,7 @@
  1 file changed, 3 deletions(-)
 
 diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
-index 55c0c77..4e56396 100644
+index 55c0c778972..4e5639683a7 100644
 --- a/telephony/java/android/telephony/SignalStrength.java
 +++ b/telephony/java/android/telephony/SignalStrength.java
 @@ -897,9 +897,6 @@ public class SignalStrength implements Parcelable {
@@ -24,5 +24,5 @@
          if (snrIconLevel != -1 && rsrpIconLevel != -1) {
              /*
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0002-Fix-backlight-control-on-Galaxy-S9.patch b/patches/frameworks/base/0003-Fix-backlight-control-on-Galaxy-S9.patch
similarity index 83%
rename from patches/frameworks/base/0002-Fix-backlight-control-on-Galaxy-S9.patch
rename to patches/frameworks/base/0003-Fix-backlight-control-on-Galaxy-S9.patch
index d994ca4..20ef93a 100644
--- a/patches/frameworks/base/0002-Fix-backlight-control-on-Galaxy-S9.patch
+++ b/patches/frameworks/base/0003-Fix-backlight-control-on-Galaxy-S9.patch
@@ -1,14 +1,14 @@
-From 8d2e50a9e6932d4c0a65269a3e8ad9743912686d Mon Sep 17 00:00:00 2001
+From 8fa619b8a4e063730776b3ac63d1be73a5b1ac46 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Sat, 24 Mar 2018 08:01:48 +0100
-Subject: [PATCH 02/26] Fix backlight control on Galaxy S9(+)
+Subject: [PATCH 03/26] Fix backlight control on Galaxy S9(+)
 
 ---
- services/core/java/com/android/server/lights/LightsService.java | 7 +++++++
+ .../core/java/com/android/server/lights/LightsService.java | 7 +++++++
  1 file changed, 7 insertions(+)
 
 diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
-index a94ed60..762b0ae 100644
+index a94ed608b9c..762b0ae4037 100644
 --- a/services/core/java/com/android/server/lights/LightsService.java
 +++ b/services/core/java/com/android/server/lights/LightsService.java
 @@ -21,6 +21,7 @@ import android.app.ActivityManager;
@@ -33,5 +33,5 @@
                  color = 0xff000000 | (color << 16) | (color << 8) | color;
                  setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0003-Revert-Revert-Remove-getIntWithSubId-in-TelephonyMan.patch b/patches/frameworks/base/0003-Revert-Revert-Remove-getIntWithSubId-in-TelephonyMan.patch
deleted file mode 100644
index 18c5098..0000000
--- a/patches/frameworks/base/0003-Revert-Revert-Remove-getIntWithSubId-in-TelephonyMan.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From 76ad65fa9d4689eed28b24b9ba55059389a6cf96 Mon Sep 17 00:00:00 2001
-From: jhenrique09 <jhenrique09.mcz@hotmail.com>
-Date: Sat, 11 Aug 2018 13:40:00 -0400
-Subject: [PATCH 03/26] Revert "Revert "Remove getIntWithSubId in
- TelephonyManager.""
-
-This reverts commit e788decb1b366a9df9683d86314ea4cf22a10d74.
----
- .../java/android/telephony/TelephonyManager.java   | 39 ----------------------
- 1 file changed, 39 deletions(-)
-
-diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
-index 3ecb6bb..b916a79 100644
---- a/telephony/java/android/telephony/TelephonyManager.java
-+++ b/telephony/java/android/telephony/TelephonyManager.java
-@@ -6633,45 +6633,6 @@ public class TelephonyManager {
-     }
- 
-     /**
--     * This function retrieves value for setting "name+subId", and if that is not found
--     * retrieves value for setting "name", and if that is not found throws
--     * SettingNotFoundException
--     *
--     * @hide
--     */
--    public static int getIntWithSubId(ContentResolver cr, String name, int subId)
--            throws SettingNotFoundException {
--        try {
--            return Settings.Global.getInt(cr, name + subId);
--        } catch (SettingNotFoundException e) {
--            try {
--                int val = Settings.Global.getInt(cr, name);
--                Settings.Global.putInt(cr, name + subId, val);
--
--                /* We are now moving from 'setting' to 'setting+subId', and using the value stored
--                 * for 'setting' as default. Reset the default (since it may have a user set
--                 * value). */
--                int default_val = val;
--                if (name.equals(Settings.Global.MOBILE_DATA)) {
--                    default_val = "true".equalsIgnoreCase(
--                            SystemProperties.get("ro.com.android.mobiledata", "true")) ? 1 : 0;
--                } else if (name.equals(Settings.Global.DATA_ROAMING)) {
--                    default_val = "true".equalsIgnoreCase(
--                            SystemProperties.get("ro.com.android.dataroaming", "false")) ? 1 : 0;
--                }
--
--                if (default_val != val) {
--                    Settings.Global.putInt(cr, name, default_val);
--                }
--
--                return val;
--            } catch (SettingNotFoundException exc) {
--                throw new SettingNotFoundException(name);
--            }
--        }
--    }
--
--    /**
-      * Returns the IMS Registration Status for a particular Subscription ID.
-      *
-      * @param subId Subscription ID
--- 
-2.7.4
-
diff --git a/patches/frameworks/base/0004-Relax-requirement-for-visible-flag-to-sdcards.patch b/patches/frameworks/base/0004-Relax-requirement-for-visible-flag-to-sdcards.patch
index cf63de5..ab6d087 100644
--- a/patches/frameworks/base/0004-Relax-requirement-for-visible-flag-to-sdcards.patch
+++ b/patches/frameworks/base/0004-Relax-requirement-for-visible-flag-to-sdcards.patch
@@ -1,4 +1,4 @@
-From bce6b073e39f1c12839debc4e1df55f992bf4409 Mon Sep 17 00:00:00 2001
+From a9b12570584788b9e4b1ee8a41cdc79f2cbf51e3 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Tue, 28 Nov 2017 18:28:04 +0100
 Subject: [PATCH 04/26] Relax requirement for visible flag to sdcards
@@ -9,11 +9,11 @@
 
 Change-Id: Ia616671c03562d1eadaff5531a5c708a62d7ad3a
 ---
- services/core/java/com/android/server/StorageManagerService.java | 3 ++-
+ .../core/java/com/android/server/StorageManagerService.java    | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
-index a35357f..14ca559 100644
+index a35357f2864..14ca559c306 100644
 --- a/services/core/java/com/android/server/StorageManagerService.java
 +++ b/services/core/java/com/android/server/StorageManagerService.java
 @@ -1178,7 +1178,8 @@ class StorageManagerService extends IStorageManager.Stub
@@ -27,5 +27,5 @@
              }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0005-Also-scan-system-overlay.patch b/patches/frameworks/base/0005-Also-scan-system-overlay.patch
index c499e5e..127d880 100644
--- a/patches/frameworks/base/0005-Also-scan-system-overlay.patch
+++ b/patches/frameworks/base/0005-Also-scan-system-overlay.patch
@@ -1,4 +1,4 @@
-From 11e5882f79432d04eda5dc7415a33ce051db14d5 Mon Sep 17 00:00:00 2001
+From fe2320fb75d4b04720641632c8009d0bcb4ee3c6 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Tue, 1 May 2018 17:47:36 +0200
 Subject: [PATCH 05/26] Also scan /system/overlay
@@ -10,7 +10,7 @@
  2 files changed, 7 insertions(+), 2 deletions(-)
 
 diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
-index fa9f445..1d3bf73 100644
+index fa9f44557d3..1d3bf73eebb 100644
 --- a/core/jni/android_util_AssetManager.cpp
 +++ b/core/jni/android_util_AssetManager.cpp
 @@ -149,7 +149,7 @@ static void NativeVerifySystemIdmaps(JNIEnv* /*env*/, jclass /*clazz*/) {
@@ -34,7 +34,7 @@
        if (argc > 5) {
          execv(AssetManager::IDMAP_BIN, (char* const*)argv);
 diff --git a/core/jni/fd_utils.cpp b/core/jni/fd_utils.cpp
-index c5904e0..6548215 100644
+index c5904e0e9e5..6548215772a 100644
 --- a/core/jni/fd_utils.cpp
 +++ b/core/jni/fd_utils.cpp
 @@ -93,7 +93,8 @@ bool FileDescriptorWhitelist::IsAllowed(const std::string& path) const {
@@ -48,5 +48,5 @@
        && path.find("/../") == std::string::npos) {
      return true;
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0006-Don-t-crash-if-there-is-IR-HAL-is-not-declared.patch b/patches/frameworks/base/0006-Don-t-crash-if-there-is-IR-HAL-is-not-declared.patch
index 9fb6edb..ca478ae 100644
--- a/patches/frameworks/base/0006-Don-t-crash-if-there-is-IR-HAL-is-not-declared.patch
+++ b/patches/frameworks/base/0006-Don-t-crash-if-there-is-IR-HAL-is-not-declared.patch
@@ -1,4 +1,4 @@
-From cb0dd6d660d6bfdf2127bbe7cc0239eca775eb75 Mon Sep 17 00:00:00 2001
+From 5d5a6a281c69f7eb8b78ddd7a4b7b120fe3d56df Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Thu, 17 May 2018 20:28:35 +0200
 Subject: [PATCH 06/26] Don't crash if there is IR HAL is not declared
@@ -8,7 +8,7 @@
  1 file changed, 2 deletions(-)
 
 diff --git a/services/core/java/com/android/server/ConsumerIrService.java b/services/core/java/com/android/server/ConsumerIrService.java
-index 2ed6c77..c574a03 100644
+index 2ed6c77baa0..c574a03c9a3 100644
 --- a/services/core/java/com/android/server/ConsumerIrService.java
 +++ b/services/core/java/com/android/server/ConsumerIrService.java
 @@ -50,8 +50,6 @@ public class ConsumerIrService extends IConsumerIrService.Stub {
@@ -21,5 +21,5 @@
      }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0007-Fix-62.patch b/patches/frameworks/base/0007-Fix-62.patch
index 1b68961..8794785 100644
--- a/patches/frameworks/base/0007-Fix-62.patch
+++ b/patches/frameworks/base/0007-Fix-62.patch
@@ -1,17 +1,17 @@
-From df2b78aa40160a50dc2bd50c8b4debfe1662179c Mon Sep 17 00:00:00 2001
+From 7b666d0761c2a1af8e206943d394468a1315b334 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Wed, 30 May 2018 14:05:30 +0200
 Subject: [PATCH 07/26] Fix(?) #62
 
 ---
- .../SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java     | 5 ++++-
+ .../src/com/android/keyguard/KeyguardUpdateMonitor.java      | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
-index 8a8a569..98df114 100644
+index e988e678ea7..8f99fa7ff3b 100644
 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
 +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
-@@ -898,7 +898,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
+@@ -895,7 +895,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
  
          @Override
          public void onAuthenticationError(int errMsgId, CharSequence errString) {
@@ -24,5 +24,5 @@
  
          @Override
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0008-S9-brightness-override-only-for-screen.patch b/patches/frameworks/base/0008-S9-brightness-override-only-for-screen.patch
index e31aafa..25368f1 100644
--- a/patches/frameworks/base/0008-S9-brightness-override-only-for-screen.patch
+++ b/patches/frameworks/base/0008-S9-brightness-override-only-for-screen.patch
@@ -1,14 +1,14 @@
-From 5aaac501604c1a512a74a1a683bd3b0d426d5e46 Mon Sep 17 00:00:00 2001
+From fcb2d6953ad707ff8eabdf0eb5b2525e23d6392c Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <pierre-hugues.husson@softathome.com>
 Date: Thu, 7 Jun 2018 13:36:51 +0200
 Subject: [PATCH 08/26] S9 brightness override only for screen
 
 ---
- .../core/java/com/android/server/lights/LightsService.java   | 12 +++++++-----
+ .../com/android/server/lights/LightsService.java     | 12 +++++++-----
  1 file changed, 7 insertions(+), 5 deletions(-)
 
 diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
-index 762b0ae..eb25943 100644
+index 762b0ae4037..eb25943fa6b 100644
 --- a/services/core/java/com/android/server/lights/LightsService.java
 +++ b/services/core/java/com/android/server/lights/LightsService.java
 @@ -53,11 +53,13 @@ public class LightsService extends SystemService {
@@ -31,5 +31,5 @@
                  int color = brightness & 0x000000ff;
                  color = 0xff000000 | (color << 16) | (color << 8) | color;
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0009-Fix-OP6-brightness.patch b/patches/frameworks/base/0009-Fix-OP6-brightness.patch
index 688c3a9..11f6c18 100644
--- a/patches/frameworks/base/0009-Fix-OP6-brightness.patch
+++ b/patches/frameworks/base/0009-Fix-OP6-brightness.patch
@@ -1,14 +1,14 @@
-From 2f75c91fb2bdd2647dd1954a82ae0051a0a00ac6 Mon Sep 17 00:00:00 2001
+From 6923e824c890e6ed6a65881341749a83b489c954 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <pierre-hugues.husson@softathome.com>
 Date: Thu, 7 Jun 2018 13:42:02 +0200
 Subject: [PATCH 09/26] Fix OP6 brightness
 
 ---
- .../core/java/com/android/server/lights/LightsService.java   | 12 ++++++++++++
+ .../com/android/server/lights/LightsService.java     | 12 ++++++++++++
  1 file changed, 12 insertions(+)
 
 diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
-index eb25943..a77af44 100644
+index eb25943fa6b..a77af445ba6 100644
 --- a/services/core/java/com/android/server/lights/LightsService.java
 +++ b/services/core/java/com/android/server/lights/LightsService.java
 @@ -59,6 +59,18 @@ public class LightsService extends SystemService {
@@ -31,5 +31,5 @@
  
                  int color = brightness & 0x000000ff;
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0010-Try-to-make-brightness-more-generic-using-property-s.patch b/patches/frameworks/base/0010-Try-to-make-brightness-more-generic-using-property-s.patch
index 88a774e..090287c 100644
--- a/patches/frameworks/base/0010-Try-to-make-brightness-more-generic-using-property-s.patch
+++ b/patches/frameworks/base/0010-Try-to-make-brightness-more-generic-using-property-s.patch
@@ -1,15 +1,15 @@
-From 2e537ac68e587286bee27ff78cd6154ed9923683 Mon Sep 17 00:00:00 2001
+From 82c87e64737aed3c80aa16566ac3546182d00ffc Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Sun, 10 Jun 2018 22:54:55 +0200
 Subject: [PATCH 10/26] Try to make brightness more generic using property set
  by rw-system
 
 ---
- services/core/java/com/android/server/lights/LightsService.java | 6 ++++--
+ .../core/java/com/android/server/lights/LightsService.java  | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
-index a77af44..4dc44de 100644
+index a77af445ba6..4dc44de37cd 100644
 --- a/services/core/java/com/android/server/lights/LightsService.java
 +++ b/services/core/java/com/android/server/lights/LightsService.java
 @@ -62,9 +62,11 @@ public class LightsService extends SystemService {
@@ -27,5 +27,5 @@
  
                      if(qcomExtendBrightness) {
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0011-property-matching-RROs-allow-to-prefix-the-value-wit.patch b/patches/frameworks/base/0011-property-matching-RROs-allow-to-prefix-the-value-wit.patch
index 653e8dd..557f85b 100644
--- a/patches/frameworks/base/0011-property-matching-RROs-allow-to-prefix-the-value-wit.patch
+++ b/patches/frameworks/base/0011-property-matching-RROs-allow-to-prefix-the-value-wit.patch
@@ -1,4 +1,4 @@
-From f7dd56eb01d249e15fbff250dc3939751770511c Mon Sep 17 00:00:00 2001
+From 92055b58d15be699f3652f6d9726de7da1188768 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Tue, 12 Jun 2018 22:55:32 +0200
 Subject: [PATCH 11/26] property-matching RROs: allow to prefix the value with
@@ -9,7 +9,7 @@
  1 file changed, 5 insertions(+)
 
 diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp
-index d69dd79..2be6d23 100644
+index d69dd79555a..2be6d23ac78 100644
 --- a/cmds/idmap/scan.cpp
 +++ b/cmds/idmap/scan.cpp
 @@ -1,5 +1,6 @@
@@ -31,5 +31,5 @@
      }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0012-Fix-typo-on-fnmatch-return-value-check.patch b/patches/frameworks/base/0012-Fix-typo-on-fnmatch-return-value-check.patch
index 867df17..971502d 100644
--- a/patches/frameworks/base/0012-Fix-typo-on-fnmatch-return-value-check.patch
+++ b/patches/frameworks/base/0012-Fix-typo-on-fnmatch-return-value-check.patch
@@ -1,4 +1,4 @@
-From c76d3ec31672441e234863a864edcb81b30ac5b9 Mon Sep 17 00:00:00 2001
+From 6434c54e04ece8b327af3f1d453b9d2845f12fe2 Mon Sep 17 00:00:00 2001
 From: Song Fuchang <song.fc@gmail.com>
 Date: Sun, 17 Jun 2018 22:39:37 +0800
 Subject: [PATCH 12/26] Fix typo on fnmatch return value check
@@ -8,7 +8,7 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp
-index 2be6d23..0acff23 100644
+index 2be6d23ac78..0acff23d031 100644
 --- a/cmds/idmap/scan.cpp
 +++ b/cmds/idmap/scan.cpp
 @@ -94,7 +94,7 @@ namespace {
@@ -21,5 +21,5 @@
  
          return (strcmp(propBuf, val) == 0);
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0013-Add-Qualcomm-starlte.patch b/patches/frameworks/base/0013-Add-Qualcomm-starlte.patch
index 194c040..74fd837 100644
--- a/patches/frameworks/base/0013-Add-Qualcomm-starlte.patch
+++ b/patches/frameworks/base/0013-Add-Qualcomm-starlte.patch
@@ -1,14 +1,14 @@
-From 672a57ba8016499f4c78b63ce4ec56ff4ae1162b Mon Sep 17 00:00:00 2001
+From c232a221826b04cacf0c9ba19d0f687b5adb61f4 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 25 Jun 2018 22:43:32 +0200
 Subject: [PATCH 13/26] Add Qualcomm starlte
 
 ---
- services/core/java/com/android/server/lights/LightsService.java | 4 +++-
+ .../core/java/com/android/server/lights/LightsService.java    | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
 
 diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
-index 4dc44de..2886f29 100644
+index 4dc44de37cd..2886f2900d9 100644
 --- a/services/core/java/com/android/server/lights/LightsService.java
 +++ b/services/core/java/com/android/server/lights/LightsService.java
 @@ -55,7 +55,9 @@ public class LightsService extends SystemService {
@@ -23,5 +23,5 @@
                          return;
                      }
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0014-remaining-of-HAL-onEnroll-is-actually-a-percent-of-p.patch b/patches/frameworks/base/0014-remaining-of-HAL-onEnroll-is-actually-a-percent-of-p.patch
index 006c736..b42ac73 100644
--- a/patches/frameworks/base/0014-remaining-of-HAL-onEnroll-is-actually-a-percent-of-p.patch
+++ b/patches/frameworks/base/0014-remaining-of-HAL-onEnroll-is-actually-a-percent-of-p.patch
@@ -1,15 +1,15 @@
-From 193e90216abdd2758da4c42935bf2bf792bffa46 Mon Sep 17 00:00:00 2001
+From 7f583a4e841bfa0525abb0a523fee67f500a7e2f Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 2 Jul 2018 23:36:39 +0200
 Subject: [PATCH 14/26] "remaining" of HAL onEnroll is actually a percent of
  progress
 
 ---
- .../java/com/android/server/fingerprint/FingerprintService.java     | 6 +++++-
+ .../com/android/server/fingerprint/FingerprintService.java  | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
 
 diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java
-index 06329e57..6f09433 100644
+index 06329e571b4..6f09433c002 100644
 --- a/services/core/java/com/android/server/fingerprint/FingerprintService.java
 +++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java
 @@ -1046,7 +1046,11 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
@@ -26,5 +26,5 @@
              });
          }
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0015-Show-APN-Settings-for-CDMA-carriers.patch b/patches/frameworks/base/0015-Show-APN-Settings-for-CDMA-carriers.patch
index 226f8f6..f656493 100644
--- a/patches/frameworks/base/0015-Show-APN-Settings-for-CDMA-carriers.patch
+++ b/patches/frameworks/base/0015-Show-APN-Settings-for-CDMA-carriers.patch
@@ -1,4 +1,4 @@
-From 450bb6695075a8307306d87c45fe4de06be9b544 Mon Sep 17 00:00:00 2001
+From 4929e9f4ecda2f7083e8f975526e0f42e8ddac9f Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 6 Aug 2018 12:49:00 +0200
 Subject: [PATCH 15/26] Show APN Settings for CDMA carriers
@@ -8,10 +8,10 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
-index f66164c..0cf93a1 100644
+index a8b39e3b06b..5b1e1fc6c74 100644
 --- a/telephony/java/android/telephony/CarrierConfigManager.java
 +++ b/telephony/java/android/telephony/CarrierConfigManager.java
-@@ -2019,7 +2019,7 @@ public class CarrierConfigManager {
+@@ -2084,7 +2084,7 @@ public class CarrierConfigManager {
          sDefaults.putBoolean(KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL, false);
          sDefaults.putBoolean(KEY_OPERATOR_SELECTION_EXPAND_BOOL, true);
          sDefaults.putBoolean(KEY_PREFER_2G_BOOL, true);
@@ -21,5 +21,5 @@
          sDefaults.putBoolean(KEY_SMS_REQUIRES_DESTINATION_NUMBER_CONVERSION_BOOL, false);
          sDefaults.putBoolean(KEY_SHOW_ONSCREEN_DIAL_BUTTON_BOOL, true);
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0016-Change-SignalStrentgh-to-change-behaviour-based-on-p.patch b/patches/frameworks/base/0016-Change-SignalStrentgh-to-change-behaviour-based-on-p.patch
index 2812eb2..846777e 100644
--- a/patches/frameworks/base/0016-Change-SignalStrentgh-to-change-behaviour-based-on-p.patch
+++ b/patches/frameworks/base/0016-Change-SignalStrentgh-to-change-behaviour-based-on-p.patch
@@ -1,4 +1,4 @@
-From 372ab41c59413ba81891195d72f6ebde33eb9b08 Mon Sep 17 00:00:00 2001
+From 5d298fdddbdf236dcd3908e8cfd2bd00c8a221a2 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 6 Aug 2018 20:01:44 +0200
 Subject: [PATCH 16/26] Change SignalStrentgh to change behaviour based on
@@ -6,11 +6,11 @@
 
 Change-Id: I940ed724047567ec5195ac93ea04574c3d92f70b
 ---
- .../java/android/telephony/SignalStrength.java     | 39 +++++++++++++++-------
+ .../android/telephony/SignalStrength.java     | 39 +++++++++++++------
  1 file changed, 27 insertions(+), 12 deletions(-)
 
 diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
-index 4e56396..ff906d3 100644
+index 4e5639683a7..ff906d330d4 100644
 --- a/telephony/java/android/telephony/SignalStrength.java
 +++ b/telephony/java/android/telephony/SignalStrength.java
 @@ -854,6 +854,7 @@ public class SignalStrength implements Parcelable {
@@ -74,5 +74,5 @@
  
      }
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0017-idmap-Don-t-silently-ignore-RROs-with-same-priority.patch b/patches/frameworks/base/0017-idmap-Don-t-silently-ignore-RROs-with-same-priority.patch
index 190c4c2..ffa27e6 100644
--- a/patches/frameworks/base/0017-idmap-Don-t-silently-ignore-RROs-with-same-priority.patch
+++ b/patches/frameworks/base/0017-idmap-Don-t-silently-ignore-RROs-with-same-priority.patch
@@ -1,4 +1,4 @@
-From 01ca7e2062fe3986d7a978c04b6ad7b63d8adb23 Mon Sep 17 00:00:00 2001
+From 918aacb06ef25d3c6ede826ef65916103b9c5584 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Sun, 19 Aug 2018 10:51:06 +0200
 Subject: [PATCH 17/26] idmap: Don't silently ignore RROs with same priority
@@ -9,7 +9,7 @@
  1 file changed, 2 insertions(+)
 
 diff --git a/cmds/idmap/scan.cpp b/cmds/idmap/scan.cpp
-index 0acff23..d1dde52 100644
+index 0acff23d031..d1dde52732f 100644
 --- a/cmds/idmap/scan.cpp
 +++ b/cmds/idmap/scan.cpp
 @@ -29,6 +29,8 @@ namespace {
@@ -22,5 +22,5 @@
          }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0018-Move-SysuiDarkThemeOverlay-to-system.patch b/patches/frameworks/base/0018-Move-SysuiDarkThemeOverlay-to-system.patch
index ec1ec55..104d6dd 100644
--- a/patches/frameworks/base/0018-Move-SysuiDarkThemeOverlay-to-system.patch
+++ b/patches/frameworks/base/0018-Move-SysuiDarkThemeOverlay-to-system.patch
@@ -1,4 +1,4 @@
-From 4dd5e23ac2e61f674e7693e88da13d16394b450a Mon Sep 17 00:00:00 2001
+From 1d441d72b476758932f06c9d742701af4756dedd Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Sun, 19 Aug 2018 10:57:21 +0200
 Subject: [PATCH 18/26] Move SysuiDarkThemeOverlay to /system
@@ -9,7 +9,7 @@
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/packages/overlays/SysuiDarkThemeOverlay/Android.mk b/packages/overlays/SysuiDarkThemeOverlay/Android.mk
-index 7b277bc..89cfcf8 100644
+index 7b277bcf035..89cfcf819c2 100644
 --- a/packages/overlays/SysuiDarkThemeOverlay/Android.mk
 +++ b/packages/overlays/SysuiDarkThemeOverlay/Android.mk
 @@ -11,4 +11,5 @@ LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
@@ -20,5 +20,5 @@
 +LOCAL_IS_RUNTIME_RESOURCE_OVERLAY := true
 +include $(BUILD_PACKAGE)
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0019-Reintroduce-button-backlight-and-respective-inactivi.patch b/patches/frameworks/base/0019-Reintroduce-button-backlight-and-respective-inactivi.patch
index f5e4c6f..076a85d 100644
--- a/patches/frameworks/base/0019-Reintroduce-button-backlight-and-respective-inactivi.patch
+++ b/patches/frameworks/base/0019-Reintroduce-button-backlight-and-respective-inactivi.patch
@@ -1,4 +1,4 @@
-From 4b97606860972babc31af062db1a1b8345942f28 Mon Sep 17 00:00:00 2001
+From 2beeca83b6ef8837355d84c5939ee543d6d2701f Mon Sep 17 00:00:00 2001
 From: Ricardo Cerqueira <cyanogenmod@cerqueira.org>
 Date: Fri, 23 Nov 2012 14:23:16 +0000
 Subject: [PATCH 19/26] Reintroduce button-backlight (and respective inactivity
@@ -14,12 +14,12 @@
 
 Change-Id: I6094c446e0b8c23f57d30652a3cbd35dee5e821a
 ---
- .../com/android/server/display/DisplayPowerController.java   | 11 +++++++++++
- .../java/com/android/server/power/PowerManagerService.java   | 12 ++++++++++++
+ .../server/display/DisplayPowerController.java       | 11 +++++++++++
+ .../android/server/power/PowerManagerService.java    | 12 ++++++++++++
  2 files changed, 23 insertions(+)
 
 diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
-index db3368a..1f96902 100644
+index a09c426d7fa..4a727dc94a3 100644
 --- a/services/core/java/com/android/server/display/DisplayPowerController.java
 +++ b/services/core/java/com/android/server/display/DisplayPowerController.java
 @@ -21,6 +21,7 @@ import com.android.internal.app.IBatteryStats;
@@ -62,7 +62,7 @@
  
          // Always use the VR brightness when in the VR state.
 diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
-index d39401d..b325810 100644
+index d39401ddecd..b32581046f5 100644
 --- a/services/core/java/com/android/server/power/PowerManagerService.java
 +++ b/services/core/java/com/android/server/power/PowerManagerService.java
 @@ -230,6 +230,9 @@ public final class PowerManagerService extends SystemService
@@ -113,5 +113,5 @@
                      } else {
                          nextTimeout = mLastUserActivityTime + screenOffTimeout;
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0020-power-Disable-keyboard-button-lights-while-dozing-dr.patch b/patches/frameworks/base/0020-power-Disable-keyboard-button-lights-while-dozing-dr.patch
index 07f6129..4996927 100644
--- a/patches/frameworks/base/0020-power-Disable-keyboard-button-lights-while-dozing-dr.patch
+++ b/patches/frameworks/base/0020-power-Disable-keyboard-button-lights-while-dozing-dr.patch
@@ -1,4 +1,4 @@
-From 5036b3d244cb7b784688f6fcf3d9cec74b796ac0 Mon Sep 17 00:00:00 2001
+From b56a05837a3f080ffad773d7b4f8ad89fe69a697 Mon Sep 17 00:00:00 2001
 From: Steve Kondik <steve@cyngn.com>
 Date: Sat, 3 Jan 2015 05:13:26 -0800
 Subject: [PATCH 20/26] power: Disable keyboard/button lights while
@@ -10,11 +10,11 @@
 
 Change-Id: I7f1fc35a1573717d1ea101a07c4171d6f66d1553
 ---
- services/core/java/com/android/server/power/PowerManagerService.java | 2 +-
+ .../core/java/com/android/server/power/PowerManagerService.java | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
-index b325810..1ac93c7 100644
+index b32581046f5..1ac93c733f1 100644
 --- a/services/core/java/com/android/server/power/PowerManagerService.java
 +++ b/services/core/java/com/android/server/power/PowerManagerService.java
 @@ -2006,7 +2006,7 @@ public final class PowerManagerService extends SystemService
@@ -27,5 +27,5 @@
                              + screenOffTimeout - screenDimDuration;
                      if (now < nextTimeout) {
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0021-It-is-okay-not-to-have-wifi-in-SystemUI-on-FDE-lock.patch b/patches/frameworks/base/0021-It-is-okay-not-to-have-wifi-in-SystemUI-on-FDE-lock.patch
index 40703d6..cd4ba84 100644
--- a/patches/frameworks/base/0021-It-is-okay-not-to-have-wifi-in-SystemUI-on-FDE-lock.patch
+++ b/patches/frameworks/base/0021-It-is-okay-not-to-have-wifi-in-SystemUI-on-FDE-lock.patch
@@ -1,16 +1,16 @@
-From aabb69b5de04daa55c6576dea758a0fa838dea25 Mon Sep 17 00:00:00 2001
+From 160cb121fe386b18361771dc6886fee42c6a4552 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 20 Aug 2018 22:27:02 +0200
 Subject: [PATCH 21/26] It is okay not to have wifi in SystemUI (on FDE lock)
 
 ---
- .../SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java     | 2 +-
- .../com/android/systemui/statusbar/policy/HotspotControllerImpl.java  | 1 +
- .../com/android/systemui/statusbar/policy/WifiSignalController.java   | 4 +++-
+ .../src/com/android/settingslib/wifi/WifiTracker.java         | 2 +-
+ .../systemui/statusbar/policy/HotspotControllerImpl.java      | 1 +
+ .../systemui/statusbar/policy/WifiSignalController.java       | 4 +++-
  3 files changed, 5 insertions(+), 2 deletions(-)
 
 diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
-index d8f0886..76cd70d 100644
+index d8f0886730d..76cd70d5c84 100644
 --- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
 +++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
 @@ -207,7 +207,7 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro
@@ -23,7 +23,7 @@
          mFilter = filter;
  
 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
-index d6d0673..07db5f8 100644
+index 3c16329e6f1..050a9c5257e 100644
 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
 +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java
 @@ -113,6 +113,7 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof
@@ -35,7 +35,7 @@
              mWifiManager.registerSoftApCallback(
                      this,
 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
-index e5e576d..78b3050 100644
+index e5e576d6b80..78b30500da7 100644
 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
 +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
 @@ -59,7 +59,9 @@ public class WifiSignalController extends
@@ -50,5 +50,5 @@
              mWifiChannel.connect(context, handler, wifiMessenger);
          }
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0022-Don-t-wake-IR-HAL-to-the-infinity-and-beyond.patch b/patches/frameworks/base/0022-Don-t-wake-IR-HAL-to-the-infinity-and-beyond.patch
index b42fdf3..dbf6464 100644
--- a/patches/frameworks/base/0022-Don-t-wake-IR-HAL-to-the-infinity-and-beyond.patch
+++ b/patches/frameworks/base/0022-Don-t-wake-IR-HAL-to-the-infinity-and-beyond.patch
@@ -1,4 +1,4 @@
-From 52b034278a9809942e93a1d630b38d2050b74615 Mon Sep 17 00:00:00 2001
+From c31d457bbc90e1c0dc0a5e21f0591af959b4a92b Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Tue, 21 Aug 2018 22:24:02 +0200
 Subject: [PATCH 22/26] Don't wake IR HAL to the infinity and beyond
@@ -9,7 +9,7 @@
  2 files changed, 1 insertion(+), 6 deletions(-)
 
 diff --git a/services/core/java/com/android/server/ConsumerIrService.java b/services/core/java/com/android/server/ConsumerIrService.java
-index c574a03..82ec033 100644
+index c574a03c9a3..82ec033bc30 100644
 --- a/services/core/java/com/android/server/ConsumerIrService.java
 +++ b/services/core/java/com/android/server/ConsumerIrService.java
 @@ -46,11 +46,6 @@ public class ConsumerIrService extends IConsumerIrService.Stub {
@@ -25,7 +25,7 @@
  
      @Override
 diff --git a/services/core/jni/com_android_server_ConsumerIrService.cpp b/services/core/jni/com_android_server_ConsumerIrService.cpp
-index 2ca348b..148fba9 100644
+index 2ca348b3ae4..148fba9a688 100644
 --- a/services/core/jni/com_android_server_ConsumerIrService.cpp
 +++ b/services/core/jni/com_android_server_ConsumerIrService.cpp
 @@ -36,7 +36,7 @@ static sp<IConsumerIr> mHal;
@@ -38,5 +38,5 @@
  }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0023-Switch-samsung-light-fingerprint-match-to-regexp-to-.patch b/patches/frameworks/base/0023-Switch-samsung-light-fingerprint-match-to-regexp-to-.patch
index 09269ae..2a77571 100644
--- a/patches/frameworks/base/0023-Switch-samsung-light-fingerprint-match-to-regexp-to-.patch
+++ b/patches/frameworks/base/0023-Switch-samsung-light-fingerprint-match-to-regexp-to-.patch
@@ -1,15 +1,15 @@
-From 53efb21888f88be64b11ee70fef324dc8413353e Mon Sep 17 00:00:00 2001
+From 2807a9946b7a22c46cd98f10f64a6bc55101b860 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Thu, 23 Aug 2018 23:39:16 +0200
 Subject: [PATCH 23/26] Switch samsung light fingerprint match to regexp, to
  include Note9
 
 ---
- services/core/java/com/android/server/lights/LightsService.java | 4 +---
+ .../core/java/com/android/server/lights/LightsService.java    | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
 
 diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
-index 2886f29..2ad3877 100644
+index 2886f2900d9..2ad38774b9d 100644
 --- a/services/core/java/com/android/server/lights/LightsService.java
 +++ b/services/core/java/com/android/server/lights/LightsService.java
 @@ -55,9 +55,7 @@ public class LightsService extends SystemService {
@@ -24,5 +24,5 @@
                          return;
                      }
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0024-Add-a-property-toggle-to-enable-high-brightness-rang.patch b/patches/frameworks/base/0024-Add-a-property-toggle-to-enable-high-brightness-rang.patch
index f81e076..1aa969b 100644
--- a/patches/frameworks/base/0024-Add-a-property-toggle-to-enable-high-brightness-rang.patch
+++ b/patches/frameworks/base/0024-Add-a-property-toggle-to-enable-high-brightness-rang.patch
@@ -1,15 +1,15 @@
-From b9e8f8e4bb881dbbe1916512fa9ddbf52e603572 Mon Sep 17 00:00:00 2001
+From 54e3c7f10257e7fb9419429e6e3bebfccde3aeba Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 27 Aug 2018 00:47:13 +0200
 Subject: [PATCH 24/26] Add a property toggle to enable high brightness range
  on samsung device
 
 ---
- services/core/java/com/android/server/lights/LightsService.java | 6 +++++-
+ .../core/java/com/android/server/lights/LightsService.java  | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
 
 diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
-index 2ad3877..89008ea 100644
+index 2ad38774b9d..89008ea3134 100644
 --- a/services/core/java/com/android/server/lights/LightsService.java
 +++ b/services/core/java/com/android/server/lights/LightsService.java
 @@ -56,7 +56,11 @@ public class LightsService extends SystemService {
@@ -26,5 +26,5 @@
                      }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0025-Add-japanese-S9.patch b/patches/frameworks/base/0025-Add-japanese-S9.patch
index f7bc6c8..f501cb2 100644
--- a/patches/frameworks/base/0025-Add-japanese-S9.patch
+++ b/patches/frameworks/base/0025-Add-japanese-S9.patch
@@ -1,14 +1,14 @@
-From b700f3655ef093f91cd842dc8346a1cd5d836bfb Mon Sep 17 00:00:00 2001
+From be5482c01553a3dfc8e2b2e176c9d7f8069d5f53 Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Tue, 28 Aug 2018 20:39:26 +0200
 Subject: [PATCH 25/26] Add japanese S9
 
 ---
- services/core/java/com/android/server/lights/LightsService.java | 3 ++-
+ .../core/java/com/android/server/lights/LightsService.java     | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
-index 89008ea..47c1d92 100644
+index 89008ea3134..47c1d9297fe 100644
 --- a/services/core/java/com/android/server/lights/LightsService.java
 +++ b/services/core/java/com/android/server/lights/LightsService.java
 @@ -55,7 +55,8 @@ public class LightsService extends SystemService {
@@ -22,5 +22,5 @@
                          if(SystemProperties.getBoolean("persist.sys.samsung.full_brightness", false)) {
                              newBrightness = (int) (brightness * 40960.0 / 255.0);
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/frameworks/base/0026-Re-order-services-so-that-it-works-even-without-qtag.patch b/patches/frameworks/base/0026-Re-order-services-so-that-it-works-even-without-qtag.patch
new file mode 100644
index 0000000..bab659b
--- /dev/null
+++ b/patches/frameworks/base/0026-Re-order-services-so-that-it-works-even-without-qtag.patch
@@ -0,0 +1,36 @@
+From 377d3dd22093bbf4f324777af4865b46168496dd Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Thu, 8 Nov 2018 23:04:03 +0100
+Subject: [PATCH 26/26] Re-order services so that it works even without qtaguid
+
+---
+ .../com/android/server/net/NetworkPolicyManagerService.java | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+index db33bd8f08d..c612b2ab211 100644
+--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
++++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+@@ -710,6 +710,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
+         Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "systemReady");
+         final int oldPriority = Process.getThreadPriority(Process.myTid());
+         try {
++            mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
++            mNetworkStats = LocalServices.getService(NetworkStatsManagerInternal.class);
++
+             // Boost thread's priority during system server init
+             Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
+             if (!isBandwidthControlEnabled()) {
+@@ -717,9 +720,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
+                 return;
+             }
+ 
+-            mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
+-            mNetworkStats = LocalServices.getService(NetworkStatsManagerInternal.class);
+-
+             synchronized (mUidRulesFirstLock) {
+                 synchronized (mNetworkPoliciesSecondLock) {
+                     updatePowerSaveWhitelistUL();
+-- 
+2.17.1
+
diff --git a/patches/frameworks/base/0026-Revert-Revert-CameraServiceProxy-Add-client-API-leve.patch b/patches/frameworks/base/0026-Revert-Revert-CameraServiceProxy-Add-client-API-leve.patch
deleted file mode 100644
index 1a22278..0000000
--- a/patches/frameworks/base/0026-Revert-Revert-CameraServiceProxy-Add-client-API-leve.patch
+++ /dev/null
@@ -1,100 +0,0 @@
-From 291679ee3ce0959101b2b905208e0275d3d463a9 Mon Sep 17 00:00:00 2001
-From: Jackeagle <jackeagle102@gmail.com>
-Date: Sat, 20 Oct 2018 12:13:12 -0400
-Subject: [PATCH 26/26] Revert "Revert "CameraServiceProxy: Add client API
- level to log metrics""
-
-This reverts commit 7c97b7bb8b1b7f87974fcd13c1ae267288ca3e79.
----
- proto/src/metrics_constants.proto                        |  5 +++++
- .../com/android/server/camera/CameraServiceProxy.java    | 16 ++++++++++------
- 2 files changed, 15 insertions(+), 6 deletions(-)
-
-diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
-index 62f9377..e568b12 100644
---- a/proto/src/metrics_constants.proto
-+++ b/proto/src/metrics_constants.proto
-@@ -5447,6 +5447,11 @@ message MetricsEvent {
-     // OS: P
-     PACKAGE_OPTIMIZATION_COMPILATION_REASON = 1321;
- 
-+    // FIELD: The camera API level used.
-+    // CATEGORY: CAMERA
-+    // OS: P
-+    FIELD_CAMERA_API_LEVEL = 1322;
-+
-     // OPEN: Settings > Battery > Battery tip > Battery tip Dialog
-     // CATEGORY: SETTINGS
-     // OS: P
-diff --git a/services/core/java/com/android/server/camera/CameraServiceProxy.java b/services/core/java/com/android/server/camera/CameraServiceProxy.java
-index 45d2375..0ee55ed 100644
---- a/services/core/java/com/android/server/camera/CameraServiceProxy.java
-+++ b/services/core/java/com/android/server/camera/CameraServiceProxy.java
-@@ -103,13 +103,15 @@ public class CameraServiceProxy extends SystemService
-     private static class CameraUsageEvent {
-         public final int mCameraFacing;
-         public final String mClientName;
-+        public final int mAPILevel;
- 
-         private boolean mCompleted;
-         private long mDurationOrStartTimeMs;  // Either start time, or duration once completed
- 
--        public CameraUsageEvent(int facing, String clientName) {
-+        public CameraUsageEvent(int facing, String clientName, int apiLevel) {
-             mCameraFacing = facing;
-             mClientName = clientName;
-+            mAPILevel = apiLevel;
-             mDurationOrStartTimeMs = SystemClock.elapsedRealtime();
-             mCompleted = false;
-         }
-@@ -173,7 +175,7 @@ public class CameraServiceProxy extends SystemService
- 
-         @Override
-         public void notifyCameraState(String cameraId, int newCameraState, int facing,
--                String clientName) {
-+                String clientName, int apiLevel) {
-             if (Binder.getCallingUid() != Process.CAMERASERVER_UID) {
-                 Slog.e(TAG, "Calling UID: " + Binder.getCallingUid() + " doesn't match expected " +
-                         " camera service UID!");
-@@ -182,9 +184,9 @@ public class CameraServiceProxy extends SystemService
-             String state = cameraStateToString(newCameraState);
-             String facingStr = cameraFacingToString(facing);
-             if (DEBUG) Slog.v(TAG, "Camera " + cameraId + " facing " + facingStr + " state now " +
--                    state + " for client " + clientName);
-+                    state + " for client " + clientName + " API Level " + apiLevel);
- 
--            updateActivityCount(cameraId, newCameraState, facing, clientName);
-+            updateActivityCount(cameraId, newCameraState, facing, clientName, apiLevel);
-         }
-     };
- 
-@@ -303,6 +305,7 @@ public class CameraServiceProxy extends SystemService
-                         .setType(MetricsEvent.TYPE_ACTION)
-                         .setSubtype(subtype)
-                         .setLatency(e.getDuration())
-+                        .addTaggedData(MetricsEvent.FIELD_CAMERA_API_LEVEL, e.mAPILevel)
-                         .setPackageName(e.mClientName);
-                 mLogger.write(l);
-             }
-@@ -383,7 +386,8 @@ public class CameraServiceProxy extends SystemService
-         return true;
-     }
- 
--    private void updateActivityCount(String cameraId, int newCameraState, int facing, String clientName) {
-+    private void updateActivityCount(String cameraId, int newCameraState, int facing,
-+            String clientName, int apiLevel) {
-         synchronized(mLock) {
-             // Update active camera list and notify NFC if necessary
-             boolean wasEmpty = mActiveCameraUsage.isEmpty();
-@@ -391,7 +395,7 @@ public class CameraServiceProxy extends SystemService
-                 case ICameraServiceProxy.CAMERA_STATE_OPEN:
-                     break;
-                 case ICameraServiceProxy.CAMERA_STATE_ACTIVE:
--                    CameraUsageEvent newEvent = new CameraUsageEvent(facing, clientName);
-+                    CameraUsageEvent newEvent = new CameraUsageEvent(facing, clientName, apiLevel);
-                     CameraUsageEvent oldEvent = mActiveCameraUsage.put(cameraId, newEvent);
-                     if (oldEvent != null) {
-                         Slog.w(TAG, "Camera " + cameraId + " was already marked as active");
--- 
-2.7.4
-
diff --git a/patches/system/vold/0001-Allow-deletion-of-symlink.patch b/patches/system/vold/0001-Allow-deletion-of-symlink.patch
deleted file mode 100644
index c7c5b99..0000000
--- a/patches/system/vold/0001-Allow-deletion-of-symlink.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 30efdaa4669e5dcf632457cbdbc06d1943b19700 Mon Sep 17 00:00:00 2001
-From: Pierre-Hugues Husson <phh@phh.me>
-Date: Sat, 17 Feb 2018 19:39:38 +0100
-Subject: [PATCH 1/5] Allow deletion of symlink
-
-Change-Id: I9731895f88729072297f753088583aabbe6990f4
----
- Ext4Crypt.cpp | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp
-index 67b7e90..99a63b4 100644
---- a/Ext4Crypt.cpp
-+++ b/Ext4Crypt.cpp
-@@ -221,6 +221,7 @@ static bool prepare_dir(const std::string& dir, mode_t mode, uid_t uid, gid_t gi
- static bool destroy_dir(const std::string& dir) {
-     LOG(DEBUG) << "Destroying: " << dir;
-     if (rmdir(dir.c_str()) != 0 && errno != ENOENT) {
-+        if(unlink(dir.c_str()) == 0) return true;
-         PLOG(ERROR) << "Failed to destroy " << dir;
-         return false;
-     }
--- 
-2.7.4
-
diff --git a/patches/system/vold/0003-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch b/patches/system/vold/0001-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch
similarity index 85%
rename from patches/system/vold/0003-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch
rename to patches/system/vold/0001-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch
index 4bb1f92..289c53f 100644
--- a/patches/system/vold/0003-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch
+++ b/patches/system/vold/0001-Create-vendor_de.-This-is-done-by-init.rc-on-system-.patch
@@ -1,7 +1,7 @@
-From e3d4f144c3322ef7910c4f61dc8cbfc1f17c9455 Mon Sep 17 00:00:00 2001
+From 40ca9a2fc137e0c185e3aaedeababb65f1d6cd4e Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Tue, 14 Aug 2018 20:54:08 +0200
-Subject: [PATCH 3/5] Create vendor_de. This is done by /init.rc on
+Subject: [PATCH 1/4] Create vendor_de. This is done by /init.rc on
  system-as-root device
 
 ---
@@ -22,5 +22,5 @@
              if (!prepare_dir(system_legacy_path, 0700, AID_SYSTEM, AID_SYSTEM)) return false;
  #if MANAGE_MISC_DIRS
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/system/vold/0002-Don-t-set-reserved_disk-group-it-panics-old-inits.patch b/patches/system/vold/0002-Don-t-set-reserved_disk-group-it-panics-old-inits.patch
deleted file mode 100644
index 150354d..0000000
--- a/patches/system/vold/0002-Don-t-set-reserved_disk-group-it-panics-old-inits.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-From 90dfcf4b79f01087997d658d87dbf2ff332b7012 Mon Sep 17 00:00:00 2001
-From: Pierre-Hugues Husson <phh@phh.me>
-Date: Tue, 14 Aug 2018 20:53:12 +0200
-Subject: [PATCH 2/5] Don't set reserved_disk group, it panics old inits
-
----
- vold.rc | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/vold.rc b/vold.rc
-index 7d14453..c27aeda 100644
---- a/vold.rc
-+++ b/vold.rc
-@@ -5,4 +5,3 @@ service vold /system/bin/vold \
-     ioprio be 2
-     writepid /dev/cpuset/foreground/tasks
-     shutdown critical
--    group reserved_disk
--- 
-2.7.4
-
diff --git a/patches/system/vold/0004-Support-Samsung-s-implementation-of-exfat-called-sdf.patch b/patches/system/vold/0002-Support-Samsung-s-implementation-of-exfat-called-sdf.patch
similarity index 91%
rename from patches/system/vold/0004-Support-Samsung-s-implementation-of-exfat-called-sdf.patch
rename to patches/system/vold/0002-Support-Samsung-s-implementation-of-exfat-called-sdf.patch
index c353771..d129fae 100644
--- a/patches/system/vold/0004-Support-Samsung-s-implementation-of-exfat-called-sdf.patch
+++ b/patches/system/vold/0002-Support-Samsung-s-implementation-of-exfat-called-sdf.patch
@@ -1,7 +1,7 @@
-From baa16308959d861658a63836e43b57479d02345d Mon Sep 17 00:00:00 2001
+From 642887ce1ff0403fce542af0aea8c3c52ba07fdb Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 20 Aug 2018 22:37:54 +0200
-Subject: [PATCH 4/5] Support Samsung's implementation of exfat, called sdfat
+Subject: [PATCH 2/4] Support Samsung's implementation of exfat, called sdfat
 
 ---
  fs/Exfat.cpp | 9 ++++++---
@@ -40,5 +40,5 @@
      }
  
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/system/vold/0005-Also-create-vendor_ce-same-reason-as-vendor_de.patch b/patches/system/vold/0003-Also-create-vendor_ce-same-reason-as-vendor_de.patch
similarity index 81%
rename from patches/system/vold/0005-Also-create-vendor_ce-same-reason-as-vendor_de.patch
rename to patches/system/vold/0003-Also-create-vendor_ce-same-reason-as-vendor_de.patch
index cf92197..ce56b36 100644
--- a/patches/system/vold/0005-Also-create-vendor_ce-same-reason-as-vendor_de.patch
+++ b/patches/system/vold/0003-Also-create-vendor_ce-same-reason-as-vendor_de.patch
@@ -1,8 +1,9 @@
-From 18b7fc6d0fb54a16e6d1d095b000dc8840511eff Mon Sep 17 00:00:00 2001
+From d2d67f9e989a6b72df42b387ac573f55bd236d3c Mon Sep 17 00:00:00 2001
 From: Pierre-Hugues Husson <phh@phh.me>
 Date: Mon, 20 Aug 2018 22:38:08 +0200
-Subject: [PATCH 5/5] Also create vendor_ce (same reason as vendor_de)
+Subject: [PATCH 3/4] Also create vendor_ce (same reason as vendor_de)
 
+Change-Id: Ifba45dd063cc2f4947dcb5c47be30e34b32bd758
 ---
  Ext4Crypt.cpp | 2 ++
  1 file changed, 2 insertions(+)
@@ -21,5 +22,5 @@
              if (!prepare_dir(system_ce_path, 0770, AID_SYSTEM, AID_SYSTEM)) return false;
              if (!prepare_dir(misc_ce_path, 01771, AID_SYSTEM, AID_MISC)) return false;
 -- 
-2.7.4
+2.17.1
 
diff --git a/patches/system/vold/0004-Don-t-set-reserved_disk-group-it-panics-old-inits.patch b/patches/system/vold/0004-Don-t-set-reserved_disk-group-it-panics-old-inits.patch
new file mode 100644
index 0000000..4c5470b
--- /dev/null
+++ b/patches/system/vold/0004-Don-t-set-reserved_disk-group-it-panics-old-inits.patch
@@ -0,0 +1,23 @@
+From 5a60b2a5fee25755109ab9e060bf5a2aff905ca8 Mon Sep 17 00:00:00 2001
+From: Pierre-Hugues Husson <phh@phh.me>
+Date: Tue, 14 Aug 2018 20:53:12 +0200
+Subject: [PATCH 4/4] Don't set reserved_disk group, it panics old inits
+
+Signed-off-by: Jackeagle <jackeagle102@gmail.com>
+Change-Id: Ib9318bb0af7a2f0b5dbc75b505d1d716bb4e9cc7
+---
+ vold.rc | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/vold.rc b/vold.rc
+index 93d8786..c27aeda 100644
+--- a/vold.rc
++++ b/vold.rc
+@@ -5,4 +5,3 @@ service vold /system/bin/vold \
+     ioprio be 2
+     writepid /dev/cpuset/foreground/tasks
+     shutdown critical
+-    group root reserved_disk
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0001-Revert-verity_tool-Implement-status-getter.patch b/patches/vendor/bliss/0001-Revert-verity_tool-Implement-status-getter.patch
new file mode 100644
index 0000000..2cda6de
--- /dev/null
+++ b/patches/vendor/bliss/0001-Revert-verity_tool-Implement-status-getter.patch
@@ -0,0 +1,199 @@
+From 6d89034411393db371fb376931dc6c1b6b114c40 Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:24:08 -0700
+Subject: [PATCH 1/9] Revert "verity_tool: Implement status getter"
+
+This reverts commit 385296fd334a854915d41ef556ce7bb981f66bb3.
+
+Change-Id: I8748c6c4ee0158124ad9c4469521be7d1cc02fc6
+---
+ config/BoardConfigBliss.mk        |  8 ++--
+ verity_tool/include/verity_tool.h | 15 --------
+ verity_tool/main.cpp              | 27 +------------
+ verity_tool/verity_tool.cpp       | 63 -------------------------------
+ 4 files changed, 6 insertions(+), 107 deletions(-)
+
+diff --git a/config/BoardConfigBliss.mk b/config/BoardConfigBliss.mk
+index 032e061..7ccae1d 100644
+--- a/config/BoardConfigBliss.mk
++++ b/config/BoardConfigBliss.mk
+@@ -9,8 +9,8 @@ ifeq ($(TARGET_HW_DISK_ENCRYPTION),true)
+ endif
+ 
+ include vendor/bliss/config/BoardConfigKernel.mk
+-include vendor/bliss/config/BoardConfigSoong.mk
++include vendor/lineage/config/BoardConfigSoong.mk
+ 
+-ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
+-include vendor/bliss/config/BoardConfigQcom.mk
+-endif
++ifeq ($(BOARD_USES_QCOM_HARDWARE),true) 
++include vendor/bliss/config/BoardConfigQcom.mk 
++endif 
+diff --git a/verity_tool/include/verity_tool.h b/verity_tool/include/verity_tool.h
+index b81eda1..25a6a7c 100644
+--- a/verity_tool/include/verity_tool.h
++++ b/verity_tool/include/verity_tool.h
+@@ -18,14 +18,6 @@
+ 
+ #include <string>
+ 
+-typedef enum {
+-    VERITY_STATE_UNKNOWN,
+-    VERITY_STATE_NO_DEVICE,
+-    VERITY_STATE_DISABLED,
+-    VERITY_STATE_ENABLED,
+-    VERITY_STATE_MAX = VERITY_STATE_ENABLED
+-} verity_state_t;
+-
+ /*
+  * Return codes:
+  *
+@@ -35,13 +27,6 @@ typedef enum {
+ bool set_block_device_verity_enabled(const std::string& block_device,
+                                      bool enable);
+ 
+-/*
+- * Return codes:
+- *
+- *    verity state (unknown, disabled, enabled)
+- */
+-verity_state_t get_verity_state();
+-
+ /*
+  * Return codes:
+  *
+diff --git a/verity_tool/main.cpp b/verity_tool/main.cpp
+index befdafa..f5f026a 100644
+--- a/verity_tool/main.cpp
++++ b/verity_tool/main.cpp
+@@ -24,23 +24,20 @@ static void print_usage() {
+     printf("veritytool - toggle block device verification\n"
+            "    --help        show this help\n"
+            "    --enable      enable dm-verity\n"
+-           "    --disable     disable dm-verity\n"
+-           "    --show        show current dm-verity state\n");
++           "    --disable     disable dm-verity\n");
+ }
+ 
+ int main(int argc, char** argv) {
+     int c, rc;
+     int enable = 0;
+-    int show = 0;
+     bool flag_set = false;
+     struct option long_opts[] = {
+         {"disable", no_argument, &enable, 0},
+         {"enable", no_argument, &enable, 1},
+-        {"show", no_argument, &show, 1},
+         {NULL, 0, NULL, 0},
+     };
+ 
+-    while ((c = getopt_long(argc, argv, "des", long_opts, NULL)) != -1) {
++    while ((c = getopt_long(argc, argv, "de", long_opts, NULL)) != -1) {
+         switch (c) {
+             case 0:
+                 flag_set = true;
+@@ -56,26 +53,6 @@ int main(int argc, char** argv) {
+         exit(0);
+     }
+ 
+-    if (show) {
+-        printf("dm-verity state: ");
+-        switch (get_verity_state()) {
+-            case VERITY_STATE_NO_DEVICE:
+-                printf("NO DEVICE");
+-                break;
+-            case VERITY_STATE_DISABLED:
+-                printf("DISABLED");
+-                break;
+-            case VERITY_STATE_ENABLED:
+-                printf("ENABLED");
+-                break;
+-            default:
+-                printf("UNKNOWN");
+-                break;
+-        }
+-        printf("\n");
+-        return 0;
+-    }
+-
+     if (!set_verity_enabled(enable)) {
+         printf("Error occurred in set_verity_enable\n");
+         exit(EXIT_FAILURE);
+diff --git a/verity_tool/verity_tool.cpp b/verity_tool/verity_tool.cpp
+index 48e95b6..9575c4c 100644
+--- a/verity_tool/verity_tool.cpp
++++ b/verity_tool/verity_tool.cpp
+@@ -108,69 +108,6 @@ static std::string get_ab_suffix() {
+     return ab_suffix;
+ }
+ 
+-verity_state_t get_verity_state() {
+-    verity_state_t rc = VERITY_STATE_NO_DEVICE;
+-    std::string ab_suffix = get_ab_suffix();
+-
+-    // Figure out if we're using VB1.0 or VB2.0 (aka AVB) - by
+-    // contract, androidboot.vbmeta.digest is set by the bootloader
+-    // when using AVB).
+-    bool using_avb = !android::base::GetProperty("ro.boot.vbmeta.digest", "").empty();
+-
+-    if (using_avb) {
+-        // Yep, the system is using AVB.
+-        AvbOps* ops = avb_ops_user_new();
+-        if (ops == nullptr) {
+-            LOG(ERROR) << "Error getting AVB ops";
+-            avb_ops_user_free(ops);
+-            return VERITY_STATE_UNKNOWN;
+-        }
+-        bool verity_enabled;
+-        if (!avb_user_verity_get(ops, ab_suffix.c_str(), &verity_enabled)) {
+-            LOG(ERROR) << "Error getting verity state";
+-            avb_ops_user_free(ops);
+-            return VERITY_STATE_UNKNOWN;
+-        }
+-        rc = verity_enabled ? VERITY_STATE_ENABLED : VERITY_STATE_DISABLED;
+-        avb_ops_user_free(ops);
+-    } else {
+-        // Not using AVB - assume VB1.0.
+-
+-        // read all fstab entries at once from all sources
+-        struct fstab* fstab = fs_mgr_read_fstab_default();
+-        if (!fstab) {
+-            LOG(ERROR) << "Failed to read fstab";
+-            fs_mgr_free_fstab(fstab);
+-            return VERITY_STATE_UNKNOWN;
+-        }
+-
+-        // Loop through entries looking for ones that vold manages.
+-        for (int i = 0; i < fstab->num_entries; i++) {
+-            if (fs_mgr_is_verified(&fstab->recs[i])) {
+-                std::string block_device = fstab->recs[i].blk_device;
+-                fec::io fh(block_device, O_RDONLY);
+-                if (!fh) {
+-                    PLOG(ERROR) << "Could not open block device " << block_device;
+-                    rc = VERITY_STATE_UNKNOWN;
+-                    break;
+-                }
+-
+-                fec_verity_metadata metadata;
+-                if (!fh.get_verity_metadata(metadata)) {
+-                    LOG(ERROR) << "Couldn't find verity metadata!";
+-                    rc = VERITY_STATE_UNKNOWN;
+-                    break;
+-                }
+-
+-                rc = metadata.disabled ? VERITY_STATE_DISABLED : VERITY_STATE_ENABLED;
+-            }
+-        }
+-        fs_mgr_free_fstab(fstab);
+-    }
+-
+-    return rc;
+-}
+-
+ /* Use AVB to turn verity on/off */
+ static bool set_avb_verity_enabled_state(AvbOps* ops, bool enable_verity) {
+     std::string ab_suffix = get_ab_suffix();
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0002-Revert-kernel.mk-Support-kernels-that-use-LTO.patch b/patches/vendor/bliss/0002-Revert-kernel.mk-Support-kernels-that-use-LTO.patch
new file mode 100644
index 0000000..f92e018
--- /dev/null
+++ b/patches/vendor/bliss/0002-Revert-kernel.mk-Support-kernels-that-use-LTO.patch
@@ -0,0 +1,114 @@
+From 923baf7c52a3598ab9c35ef689a9d53bfb850024 Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:24:36 -0700
+Subject: [PATCH 2/9] Revert "kernel.mk: Support kernels that use LTO"
+
+This reverts commit 811524eef488f81295c876b669d8ec7a6cad9cea.
+
+Change-Id: I01ddf5eedfed84c04c1a36856e495da4fb5a83c3
+---
+ build/tasks/kernel.mk | 31 +++++++++++++++----------------
+ 1 file changed, 15 insertions(+), 16 deletions(-)
+
+diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
+index 54812a9..7a674ee 100644
+--- a/build/tasks/kernel.mk
++++ b/build/tasks/kernel.mk
+@@ -178,9 +178,8 @@ ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
+     else ifeq ($(KERNEL_ARCH),x86)
+         KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=x86_64-linux-gnu-
+     endif
+-    PATH_OVERRIDE := PATH=$(TARGET_KERNEL_CLANG_PATH):$$PATH LD_LIBRARY_PATH=$(BUILD_TOP)/prebuilts/clang/host/$(HOST_OS)-x86/$(KERNEL_CLANG_VERSION)/lib64:$$LD_LIBRARY_PATH
+     ifeq ($(KERNEL_CC),)
+-        KERNEL_CC := CC="$(CCACHE_BIN) clang"
++        KERNEL_CC := CC="$(CCACHE_BIN) $(TARGET_KERNEL_CLANG_PATH)/clang"
+     endif
+ endif
+ 
+@@ -197,17 +196,17 @@ $(KERNEL_ADDITIONAL_CONFIG_OUT): force_additional_config
+ $(KERNEL_CONFIG): $(KERNEL_DEFCONFIG_SRC) $(KERNEL_ADDITIONAL_CONFIG_OUT)
+ 	@echo "Building Kernel Config"
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+-	$(PATH_OVERRIDE) $(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG)
++	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG)
+ 	$(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \
+ 			echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \
+ 			echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \
+-			$(PATH_OVERRIDE) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) oldconfig; fi
++			$(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) oldconfig; fi
+ 	# Create defconfig build artifact
+-	$(hide) $(PATH_OVERRIDE) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig
++	$(hide) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig
+ 	$(hide) if [ ! -z "$(KERNEL_ADDITIONAL_CONFIG)" ]; then \
+ 			echo "Using additional config '$(KERNEL_ADDITIONAL_CONFIG)'"; \
+ 			$(KERNEL_SRC)/scripts/kconfig/merge_config.sh -m -O $(KERNEL_OUT) $(KERNEL_OUT)/.config $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG); \
+-			$(PATH_OVERRIDE) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) KCONFIG_ALLCONFIG=$(KERNEL_OUT)/.config alldefconfig; fi
++			$(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) KCONFIG_ALLCONFIG=$(KERNEL_OUT)/.config alldefconfig; fi
+ 
+ .PHONY: TARGET_KERNEL_BINARIES
+ TARGET_KERNEL_BINARIES: $(KERNEL_CONFIG)
+@@ -215,21 +214,21 @@ TARGET_KERNEL_BINARIES: $(KERNEL_CONFIG)
+ 	$(hide) rm -rf $(KERNEL_MODULES_OUT)
+ 	$(hide) mkdir -p $(KERNEL_MODULES_OUT)
+ 	$(hide) rm -rf $(KERNEL_DEPMOD_STAGING_DIR)
+-	$(PATH_OVERRIDE) $(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(BOARD_KERNEL_IMAGE_NAME)
++	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(BOARD_KERNEL_IMAGE_NAME)
+ 	$(hide) if grep -q '^CONFIG_OF=y' $(KERNEL_CONFIG); then \
+ 			echo "Building DTBs"; \
+-			$(PATH_OVERRIDE) $(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbs; \
++			$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbs; \
+ 		fi
+ 	$(hide) if grep -q '^CONFIG_MODULES=y' $(KERNEL_CONFIG); then \
+ 			echo "Building Kernel Modules"; \
+-			$(PATH_OVERRIDE) $(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) modules; \
++			$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) modules; \
+ 		fi
+ 
+ .PHONY: INSTALLED_KERNEL_MODULES
+ INSTALLED_KERNEL_MODULES: depmod-host
+ 	$(hide) if grep -q '^CONFIG_MODULES=y' $(KERNEL_CONFIG); then \
+ 			echo "Installing Kernel Modules"; \
+-			$(PATH_OVERRIDE) $(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) INSTALL_MOD_PATH=../../$(KERNEL_MODULES_INSTALL) modules_install && \
++			$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) INSTALL_MOD_PATH=../../$(KERNEL_MODULES_INSTALL) modules_install && \
+ 			mofile=$$(find $(KERNEL_MODULES_OUT) -type f -name modules.order) && \
+ 			mpath=$$(dirname $$mofile) && \
+ 			for f in $$(find $$mpath/kernel -type f -name '*.ko'); do \
+@@ -250,29 +249,29 @@ $(TARGET_PREBUILT_INT_KERNEL): $(TARGET_KERNEL_MODULES)
+ .PHONY: kerneltags
+ kerneltags: $(KERNEL_CONFIG)
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+-	$(PATH_OVERRIDE) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) tags
++	$(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) tags
+ 
+ .PHONY: kernelsavedefconfig alldefconfig
+ 
+ kernelsavedefconfig:
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+-	$(PATH_OVERRIDE) $(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
++	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
+ 	env KCONFIG_NOTIMESTAMP=true \
+-		 $(PATH_OVERRIDE) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig
++		 $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig
+ 	cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC)
+ 
+ alldefconfig:
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+ 	env KCONFIG_NOTIMESTAMP=true \
+-		 $(PATH_OVERRIDE) $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) alldefconfig
++		 $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) alldefconfig
+ 
+ endif # FULL_KERNEL_BUILD
+ 
+ TARGET_PREBUILT_DTBO = $(PRODUCT_OUT)/dtbo/arch/$(KERNEL_ARCH)/boot/dtbo.img
+ $(TARGET_PREBUILT_DTBO): $(AVBTOOL)
+ 	echo -e ${CL_GRN}"Building DTBO.img"${CL_RST}
+-	$(PATH_OVERRIDE) $(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
+-	$(PATH_OVERRIDE) $(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbo.img
++	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
++	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbo.img
+ 	$(AVBTOOL) add_hash_footer \
+ 		--image $@ \
+ 		--partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0003-Revert-kernel-Remove-kernel-x-config.patch b/patches/vendor/bliss/0003-Revert-kernel-Remove-kernel-x-config.patch
new file mode 100644
index 0000000..f1c9601
--- /dev/null
+++ b/patches/vendor/bliss/0003-Revert-kernel-Remove-kernel-x-config.patch
@@ -0,0 +1,37 @@
+From 851e1066c8571b64f73abbbf4c702332fcaac623 Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:26:00 -0700
+Subject: [PATCH 3/9] Revert "kernel: Remove kernel{x}config"
+
+This reverts commit 12c4070d98e0bb69869874d8fcaa22769a07d994.
+---
+ build/tasks/kernel.mk | 13 ++++++++++++-
+ 1 file changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
+index 7a674ee..61d63bc 100644
+--- a/build/tasks/kernel.mk
++++ b/build/tasks/kernel.mk
+@@ -251,7 +251,18 @@ kerneltags: $(KERNEL_CONFIG)
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+ 	$(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) tags
+ 
+-.PHONY: kernelsavedefconfig alldefconfig
++.PHONY: kernelconfig kernelxconfig kernelsavedefconfig alldefconfig
++
++kernelconfig:  KERNELCONFIG_MODE := menuconfig
++kernelxconfig: KERNELCONFIG_MODE := xconfig
++kernelxconfig kernelconfig:
++	$(hide) mkdir -p $(KERNEL_OUT)
++	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
++	env KCONFIG_NOTIMESTAMP=true \
++		 $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNELCONFIG_MODE)
++	env KCONFIG_NOTIMESTAMP=true \
++		 $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig
++	cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC)
+ 
+ kernelsavedefconfig:
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0004-Revert-kernel-Remove-deprecated-flag-errors.patch b/patches/vendor/bliss/0004-Revert-kernel-Remove-deprecated-flag-errors.patch
new file mode 100644
index 0000000..a1378c9
--- /dev/null
+++ b/patches/vendor/bliss/0004-Revert-kernel-Remove-deprecated-flag-errors.patch
@@ -0,0 +1,30 @@
+From aeecbbc9482abc64bedd18df3ab3a74b96d5c95a Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:26:06 -0700
+Subject: [PATCH 4/9] Revert "kernel: Remove deprecated flag errors"
+
+This reverts commit 31a4c13150d86dd3690fe4b79678f0578900591c.
+---
+ build/tasks/kernel.mk | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
+index 61d63bc..b42d86d 100644
+--- a/build/tasks/kernel.mk
++++ b/build/tasks/kernel.mk
+@@ -77,6 +77,12 @@ KERNEL_DEFCONFIG_SRC := $(KERNEL_SRC)/arch/$(KERNEL_DEFCONFIG_ARCH)/configs/$(KE
+ ifeq ($(BOARD_KERNEL_IMAGE_NAME),)
+ $(error BOARD_KERNEL_IMAGE_NAME not defined.)
+ endif
++ifneq ($(TARGET_USES_UNCOMPRESSED_KERNEL),)
++$(error TARGET_USES_UNCOMPRESSED_KERNEL is deprecated.)
++endif
++ifneq ($(TARGET_KERNEL_APPEND_DTB),)
++$(error TARGET_KERNEL_APPEND_DTB is deprecated.)
++endif
+ TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME)
+ 
+ ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),)
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0005-Revert-vendor-bliss-Remove-kernel.mk-headers-generat.patch b/patches/vendor/bliss/0005-Revert-vendor-bliss-Remove-kernel.mk-headers-generat.patch
new file mode 100644
index 0000000..7bc4f19
--- /dev/null
+++ b/patches/vendor/bliss/0005-Revert-vendor-bliss-Remove-kernel.mk-headers-generat.patch
@@ -0,0 +1,82 @@
+From 290db10c7e0160ae1cb35e4d3d24ee40ab517362 Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:26:15 -0700
+Subject: [PATCH 5/9] Revert "vendor/bliss: Remove kernel.mk headers
+ generation"
+
+This reverts commit 6a4c7c1258ffecc26324b034c9091373bf0272dd.
+---
+ build/tasks/kernel.mk | 50 +++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 50 insertions(+)
+
+diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
+index b42d86d..d0263d3 100644
+--- a/build/tasks/kernel.mk
++++ b/build/tasks/kernel.mk
+@@ -151,6 +151,9 @@ endif
+ 
+ ifeq ($(FULL_KERNEL_BUILD),true)
+ 
++KERNEL_HEADERS_INSTALL_DIR := $(KERNEL_OUT)/usr
++KERNEL_HEADERS_INSTALL_DEPS := $(KERNEL_OUT)/.headers_install_deps
++
+ ifeq ($(NEED_KERNEL_MODULE_ROOT),true)
+ KERNEL_MODULES_INSTALL := root
+ KERNEL_MODULES_OUT := $(TARGET_ROOT_OUT)/lib/modules
+@@ -252,6 +255,53 @@ $(TARGET_KERNEL_MODULES): TARGET_KERNEL_BINARIES
+ 
+ $(TARGET_PREBUILT_INT_KERNEL): $(TARGET_KERNEL_MODULES)
+ 
++# Install kernel (uapi) headers.
++#
++# The dependency file serves two purposes:
++#  - It is a stamp indicating when the headers were last installed.
++#  - It contains a rule to regenerate itself when any kernel header
++#    files change.  This rule is identical to the rule emitted by
++#    GCC using the M/MM flags.
++#
++# Note that the location of installed kernel headers changed when the
++# kernel uapi system was introduced in 3.7.  Unfortunately, it is not
++# sufficient to test whether the uapi directories exist because some
++# kernels backport patches that contain uapi headers.  So we look for
++# the string "version_h" in the kernel makefile which was introduced
++# as a part of the uapi system (commit d183e6f570f3).
++-include $(KERNEL_HEADERS_INSTALL_DEPS)
++$(KERNEL_HEADERS_INSTALL_DEPS):
++	@echo "Building Kernel Headers"
++	$(hide) mkdir -p $(KERNEL_OUT)
++	$(hide) rm -f $@
++	$(hide) $(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) headers_install
++	$(hide) echo "$@: \\" > $@
++	$(hide) ( cd $(KERNEL_SRC); \
++		if grep -q '^version_h' 'Makefile'; then \
++			depdirs="arch/$(KERNEL_ARCH)/include/uapi include/uapi"; \
++		else \
++			depdirs="arch/$(KERNEL_ARCH)/include/asm include"; \
++		fi; \
++		deps="Makefile $$(find $$depdirs -type f -name '*.h')"; \
++		for f in $$deps; do \
++			echo "  $(KERNEL_SRC)/$$f \\" >> $@; \
++		done ; \
++		echo "" >> $@ ; \
++		for f in $$deps; do \
++			echo "$(KERNEL_SRC)/$$f:" >> $@; \
++			echo "" >> $@; \
++		done \
++		)
++
++.PHONY: INSTALLED_KERNEL_HEADERS
++INSTALLED_KERNEL_HEADERS: $(KERNEL_HEADERS_INSTALL_DEPS)
++
++# Dependencies on $(KERNEL_OUT)/usr are deprecated
++$(KERNEL_HEADERS_INSTALL_DIR): $(KERNEL_HEADERS_INSTALL_DEPS)
++	@echo "Depending on $(KERNEL_HEADERS_INSTALL_DIR) is deprecated." 1>&2
++	@echo "Use INSTALLED_KERNEL_HEADERS instead." 1>&2
++	@exit 1
++
+ .PHONY: kerneltags
+ kerneltags: $(KERNEL_CONFIG)
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0006-Revert-vendor-bliss-Dynamically-generate-kernel-head.patch b/patches/vendor/bliss/0006-Revert-vendor-bliss-Dynamically-generate-kernel-head.patch
new file mode 100644
index 0000000..8b3b2ff
--- /dev/null
+++ b/patches/vendor/bliss/0006-Revert-vendor-bliss-Dynamically-generate-kernel-head.patch
@@ -0,0 +1,150 @@
+From bfb9d40fb9a61288099d69a48294f21ecad3d2ca Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:26:24 -0700
+Subject: [PATCH 6/9] Revert "vendor/bliss: Dynamically generate kernel headers
+ using bliss generator"
+
+This reverts commit e0831af9a803dc2bdd1d203d93c3e3ce9b8e120a.
+---
+ build/soong/Android.bp             | 22 ----------------------
+ build/soong/generator/generator.go |  5 +----
+ build/soong/generator/variables.go | 28 ----------------------------
+ config/BoardConfigBliss.mk         |  1 -
+ config/BoardConfigSoong.mk         | 18 ------------------
+ 5 files changed, 1 insertion(+), 73 deletions(-)
+ delete mode 100644 build/soong/generator/variables.go
+ delete mode 100644 config/BoardConfigSoong.mk
+
+diff --git a/build/soong/Android.bp b/build/soong/Android.bp
+index 3addbe3..45a4ab7 100644
+--- a/build/soong/Android.bp
++++ b/build/soong/Android.bp
+@@ -18,28 +18,6 @@ bootstrap_go_package {
+     ],
+     srcs: [
+         "generator/generator.go",
+-        "generator/variables.go",
+     ],
+     pluginFor: ["soong_build"],
+ }
+-
+-bliss_generator {
+-    name: "generated_kernel_includes",
+-
+-    // The headers make command
+-    cmd: "make $(KERNEL_MAKE_FLAGS) -C $(TARGET_KERNEL_SOURCE) O=$(genDir) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) headers_install",
+-
+-    // Directories that can be imported by a cc_* module generated_headers property
+-    export_include_dirs: ["usr/include"],
+-
+-    // Sources for dependency tracking
+-    dep_root: "$(TARGET_KERNEL_SOURCE)",
+-    dep_files: [ "Makefile", "include/**/*", "arch/$(KERNEL_ARCH)/include/**/*"],
+-}
+-
+-cc_library_headers {
+-    name: "generated_kernel_headers",
+-    generated_headers: ["generated_kernel_includes"],
+-    export_generated_headers: ["generated_kernel_includes"],
+-    vendor_available: true,
+-}
+diff --git a/build/soong/generator/generator.go b/build/soong/generator/generator.go
+index ffaece3..b14a19c 100644
+--- a/build/soong/generator/generator.go
++++ b/build/soong/generator/generator.go
+@@ -213,13 +213,10 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ 	depRoot := String(g.properties.Dep_root)
+ 	if depRoot == "" {
+ 		depRoot = ctx.ModuleDir()
+-	} else {
+-		depRoot = blissExpandVariables(ctx, depRoot)
+ 	}
+ 
+ 	// Glob dep_files property
+ 	for _, dep_file := range g.properties.Dep_files {
+-		dep_file = blissExpandVariables(ctx, dep_file)
+ 		globPath := filepath.Join(depRoot, dep_file)
+ 		paths, err := ctx.GlobWithDeps(globPath, nil)
+ 		if err != nil {
+@@ -231,7 +228,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ 		}
+ 	}
+ 
+-	cmd := blissExpandVariables(ctx, String(g.properties.Cmd))
++	cmd := String(g.properties.Cmd)
+ 
+ 	rawCommand, err := android.Expand(cmd, func(name string) (string, error) {
+ 		switch name {
+diff --git a/build/soong/generator/variables.go b/build/soong/generator/variables.go
+deleted file mode 100644
+index 3e633ff..0000000
+--- a/build/soong/generator/variables.go
++++ /dev/null
+@@ -1,28 +0,0 @@
+-package generator
+-
+-import (
+-	"fmt"
+-
+-	"android/soong/android"
+-)
+-
+-func blissExpandVariables(ctx android.ModuleContext, in string) string {
+-	blissVars := ctx.Config().VendorConfig("blissVarsPlugin")
+-
+-	out, err := android.Expand(in, func(name string) (string, error) {
+-		if blissVars.IsSet(name) {
+-			return blissVars.String(name), nil
+-		}
+-		// This variable is not for us, restore what the original
+-		// variable string will have looked like for an Expand
+-		// that comes later.
+-		return fmt.Sprintf("$(%s)", name), nil
+-	})
+-
+-	if err != nil {
+-		ctx.PropertyErrorf("%s: %s", in, err.Error())
+-		return ""
+-	}
+-
+-	return out
+-}
+diff --git a/config/BoardConfigBliss.mk b/config/BoardConfigBliss.mk
+index 7ccae1d..e38938b 100644
+--- a/config/BoardConfigBliss.mk
++++ b/config/BoardConfigBliss.mk
+@@ -9,7 +9,6 @@ ifeq ($(TARGET_HW_DISK_ENCRYPTION),true)
+ endif
+ 
+ include vendor/bliss/config/BoardConfigKernel.mk
+-include vendor/lineage/config/BoardConfigSoong.mk
+ 
+ ifeq ($(BOARD_USES_QCOM_HARDWARE),true) 
+ include vendor/bliss/config/BoardConfigQcom.mk 
+diff --git a/config/BoardConfigSoong.mk b/config/BoardConfigSoong.mk
+deleted file mode 100644
+index 35d7893..0000000
+--- a/config/BoardConfigSoong.mk
++++ /dev/null
+@@ -1,18 +0,0 @@
+-# Add variables that we wish to make available to soong here.
+-EXPORT_TO_SOONG := \
+-    KERNEL_ARCH \
+-    KERNEL_CROSS_COMPILE \
+-    KERNEL_MAKE_FLAGS \
+-    TARGET_KERNEL_CONFIG \
+-    TARGET_KERNEL_SOURCE
+-
+-SOONG_CONFIG_NAMESPACES += blissVarsPlugin
+-
+-SOONG_CONFIG_blissVarsPlugin :=
+-
+-define addVar
+-  SOONG_CONFIG_blissVarsPlugin += $(1)
+-  SOONG_CONFIG_blissVarsPlugin_$(1) := $$(subst ",\",$$($1))
+-endef
+-
+-$(foreach v,$(EXPORT_TO_SOONG),$(eval $(call addVar,$(v))))
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0007-Revert-vendor-bliss-Add-soong-generator-module-type.patch b/patches/vendor/bliss/0007-Revert-vendor-bliss-Add-soong-generator-module-type.patch
new file mode 100644
index 0000000..f4b6ffa
--- /dev/null
+++ b/patches/vendor/bliss/0007-Revert-vendor-bliss-Add-soong-generator-module-type.patch
@@ -0,0 +1,352 @@
+From b0683d4e56b31ee4594e10e046fd4e5b2e1e8b2f Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:26:48 -0700
+Subject: [PATCH 7/9] Revert "vendor/bliss: Add soong generator module type"
+
+This reverts commit 0d2bcd429f2227c1efd59c2a7a4916f6f10c8af2.
+---
+ build/soong/Android.bp             |  16 --
+ build/soong/generator/generator.go | 307 -----------------------------
+ 2 files changed, 323 deletions(-)
+ delete mode 100644 build/soong/generator/generator.go
+
+diff --git a/build/soong/Android.bp b/build/soong/Android.bp
+index 45a4ab7..2cb1afa 100644
+--- a/build/soong/Android.bp
++++ b/build/soong/Android.bp
+@@ -5,19 +5,3 @@ bootstrap_go_package {
+         "android/variable.go",
+     ],
+ }
+-
+-bootstrap_go_package {
+-    name: "soong-bliss-generator",
+-    pkgPath: "bliss/soong/generator",
+-    deps: [
+-        "blueprint",
+-        "blueprint-pathtools",
+-        "soong",
+-        "soong-android",
+-        "soong-shared",
+-    ],
+-    srcs: [
+-        "generator/generator.go",
+-    ],
+-    pluginFor: ["soong_build"],
+-}
+diff --git a/build/soong/generator/generator.go b/build/soong/generator/generator.go
+deleted file mode 100644
+index b14a19c..0000000
+--- a/build/soong/generator/generator.go
++++ /dev/null
+@@ -1,307 +0,0 @@
+-// Copyright 2015 Google Inc. All rights reserved.
+-// Copyright (C) 2018 The LineageOS 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.
+-
+-package generator
+-
+-import (
+-	"fmt"
+-	"strings"
+-
+-	"github.com/google/blueprint"
+-	"github.com/google/blueprint/bootstrap"
+-	"github.com/google/blueprint/proptools"
+-
+-	"android/soong/android"
+-	"android/soong/shared"
+-	"path/filepath"
+-)
+-
+-func init() {
+-	android.RegisterModuleType("bliss_generator", GeneratorFactory)
+-
+-	pctx.HostBinToolVariable("sboxCmd", "sbox")
+-}
+-
+-var String = proptools.String
+-
+-var (
+-	pctx = android.NewPackageContext("android/soong/generator")
+-)
+-
+-type HostToolProvider interface {
+-	HostToolPath() android.OptionalPath
+-}
+-
+-type hostToolDependencyTag struct {
+-	blueprint.BaseDependencyTag
+-}
+-
+-var hostToolDepTag hostToolDependencyTag
+-
+-type generatorProperties struct {
+-	// The command to run on one or more input files. Cmd supports substitution of a few variables
+-	// (the actual substitution is implemented in GenerateAndroidBuildActions below)
+-	//
+-	// Available variables for substitution:
+-	//
+-	//  $(location): the path to the first entry in tools or tool_files
+-	//  $(location <label>): the path to the tool or tool_file with name <label>
+-	//  $(genDir): the sandbox directory for this tool; contains $(out)
+-	//  $$: a literal $
+-	//
+-	Cmd *string
+-
+-	// name of the modules (if any) that produces the host executable.   Leave empty for
+-	// prebuilts or scripts that do not need a module to build them.
+-	Tools []string
+-
+-	// Local file that is used as the tool
+-	Tool_files []string
+-
+-	// List of directories to export as headers
+-	Export_include_dirs []string
+-
+-	// List of directories to export as sources
+-	Export_source_dirs []string
+-
+-	// Root directory for dep_files.
+-	// Relative to top build dir.
+-	Dep_root *string
+-
+-	// Declare list of files that should be used for timestamp dependency checking
+-	Dep_files []string
+-}
+-
+-type Module struct {
+-	android.ModuleBase
+-
+-	properties generatorProperties
+-
+-	rule blueprint.Rule
+-
+-	// Tool dependencies
+-	implicitDeps android.Paths
+-	// Deps from input files declared in dep_files property.
+-	inputDeps android.Paths
+-
+-	exportedIncludeDirs android.Paths
+-	exportedSourceDirs  android.Paths
+-
+-	outputDeps android.Paths
+-}
+-
+-// These three methods satisfy genrule.SourceFileGenerator.
+-// Which cc modules check for when including headers etc.
+-func (g *Module) GeneratedHeaderDirs() android.Paths {
+-	return g.exportedIncludeDirs
+-}
+-
+-func (g *Module) GeneratedSourceFiles() android.Paths {
+-	return g.exportedSourceDirs
+-}
+-
+-func (g *Module) GeneratedDeps() android.Paths {
+-	return g.outputDeps
+-}
+-
+-func (g *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
+-	android.ExtractSourcesDeps(ctx, g.properties.Dep_files)
+-	android.ExtractSourcesDeps(ctx, g.properties.Tool_files)
+-	if g, ok := ctx.Module().(*Module); ok {
+-		if len(g.properties.Tools) > 0 {
+-			ctx.AddFarVariationDependencies([]blueprint.Variation{
+-				{"arch", ctx.Config().BuildOsVariant},
+-			}, hostToolDepTag, g.properties.Tools...)
+-		}
+-	}
+-}
+-
+-func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+-	if len(g.properties.Export_include_dirs) > 0 {
+-		for _, dir := range g.properties.Export_include_dirs {
+-			g.exportedIncludeDirs = append(g.exportedIncludeDirs,
+-				android.PathForModuleGen(ctx, dir))
+-		}
+-	} else {
+-		g.exportedIncludeDirs = append(g.exportedIncludeDirs, android.PathForModuleGen(ctx, ""))
+-	}
+-	if len(g.properties.Export_source_dirs) > 0 {
+-		for _, dir := range g.properties.Export_source_dirs {
+-			g.exportedSourceDirs = append(g.exportedSourceDirs,
+-				android.PathForModuleGen(ctx, dir))
+-		}
+-	} else {
+-		g.exportedSourceDirs = append(g.exportedSourceDirs, android.PathForModuleGen(ctx, ""))
+-	}
+-
+-	tools := map[string]android.Path{}
+-
+-	if len(g.properties.Tools) > 0 {
+-		ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
+-			switch ctx.OtherModuleDependencyTag(module) {
+-			case android.SourceDepTag:
+-				// Nothing to do
+-			case hostToolDepTag:
+-				tool := ctx.OtherModuleName(module)
+-				var path android.OptionalPath
+-
+-				if t, ok := module.(HostToolProvider); ok {
+-					if !t.(android.Module).Enabled() {
+-						if ctx.Config().AllowMissingDependencies() {
+-							ctx.AddMissingDependencies([]string{tool})
+-						} else {
+-							ctx.ModuleErrorf("depends on disabled module %q", tool)
+-						}
+-						break
+-					}
+-					path = t.HostToolPath()
+-				} else if t, ok := module.(bootstrap.GoBinaryTool); ok {
+-					if s, err := filepath.Rel(android.PathForOutput(ctx).String(), t.InstallPath()); err == nil {
+-						path = android.OptionalPathForPath(android.PathForOutput(ctx, s))
+-					} else {
+-						ctx.ModuleErrorf("cannot find path for %q: %v", tool, err)
+-						break
+-					}
+-				} else {
+-					ctx.ModuleErrorf("%q is not a host tool provider", tool)
+-					break
+-				}
+-
+-				if path.Valid() {
+-					g.implicitDeps = append(g.implicitDeps, path.Path())
+-					if _, exists := tools[tool]; !exists {
+-						tools[tool] = path.Path()
+-					} else {
+-						ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool], path.Path().String())
+-					}
+-				} else {
+-					ctx.ModuleErrorf("host tool %q missing output file", tool)
+-				}
+-			default:
+-				ctx.ModuleErrorf("unknown dependency on %q", ctx.OtherModuleName(module))
+-			}
+-		})
+-	}
+-
+-	if ctx.Failed() {
+-		return
+-	}
+-
+-	toolFiles := ctx.ExpandSources(g.properties.Tool_files, nil)
+-	for _, tool := range toolFiles {
+-		g.implicitDeps = append(g.implicitDeps, tool)
+-		if _, exists := tools[tool.Rel()]; !exists {
+-			tools[tool.Rel()] = tool
+-		} else {
+-			ctx.ModuleErrorf("multiple tools for %q, %q and %q", tool, tools[tool.Rel()], tool.Rel())
+-		}
+-	}
+-
+-	// Determine root dir for dep_files.  Defaults to current ctx ModuleDir.
+-	depRoot := String(g.properties.Dep_root)
+-	if depRoot == "" {
+-		depRoot = ctx.ModuleDir()
+-	}
+-
+-	// Glob dep_files property
+-	for _, dep_file := range g.properties.Dep_files {
+-		globPath := filepath.Join(depRoot, dep_file)
+-		paths, err := ctx.GlobWithDeps(globPath, nil)
+-		if err != nil {
+-			ctx.ModuleErrorf("unable to glob %s: %s", globPath, err.Error())
+-			return
+-		}
+-		for _, path := range paths {
+-			g.inputDeps = append(g.inputDeps, android.PathForSourceRelaxed(ctx, path))
+-		}
+-	}
+-
+-	cmd := String(g.properties.Cmd)
+-
+-	rawCommand, err := android.Expand(cmd, func(name string) (string, error) {
+-		switch name {
+-		case "location":
+-			if len(g.properties.Tools) == 0 && len(toolFiles) == 0 {
+-				return "", fmt.Errorf("at least one `tools` or `tool_files` is required if $(location) is used")
+-			}
+-
+-			if len(g.properties.Tools) > 0 {
+-				return tools[g.properties.Tools[0]].String(), nil
+-			} else {
+-				return tools[toolFiles[0].Rel()].String(), nil
+-			}
+-		case "genDir":
+-			return "__SBOX_OUT_DIR__", nil
+-		default:
+-			if strings.HasPrefix(name, "location ") {
+-				label := strings.TrimSpace(strings.TrimPrefix(name, "location "))
+-				if tool, ok := tools[label]; ok {
+-					return tool.String(), nil
+-				} else {
+-					return "", fmt.Errorf("unknown location label %q", label)
+-				}
+-			}
+-			return "", fmt.Errorf("unknown variable '$(%s)'", name)
+-		}
+-	})
+-
+-	if err != nil {
+-		ctx.PropertyErrorf("cmd", "%s", err.Error())
+-		return
+-	}
+-
+-	// Dummy output dep
+-	dummyDep := android.PathForModuleGen(ctx, ".dummy_dep")
+-
+-	// tell the sbox command which directory to use as its sandbox root
+-	buildDir := android.PathForOutput(ctx).String()
+-	sandboxPath := shared.TempDirForOutDir(buildDir)
+-
+-	genDir := android.PathForModuleGen(ctx)
+-	// Escape the command for the shell
+-	rawCommand = "'" + strings.Replace(rawCommand, "'", `'\''`, -1) + "'"
+-	sandboxCommand := fmt.Sprintf("$sboxCmd --sandbox-path %s --output-root %s --copy-all-output -c %s && touch %s",
+-		sandboxPath, genDir, rawCommand, dummyDep.String())
+-
+-	ruleParams := blueprint.RuleParams{
+-		Command:     sandboxCommand,
+-		CommandDeps: []string{"$sboxCmd"},
+-	}
+-	g.rule = ctx.Rule(pctx, "generator", ruleParams)
+-
+-	params := android.BuildParams{
+-		Rule:        g.rule,
+-		Description: "generate",
+-		Output:      dummyDep,
+-		Inputs:      g.inputDeps,
+-		Implicits:   g.implicitDeps,
+-	}
+-
+-	g.outputDeps = append(g.outputDeps, dummyDep)
+-
+-	ctx.Build(pctx, params)
+-}
+-
+-func NewGenerator() *Module {
+-	module := &Module{}
+-	module.AddProperties(&module.properties)
+-	return module
+-}
+-
+-func GeneratorFactory() android.Module {
+-	m := NewGenerator()
+-	android.InitAndroidModule(m)
+-	return m
+-}
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0008-Revert-vendor-bliss-Move-some-kernel-definitions-to-.patch b/patches/vendor/bliss/0008-Revert-vendor-bliss-Move-some-kernel-definitions-to-.patch
new file mode 100644
index 0000000..caf67d9
--- /dev/null
+++ b/patches/vendor/bliss/0008-Revert-vendor-bliss-Move-some-kernel-definitions-to-.patch
@@ -0,0 +1,401 @@
+From f47a7f340355df09288b5c6aa293bc62d48da6c7 Mon Sep 17 00:00:00 2001
+From: Jackeagle <jackeagle102@gmail.com>
+Date: Sat, 17 Nov 2018 08:26:58 -0700
+Subject: [PATCH 8/9] Revert "vendor/bliss: Move some kernel definitions to
+ BoardConfigKernel"
+
+This reverts commit 3a8423358f51b6616622c881e04d82ba2f603984.
+---
+ build/tasks/kernel.mk       | 122 ++++++++++++++++++++++++++++++++----
+ config/BoardConfigBliss.mk  |   2 -
+ config/BoardConfigKernel.mk | 111 --------------------------------
+ 3 files changed, 111 insertions(+), 124 deletions(-)
+ delete mode 100644 config/BoardConfigKernel.mk
+
+diff --git a/build/tasks/kernel.mk b/build/tasks/kernel.mk
+index d0263d3..6057b9f 100644
+--- a/build/tasks/kernel.mk
++++ b/build/tasks/kernel.mk
+@@ -1,5 +1,4 @@
+ # Copyright (C) 2012 The CyanogenMod Project
+-#           (C) 2017 The LineageOS Project
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+@@ -21,10 +20,17 @@
+ #
+ # These config vars are usually set in BoardConfig.mk:
+ #
++#   TARGET_KERNEL_SOURCE               = Kernel source dir, optional, defaults
++#                                        to kernel/$(TARGET_DEVICE_DIR)
+ #   TARGET_KERNEL_CONFIG               = Kernel defconfig
+ #   TARGET_KERNEL_VARIANT_CONFIG       = Variant defconfig, optional
+ #   TARGET_KERNEL_SELINUX_CONFIG       = SELinux defconfig, optional
+ #   TARGET_KERNEL_ADDITIONAL_CONFIG    = Additional defconfig, optional
++#   TARGET_KERNEL_ARCH                 = Kernel Arch
++#   TARGET_KERNEL_CROSS_COMPILE_PREFIX = Compiler prefix (e.g. arm-eabi-)
++#                                          defaults to arm-linux-androidkernel- for arm
++#                                                      aarch64-linux-androidkernel- for arm64
++#                                                      x86_64-linux-androidkernel- for x86
+ #
+ #   TARGET_KERNEL_CLANG_COMPILE        = Compile kernel with clang, defaults to false
+ #
+@@ -41,6 +47,13 @@
+ #                                          For example, for ARM devices,
+ #                                          use zImage-dtb instead of zImage.
+ #
++#   KERNEL_TOOLCHAIN_PREFIX            = Overrides TARGET_KERNEL_CROSS_COMPILE_PREFIX,
++#                                          Set this var in shell to override
++#                                          toolchain specified in BoardConfig.mk
++#   KERNEL_TOOLCHAIN                   = Path to toolchain, if unset, assumes
++#                                          TARGET_KERNEL_CROSS_COMPILE_PREFIX
++#                                          is in PATH
++#
+ #   KERNEL_CC                          = The C Compiler used. This is automatically set based
+ #                                          on whether the clang version is set, optional.
+ #
+@@ -49,6 +62,8 @@
+ #                                                      aarch64-linux-gnu- for arm64
+ #                                                      x86_64-linux-gnu- for x86
+ #
++#   USE_CCACHE                         = Enable ccache (global Android flag)
++#
+ #   NEED_KERNEL_MODULE_ROOT            = Optional, if true, install kernel
+ #                                          modules in root instead of vendor
+ #   NEED_KERNEL_MODULE_SYSTEM          = Optional, if true, install kernel
+@@ -56,7 +71,11 @@
+ 
+ ifneq ($(TARGET_NO_KERNEL),true)
+ 
++TARGET_AUTO_KDIR := $(shell echo $(TARGET_DEVICE_DIR) | sed -e 's/^device/kernel/g')
++
+ ## Externally influenced variables
++# kernel location - optional, defaults to kernel/<vendor>/<device>
++TARGET_KERNEL_SOURCE ?= $(TARGET_AUTO_KDIR)
+ KERNEL_SRC := $(TARGET_KERNEL_SOURCE)
+ # kernel configuration - mandatory
+ KERNEL_DEFCONFIG := $(TARGET_KERNEL_CONFIG)
+@@ -67,6 +86,13 @@ SELINUX_DEFCONFIG := $(TARGET_KERNEL_SELINUX_CONFIG)
+ KERNEL_OUT := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
+ KERNEL_CONFIG := $(KERNEL_OUT)/.config
+ 
++TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH))
++ifeq ($(TARGET_KERNEL_ARCH),)
++KERNEL_ARCH := $(TARGET_ARCH)
++else
++KERNEL_ARCH := $(TARGET_KERNEL_ARCH)
++endif
++
+ ifeq ($(KERNEL_ARCH),x86_64)
+ KERNEL_DEFCONFIG_ARCH := x86
+ else
+@@ -85,6 +111,19 @@ $(error TARGET_KERNEL_APPEND_DTB is deprecated.)
+ endif
+ TARGET_PREBUILT_INT_KERNEL := $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/$(BOARD_KERNEL_IMAGE_NAME)
+ 
++# Clear this first to prevent accidental poisoning from env
++MAKE_FLAGS :=
++
++ifeq ($(KERNEL_ARCH),arm)
++  # Avoid "Unknown symbol _GLOBAL_OFFSET_TABLE_" errors
++  MAKE_FLAGS += CFLAGS_MODULE="-fno-pic"
++endif
++
++ifeq ($(KERNEL_ARCH),arm64)
++  # Avoid "unsupported RELA relocation: 311" errors (R_AARCH64_ADR_GOT_PAGE)
++  MAKE_FLAGS += CFLAGS_MODULE="-fno-pic"
++endif
++
+ ifneq ($(TARGET_KERNEL_ADDITIONAL_CONFIG),)
+ KERNEL_ADDITIONAL_CONFIG := $(TARGET_KERNEL_ADDITIONAL_CONFIG)
+ KERNEL_ADDITIONAL_CONFIG_SRC := $(KERNEL_SRC)/arch/$(KERNEL_ARCH)/configs/$(KERNEL_ADDITIONAL_CONFIG)
+@@ -96,6 +135,16 @@ else
+     KERNEL_ADDITIONAL_CONFIG_SRC := /dev/null
+ endif
+ 
++## Do be discontinued in a future version. Notify builder about target
++## kernel format requirement
++ifeq ($(BOARD_KERNEL_IMAGE_NAME),)
++ifeq ($(BOARD_USES_UBOOT),true)
++        $(error "Please set BOARD_KERNEL_IMAGE_NAME to uImage")
++else ifeq ($(BOARD_USES_UNCOMPRESSED_BOOT),true)
++        $(error "Please set BOARD_KERNEL_IMAGE_NAME to Image")
++endif
++endif
++
+ ifeq "$(wildcard $(KERNEL_SRC) )" ""
+     ifneq ($(TARGET_PREBUILT_KERNEL),)
+         HAS_PREBUILT_KERNEL := true
+@@ -114,6 +163,7 @@ ifeq "$(wildcard $(KERNEL_SRC) )" ""
+         $(warning * THIS IS DEPRECATED, AND WILL BE DISCONTINUED                *)
+         $(warning * Please configure your device to download the kernel         *)
+         $(warning * source repository to $(KERNEL_SRC))
++        $(warning * See http://wiki.cyanogenmod.org/w/Doc:_integrated_kernel_building)
+         $(warning * for more information                                        *)
+         $(warning ***************************************************************)
+         FULL_KERNEL_BUILD := false
+@@ -171,6 +221,27 @@ KERNEL_DEPMOD_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendo
+ KERNEL_MODULE_MOUNTPOINT := vendor
+ endif
+ 
++TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(strip $(TARGET_KERNEL_CROSS_COMPILE_PREFIX))
++ifneq ($(TARGET_KERNEL_CROSS_COMPILE_PREFIX),)
++KERNEL_TOOLCHAIN_PREFIX ?= $(TARGET_KERNEL_CROSS_COMPILE_PREFIX)
++else ifeq ($(KERNEL_ARCH),arm64)
++KERNEL_TOOLCHAIN_PREFIX ?= aarch64-linux-androidkernel-
++else ifeq ($(KERNEL_ARCH),arm)
++KERNEL_TOOLCHAIN_PREFIX ?= arm-linux-androidkernel-
++else ifeq ($(KERNEL_ARCH),x86)
++KERNEL_TOOLCHAIN_PREFIX ?= x86_64-linux-androidkernel-
++endif
++
++ifeq ($(KERNEL_TOOLCHAIN),)
++KERNEL_TOOLCHAIN_PATH := $(KERNEL_TOOLCHAIN_PREFIX)
++else
++ifneq ($(KERNEL_TOOLCHAIN_PREFIX),)
++KERNEL_TOOLCHAIN_PATH := $(KERNEL_TOOLCHAIN)/$(KERNEL_TOOLCHAIN_PREFIX)
++endif
++endif
++
++BUILD_TOP := $(shell pwd)
++
+ ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
+     ifneq ($(TARGET_KERNEL_CLANG_VERSION),)
+         # Find the clang-* directory containing the specified version
+@@ -187,9 +258,38 @@ ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
+     else ifeq ($(KERNEL_ARCH),x86)
+         KERNEL_CLANG_TRIPLE ?= CLANG_TRIPLE=x86_64-linux-gnu-
+     endif
++endif
++
++ifneq ($(USE_CCACHE),)
++    # Detect if the system already has ccache installed to use instead of the prebuilt
++    ccache := $(shell which ccache)
++
++    ifeq ($(ccache),)
++        ccache := $(BUILD_TOP)/prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache
++        # Check that the executable is here.
++        ccache := $(strip $(wildcard $(ccache)))
++    endif
++endif
++
++ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
++    KERNEL_CROSS_COMPILE := CROSS_COMPILE="$(KERNEL_TOOLCHAIN_PATH)"
+     ifeq ($(KERNEL_CC),)
+-        KERNEL_CC := CC="$(CCACHE_BIN) $(TARGET_KERNEL_CLANG_PATH)/clang"
++        KERNEL_CC := CC="$(ccache) $(TARGET_KERNEL_CLANG_PATH)/clang"
+     endif
++else
++    KERNEL_CROSS_COMPILE := CROSS_COMPILE="$(ccache) $(KERNEL_TOOLCHAIN_PATH)"
++endif
++
++# Needed for CONFIG_COMPAT_VDSO, safe to set for all arm64 builds
++ifeq ($(KERNEL_ARCH),arm64)
++   KERNEL_CROSS_COMPILE += CROSS_COMPILE_ARM32="arm-linux-androideabi-"
++endif
++
++ccache =
++
++ifeq ($(HOST_OS),darwin)
++  MAKE_FLAGS += C_INCLUDE_PATH=$(BUILD_TOP)/external/elfutils/libelf:/usr/local/opt/openssl/include
++  MAKE_FLAGS += LIBRARY_PATH=/usr/local/opt/openssl/lib
+ endif
+ 
+ ifeq ($(TARGET_KERNEL_MODULES),)
+@@ -205,7 +305,7 @@ $(KERNEL_ADDITIONAL_CONFIG_OUT): force_additional_config
+ $(KERNEL_CONFIG): $(KERNEL_DEFCONFIG_SRC) $(KERNEL_ADDITIONAL_CONFIG_OUT)
+ 	@echo "Building Kernel Config"
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+-	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG)
++	$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) VARIANT_DEFCONFIG=$(VARIANT_DEFCONFIG) SELINUX_DEFCONFIG=$(SELINUX_DEFCONFIG) $(KERNEL_DEFCONFIG)
+ 	$(hide) if [ ! -z "$(KERNEL_CONFIG_OVERRIDE)" ]; then \
+ 			echo "Overriding kernel config with '$(KERNEL_CONFIG_OVERRIDE)'"; \
+ 			echo $(KERNEL_CONFIG_OVERRIDE) >> $(KERNEL_OUT)/.config; \
+@@ -223,21 +323,21 @@ TARGET_KERNEL_BINARIES: $(KERNEL_CONFIG)
+ 	$(hide) rm -rf $(KERNEL_MODULES_OUT)
+ 	$(hide) mkdir -p $(KERNEL_MODULES_OUT)
+ 	$(hide) rm -rf $(KERNEL_DEPMOD_STAGING_DIR)
+-	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(BOARD_KERNEL_IMAGE_NAME)
++	$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(BOARD_KERNEL_IMAGE_NAME)
+ 	$(hide) if grep -q '^CONFIG_OF=y' $(KERNEL_CONFIG); then \
+ 			echo "Building DTBs"; \
+-			$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbs; \
++			$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbs; \
+ 		fi
+ 	$(hide) if grep -q '^CONFIG_MODULES=y' $(KERNEL_CONFIG); then \
+ 			echo "Building Kernel Modules"; \
+-			$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) modules; \
++			$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) modules; \
+ 		fi
+ 
+ .PHONY: INSTALLED_KERNEL_MODULES
+ INSTALLED_KERNEL_MODULES: depmod-host
+ 	$(hide) if grep -q '^CONFIG_MODULES=y' $(KERNEL_CONFIG); then \
+ 			echo "Installing Kernel Modules"; \
+-			$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) INSTALL_MOD_PATH=../../$(KERNEL_MODULES_INSTALL) modules_install && \
++			$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) INSTALL_MOD_PATH=../../$(KERNEL_MODULES_INSTALL) modules_install && \
+ 			mofile=$$(find $(KERNEL_MODULES_OUT) -type f -name modules.order) && \
+ 			mpath=$$(dirname $$mofile) && \
+ 			for f in $$(find $$mpath/kernel -type f -name '*.ko'); do \
+@@ -313,7 +413,7 @@ kernelconfig:  KERNELCONFIG_MODE := menuconfig
+ kernelxconfig: KERNELCONFIG_MODE := xconfig
+ kernelxconfig kernelconfig:
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+-	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
++	$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
+ 	env KCONFIG_NOTIMESTAMP=true \
+ 		 $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNELCONFIG_MODE)
+ 	env KCONFIG_NOTIMESTAMP=true \
+@@ -322,7 +422,7 @@ kernelxconfig kernelconfig:
+ 
+ kernelsavedefconfig:
+ 	$(hide) mkdir -p $(KERNEL_OUT)
+-	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
++	$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
+ 	env KCONFIG_NOTIMESTAMP=true \
+ 		 $(MAKE) -C $(KERNEL_SRC) O=$(KERNEL_OUT) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) savedefconfig
+ 	cp $(KERNEL_OUT)/defconfig $(KERNEL_DEFCONFIG_SRC)
+@@ -337,8 +437,8 @@ endif # FULL_KERNEL_BUILD
+ TARGET_PREBUILT_DTBO = $(PRODUCT_OUT)/dtbo/arch/$(KERNEL_ARCH)/boot/dtbo.img
+ $(TARGET_PREBUILT_DTBO): $(AVBTOOL)
+ 	echo -e ${CL_GRN}"Building DTBO.img"${CL_RST}
+-	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
+-	$(MAKE) $(KERNEL_MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbo.img
++	$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) $(KERNEL_DEFCONFIG)
++	$(MAKE) $(MAKE_FLAGS) -C $(KERNEL_SRC) O=$(PRODUCT_OUT)/dtbo ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(KERNEL_CLANG_TRIPLE) $(KERNEL_CC) dtbo.img
+ 	$(AVBTOOL) add_hash_footer \
+ 		--image $@ \
+ 		--partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
+diff --git a/config/BoardConfigBliss.mk b/config/BoardConfigBliss.mk
+index e38938b..e6102f7 100644
+--- a/config/BoardConfigBliss.mk
++++ b/config/BoardConfigBliss.mk
+@@ -8,8 +8,6 @@ ifeq ($(TARGET_HW_DISK_ENCRYPTION),true)
+     TARGET_CRYPTFS_HW_PATH ?= vendor/qcom/opensource/cryptfs_hw
+ endif
+ 
+-include vendor/bliss/config/BoardConfigKernel.mk
+-
+ ifeq ($(BOARD_USES_QCOM_HARDWARE),true) 
+ include vendor/bliss/config/BoardConfigQcom.mk 
+ endif 
+diff --git a/config/BoardConfigKernel.mk b/config/BoardConfigKernel.mk
+deleted file mode 100644
+index 74f3413..0000000
+--- a/config/BoardConfigKernel.mk
++++ /dev/null
+@@ -1,111 +0,0 @@
+-# Copyright (C) 2018 The LineageOS 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.
+-#
+-#
+-# Kernel build configuration variables
+-# ====================================
+-#
+-# These config vars are usually set in BoardConfig.mk:
+-#
+-#   TARGET_KERNEL_SOURCE               = Kernel source dir, optional, defaults
+-#                                          to kernel/$(TARGET_DEVICE_DIR)
+-#   TARGET_KERNEL_ARCH                 = Kernel Arch
+-#   TARGET_KERNEL_CROSS_COMPILE_PREFIX = Compiler prefix (e.g. arm-eabi-)
+-#                                          defaults to arm-linux-androidkernel- for arm
+-#                                                      aarch64-linux-androidkernel- for arm64
+-#                                                      x86_64-linux-androidkernel- for x86
+-#
+-#   TARGET_KERNEL_CLANG_COMPILE        = Compile kernel with clang, defaults to false
+-#
+-#   KERNEL_TOOLCHAIN_PREFIX            = Overrides TARGET_KERNEL_CROSS_COMPILE_PREFIX,
+-#                                          Set this var in shell to override
+-#                                          toolchain specified in BoardConfig.mk
+-#   KERNEL_TOOLCHAIN                   = Path to toolchain, if unset, assumes
+-#                                          TARGET_KERNEL_CROSS_COMPILE_PREFIX
+-#                                          is in PATH
+-#   USE_CCACHE                         = Enable ccache (global Android flag)
+-
+-BUILD_TOP := $(shell pwd)
+-
+-TARGET_AUTO_KDIR := $(shell echo $(TARGET_DEVICE_DIR) | sed -e 's/^device/kernel/g')
+-TARGET_KERNEL_SOURCE ?= $(TARGET_AUTO_KDIR)
+-ifneq ($(TARGET_PREBUILT_KERNEL),)
+-TARGET_KERNEL_SOURCE :=
+-endif
+-
+-TARGET_KERNEL_ARCH := $(strip $(TARGET_KERNEL_ARCH))
+-ifeq ($(TARGET_KERNEL_ARCH),)
+-KERNEL_ARCH := $(TARGET_ARCH)
+-else
+-KERNEL_ARCH := $(TARGET_KERNEL_ARCH)
+-endif
+-
+-TARGET_KERNEL_CROSS_COMPILE_PREFIX := $(strip $(TARGET_KERNEL_CROSS_COMPILE_PREFIX))
+-ifneq ($(TARGET_KERNEL_CROSS_COMPILE_PREFIX),)
+-KERNEL_TOOLCHAIN_PREFIX ?= $(TARGET_KERNEL_CROSS_COMPILE_PREFIX)
+-else ifeq ($(KERNEL_ARCH),arm64)
+-KERNEL_TOOLCHAIN_PREFIX ?= aarch64-linux-androidkernel-
+-else ifeq ($(KERNEL_ARCH),arm)
+-KERNEL_TOOLCHAIN_PREFIX ?= arm-linux-androidkernel-
+-else ifeq ($(KERNEL_ARCH),x86)
+-KERNEL_TOOLCHAIN_PREFIX ?= x86_64-linux-androidkernel-
+-endif
+-
+-ifeq ($(KERNEL_TOOLCHAIN),)
+-KERNEL_TOOLCHAIN_PATH := $(KERNEL_TOOLCHAIN_PREFIX)
+-else
+-ifneq ($(KERNEL_TOOLCHAIN_PREFIX),)
+-KERNEL_TOOLCHAIN_PATH := $(KERNEL_TOOLCHAIN)/$(KERNEL_TOOLCHAIN_PREFIX)
+-endif
+-endif
+-
+-ifneq ($(USE_CCACHE),)
+-    # Detect if the system already has ccache installed to use instead of the prebuilt
+-    CCACHE_BIN := $(shell which ccache)
+-
+-    ifeq ($(CCACHE_BIN),)
+-        CCACHE_BIN := $(BUILD_TOP)/prebuilts/misc/$(HOST_PREBUILT_TAG)/ccache/ccache
+-        # Check that the executable is here.
+-        CCACHE_BIN := $(strip $(wildcard $(CCACHE_BIN)))
+-    endif
+-endif
+-
+-ifeq ($(TARGET_KERNEL_CLANG_COMPILE),true)
+-    KERNEL_CROSS_COMPILE := CROSS_COMPILE="$(KERNEL_TOOLCHAIN_PATH)"
+-else
+-    KERNEL_CROSS_COMPILE := CROSS_COMPILE="$(CCACHE_BIN) $(KERNEL_TOOLCHAIN_PATH)"
+-endif
+-
+-# Needed for CONFIG_COMPAT_VDSO, safe to set for all arm64 builds
+-ifeq ($(KERNEL_ARCH),arm64)
+-   KERNEL_CROSS_COMPILE += CROSS_COMPILE_ARM32="arm-linux-androidkernel-"
+-endif
+-
+-# Clear this first to prevent accidental poisoning from env
+-KERNEL_MAKE_FLAGS :=
+-
+-ifeq ($(KERNEL_ARCH),arm)
+-  # Avoid "Unknown symbol _GLOBAL_OFFSET_TABLE_" errors
+-  KERNEL_MAKE_FLAGS += CFLAGS_MODULE="-fno-pic"
+-endif
+-
+-ifeq ($(KERNEL_ARCH),arm64)
+-  # Avoid "unsupported RELA relocation: 311" errors (R_AARCH64_ADR_GOT_PAGE)
+-  KERNEL_MAKE_FLAGS += CFLAGS_MODULE="-fno-pic"
+-endif
+-
+-ifeq ($(HOST_OS),darwin)
+-  KERNEL_MAKE_FLAGS += C_INCLUDE_PATH=$(BUILD_TOP)/external/elfutils/libelf:/usr/local/opt/openssl/include
+-  KERNEL_MAKE_FLAGS += LIBRARY_PATH=/usr/local/opt/openssl/lib
+-endif
+-- 
+2.17.1
+
diff --git a/patches/vendor/bliss/0009-skip-dependencies-check-for-Treble-builds.patch b/patches/vendor/bliss/0009-skip-dependencies-check-for-Treble-builds.patch
new file mode 100644
index 0000000..7873cb2
--- /dev/null
+++ b/patches/vendor/bliss/0009-skip-dependencies-check-for-Treble-builds.patch
@@ -0,0 +1,24 @@
+From f38cfa492098d083008249434a99c3f27fbfbe0d Mon Sep 17 00:00:00 2001
+From: Jon West <electrikjesus@gmail.com>
+Date: Thu, 25 Oct 2018 20:56:53 -0400
+Subject: [PATCH 9/9] skip dependencies check for Treble builds
+
+Change-Id: I345095b3e8c7edc1e1f373e71696f9cb309cc599
+---
+ build/tools/roomservice.py | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py
+index c8bcf57..71d510c 100755
+--- a/build/tools/roomservice.py
++++ b/build/tools/roomservice.py
+@@ -313,5 +313,4 @@ if __name__ == '__main__':
+         deps_only = False
+ 
+     if not deps_only:
+-        fetch_device(device)
+-    fetch_dependencies(device)
++        print("This is a Treble build, moving along... nothing to see here")
+-- 
+2.17.1
+