From 80f5aad44cc7dfb44ced2b6900a36389a276fec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Mon, 14 Oct 2019 13:45:00 +0200 Subject: [PATCH 1/2] hybris-patches: rebase on top of android-10.0.0_r1 [hybris-patches] rebase on top of android-10.0.0_r1 --- ...ome-build-errors-to-let-the-systemim.patch | 116 + ..._tls-and-related-functions-Android-8.patch | 61 +- ...pport-for-get-and-list-of-properties.patch | 6 +- ...s.h-shifting-TLS-slots-to-avoid-conf.patch | 58 +- ...ls-usage-in-locale.cpp-to-avoid-prob.patch | 6 +- ...lots-for-x86-Aligns-with-this-libhyb.patch | 63 +- ...bris-don-t-fail-because-of-fsetxattr.patch | 6 +- ...hybris-Reduce-vendorimage-build-size.patch | 56 + ...us-group-to-adbus-to-avoid-conflicts.patch | 27 - ...imization-might-be-improveable-but-t.patch | 1005 ++-- ...le-APEX-check-we-don-t-care-about-it.patch | 26 + ...hybris-Reduce-vendorimage-build-size.patch | 54 - ...ice-is-disabled-in-hybris-adaptation.patch | 49 +- ...ble-some-tests-to-avoid-build-errors.patch | 51 + ...services-and-disable-starting-unneed.patch | 35 +- ...-shared-objects-from-appropriate-pat.patch | 34 +- ...-private-__get_tls_hooks-from-bionic.patch | 12 +- ...faceflinger-to-be-started-from-Sailf.patch | 4147 +---------------- ...e-somehow-missing-settingsd-socket-f.patch | 8 +- ...-float-handling-to-audio-api-headers.patch | 10 +- ...r-libraries-first-from-usr-libexec-d.patch | 22 +- ...-proper-aapcs-attribute-with-functio.patch | 6 +- ...ibexec-droid-hybris-lib-dev-alog-to-.patch | 17 +- ...ate-mount-dev-proc-sys.-when-booting.patch | 61 +- ...pecify-mis-alignment-handling-this-i.patch | 10 +- ...bris-Mount-points-are-handled-by-Mer.patch | 35 +- ...ybris-Systemd-handles-control-groups.patch | 20 +- system/core/0006-hybris-Mer-uses-udev.patch | 16 +- ...ady-trigger-to-init-to-run-post-boot.patch | 12 +- ...Notify-Mer-s-systemd-that-we-re-done.patch | 10 +- .../core/0009-hybris-Disable-usb-import.patch | 8 +- ...llow-system-group-to-trigger-haptics.patch | 10 +- ...rigger-late_start-on-property-change.patch | 12 +- ...service.c-adding-support-for-getprop.patch | 39 +- .../0013-hybris-reach-main-init-state.patch | 34 +- ...etting-hostname-and-domainname-in-in.patch | 10 +- ...hybris-Update-rootdir-for-64bit-libs.patch | 19 +- ...hybris-Disable-all-zygote-variations.patch | 31 +- .../0017-hybris-Disable-ueventd-service.patch | 10 +- system/core/0018-hybris-Disable-SELinux.patch | 41 +- ...is-Properly-handle-shutdown-from-Mer.patch | 10 +- ...ces-from-usr-libexec-droid-hybris-sy.patch | 14 +- ...LD_LIBRARY_PATH-from-init.environ.rc.patch | 19 +- ...-bit-LD_LIBRARY_PATH-for-32-bit-devi.patch | 34 +- ...3-hybris-Fix-list-and-get-properties.patch | 37 +- ...0024-hybris-more-SELinux-disablement.patch | 55 +- ...-try-to-mount-since-mer-handles-this.patch | 20 +- ...empting-to-mount-partitions-mer-syst.patch | 39 +- ...ices-from-droid-hybris-as-early-as-p.patch | 10 +- ...emnants-of-SELinux-which-currently-b.patch | 12 +- ...he-usage-of-libprocessgroup-since-it.patch | 105 +- .../0030-hybris-disable-vendor-symlink.patch | 12 +- ...ount-and-mkdir-tmp-commands-entirely.patch | 16 +- ...actdead-charging-animation.-MER-1949.patch | 14 +- ...ybris-system-core-Disable-usb-config.patch | 17 +- ...4-hybris-Remove-sbin-from-droid-PATH.patch | 17 +- ...x-return-value-type-of-mount-command.patch | 14 +- ...able-some-more-selinux-functionality.patch | 20 +- ...37-hybris-Disable-mnt-tmpfs-creation.patch | 38 +- ...nit_user0-which-is-not-needed-on-Mer.patch | 19 +- .../0039-hybris-Disable-SELinux-init.patch | 174 +- ...nused-code-that-was-disabled-by-priv.patch | 43 + 62 files changed, 1467 insertions(+), 5525 deletions(-) create mode 100644 art/0001-hybris-Silence-some-build-errors-to-let-the-systemim.patch create mode 100644 build/make/0001-hybris-Reduce-vendorimage-build-size.patch delete mode 100644 build/make/0001-hybris-rename-dbus-group-to-adbus-to-avoid-conflicts.patch create mode 100644 build/make/0003-hybris-Disable-APEX-check-we-don-t-care-about-it.patch delete mode 100644 build/make/0003-hybris-Reduce-vendorimage-build-size.patch create mode 100644 frameworks/base/0001-hybris-Disable-some-tests-to-avoid-build-errors.patch create mode 100644 system/core/0040-hybris-Disable-unused-code-that-was-disabled-by-priv.patch diff --git a/art/0001-hybris-Silence-some-build-errors-to-let-the-systemim.patch b/art/0001-hybris-Silence-some-build-errors-to-let-the-systemim.patch new file mode 100644 index 0000000..c494307 --- /dev/null +++ b/art/0001-hybris-Silence-some-build-errors-to-let-the-systemim.patch @@ -0,0 +1,116 @@ +From 3754ab27492f5bdb443429db9af3fc8205caeed7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= +Date: Mon, 21 Oct 2019 07:19:31 +0200 +Subject: [PATCH] (hybris) Silence some build errors to let the systemimage + build +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Previous changes to bionic and the build system removed things that +art depends on. Either remove the parts that create errors or replace +them and insert dummy data to allow the building of the systemimage. + +Change-Id: I5f12c9dd80886896885b0a84667812d966054114 +Signed-off-by: Björn Bidar +--- + build/Android.gtest.mk | 20 ++++++++++---------- + runtime/thread-current-inl.h | 2 +- + runtime/thread.cc | 4 ++-- + runtime/thread_list.cc | 2 +- + 4 files changed, 14 insertions(+), 14 deletions(-) + +diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk +index 03aae07587..20e38df7b2 100644 +--- a/build/Android.gtest.mk ++++ b/build/Android.gtest.mk +@@ -73,28 +73,28 @@ $(foreach dir,$(GTEST_DEX_DIRECTORIES), $(eval $(call build-art-test-dex,art-gte + + # Create rules for MainStripped, a copy of Main with the classes.dex stripped + # for the oat file assistant tests. +-ART_TEST_HOST_GTEST_MainStripped_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))Stripped$(suffix $(ART_TEST_HOST_GTEST_Main_DEX)) +-ART_TEST_TARGET_GTEST_MainStripped_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))Stripped$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX)) ++ART_TEST_HOST_GTEST_MainStripped_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX)) ++ART_TEST_TARGET_GTEST_MainStripped_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX)) + + # Create rules for MainUncompressed, a copy of Main with the classes.dex uncompressed + # for the dex2oat tests. +-ART_TEST_HOST_GTEST_MainUncompressed_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))Uncompressed$(suffix $(ART_TEST_HOST_GTEST_Main_DEX)) +-ART_TEST_TARGET_GTEST_MainUncompressed_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))Uncompressed$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX)) ++ART_TEST_HOST_GTEST_MainUncompressed_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX)) ++ART_TEST_TARGET_GTEST_MainUncompressed_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX)) + + # Create rules for UncompressedEmpty, a classes.dex that is empty and uncompressed + # for the dex2oat tests. +-ART_TEST_HOST_GTEST_EmptyUncompressed_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))EmptyUncompressed$(suffix $(ART_TEST_HOST_GTEST_Main_DEX)) +-ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))EmptyUncompressed$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX)) ++ART_TEST_HOST_GTEST_EmptyUncompressed_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX)) ++ART_TEST_TARGET_GTEST_EmptyUncompressed_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX)) + + # Create rules for UncompressedEmptyAligned, a classes.dex that is empty, uncompressed, + # and 4 byte aligned for the dex2oat tests. +-ART_TEST_HOST_GTEST_EmptyUncompressedAligned_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))EmptyUncompressedAligned$(suffix $(ART_TEST_HOST_GTEST_Main_DEX)) +-ART_TEST_TARGET_GTEST_EmptyUncompressedAligned_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))EmptyUncompressedAligned$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX)) ++ART_TEST_HOST_GTEST_EmptyUncompressedAligned_DEX := $(basename $(ART_TEST_HOST_GTEST_Main_DEX))$(suffix $(ART_TEST_HOST_GTEST_Main_DEX)) ++ART_TEST_TARGET_GTEST_EmptyUncompressedAligned_DEX := $(basename $(ART_TEST_TARGET_GTEST_Main_DEX))$(suffix $(ART_TEST_TARGET_GTEST_Main_DEX)) + + # Create rules for MultiDexUncompressed, a copy of MultiDex with the classes.dex uncompressed + # for the OatFile tests. +-ART_TEST_HOST_GTEST_MultiDexUncompressed_DEX := $(basename $(ART_TEST_HOST_GTEST_MultiDex_DEX))Uncompressed$(suffix $(ART_TEST_HOST_GTEST_MultiDex_DEX)) +-ART_TEST_TARGET_GTEST_MultiDexUncompressed_DEX := $(basename $(ART_TEST_TARGET_GTEST_MultiDex_DEX))Uncompressed$(suffix $(ART_TEST_TARGET_GTEST_MultiDex_DEX)) ++ART_TEST_HOST_GTEST_MultiDexUncompressed_DEX := $(basename $(ART_TEST_HOST_GTEST_MultiDex_DEX))$(suffix $(ART_TEST_HOST_GTEST_MultiDex_DEX)) ++ART_TEST_TARGET_GTEST_MultiDexUncompressed_DEX := $(basename $(ART_TEST_TARGET_GTEST_MultiDex_DEX))(suffix $(ART_TEST_TARGET_GTEST_MultiDex_DEX)) + + ifdef ART_TEST_HOST_GTEST_Main_DEX + $(ART_TEST_HOST_GTEST_MainStripped_DEX): $(ART_TEST_HOST_GTEST_Main_DEX) +diff --git a/runtime/thread-current-inl.h b/runtime/thread-current-inl.h +index 9241b1f875..904a62ccff 100644 +--- a/runtime/thread-current-inl.h ++++ b/runtime/thread-current-inl.h +@@ -34,7 +34,7 @@ inline Thread* Thread::Current() { + return nullptr; + } else { + #ifdef ART_TARGET_ANDROID +- void* thread = __get_tls()[TLS_SLOT_ART_THREAD_SELF]; ++ void* thread = __get_tls()[99]; + #else + void* thread = pthread_getspecific(Thread::pthread_key_self_); + #endif +diff --git a/runtime/thread.cc b/runtime/thread.cc +index 70ed7c8038..dcfbb7926d 100644 +--- a/runtime/thread.cc ++++ b/runtime/thread.cc +@@ -933,7 +933,7 @@ bool Thread::Init(ThreadList* thread_list, JavaVMExt* java_vm, JNIEnvExt* jni_en + } + + #ifdef ART_TARGET_ANDROID +- __get_tls()[TLS_SLOT_ART_THREAD_SELF] = this; ++ __get_tls()[99] = this; + #else + CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, this), "attach self"); + #endif +@@ -2196,7 +2196,7 @@ void Thread::ThreadExitCallback(void* arg) { + "going to use a pthread_key_create destructor?): " << *self; + CHECK(is_started_); + #ifdef ART_TARGET_ANDROID +- __get_tls()[TLS_SLOT_ART_THREAD_SELF] = self; ++ __get_tls()[99] = self; + #else + CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, self), "reattach self"); + #endif +diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc +index ed6b2c91e5..06e6f6585b 100644 +--- a/runtime/thread_list.cc ++++ b/runtime/thread_list.cc +@@ -1482,7 +1482,7 @@ void ThreadList::Unregister(Thread* self) { + // Clear the TLS data, so that the underlying native thread is recognizably detached. + // (It may wish to reattach later.) + #ifdef ART_TARGET_ANDROID +- __get_tls()[TLS_SLOT_ART_THREAD_SELF] = nullptr; ++ __get_tls()[99] = nullptr; + #else + CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, nullptr), "detach self"); + #endif +-- +2.23.0 + diff --git a/bionic/0001-hybris-Fix-__get_tls-and-related-functions-Android-8.patch b/bionic/0001-hybris-Fix-__get_tls-and-related-functions-Android-8.patch index 5abff6d..847631b 100644 --- a/bionic/0001-hybris-Fix-__get_tls-and-related-functions-Android-8.patch +++ b/bionic/0001-hybris-Fix-__get_tls-and-related-functions-Android-8.patch @@ -1,4 +1,4 @@ -From 37ff1a6589ca177efdeff77ca046f52074f0bc43 Mon Sep 17 00:00:00 2001 +From fc8a37731d84333173eebf09ec54bcbc86904d3f Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Thu, 1 Feb 2018 00:57:52 +0000 Subject: [PATCH 1/6] (hybris) Fix __get_tls and related functions (>=Android @@ -7,17 +7,15 @@ Subject: [PATCH 1/6] (hybris) Fix __get_tls and related functions (>=Android Change-Id: If75e4ae739ec6c482a68b1b69c2130535add2279 Signed-off-by: Simonas Leleiva --- - libc/bionic/ndk_cruft.cpp | 18 ++++++++----- - libc/libc.arm.map | 1 + - libc/libc.arm64.map | 1 + - libc/libc.x86.map | 1 + - libc/private/__get_tls.h | 30 ++++++++-------------- - libc/private/__get_tls_internal.h | 54 +++++++++++++++++++++++++++++++++++++++ - 6 files changed, 80 insertions(+), 25 deletions(-) + libc/bionic/ndk_cruft.cpp | 18 +++++++---- + libc/libc.map.txt | 1 + + libc/private/__get_tls.h | 31 +++++++----------- + libc/private/__get_tls_internal.h | 54 +++++++++++++++++++++++++++++++ + 4 files changed, 79 insertions(+), 25 deletions(-) create mode 100644 libc/private/__get_tls_internal.h diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp -index dbacf18..7fe91ed 100644 +index 2c3299f7b..637e3dfa1 100644 --- a/libc/bionic/ndk_cruft.cpp +++ b/libc/bionic/ndk_cruft.cpp @@ -49,6 +49,18 @@ @@ -52,47 +50,23 @@ index dbacf18..7fe91ed 100644 // This non-standard function was in our for some reason. void memswap(void* m1, void* m2, size_t n) { char* p = reinterpret_cast(m1); -diff --git a/libc/libc.arm.map b/libc/libc.arm.map -index b0f96a9..d896aa6 100644 ---- a/libc/libc.arm.map -+++ b/libc/libc.arm.map -@@ -1519,6 +1519,7 @@ LIBC_PRIVATE { - __gedf2; # arm +diff --git a/libc/libc.map.txt b/libc/libc.map.txt +index 88192239a..060f28387 100644 +--- a/libc/libc.map.txt ++++ b/libc/libc.map.txt +@@ -1593,6 +1593,7 @@ LIBC_PRIVATE { + __gesf2; # arm __get_thread; # arm x86 mips __get_tls; # arm x86 mips + __get_tls_hooks; # hybris __getdents64; # arm x86 mips __gnu_ldivmod_helper; # arm __gnu_uldivmod_helper; # arm -diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map -index 6b0e415..631db17 100644 ---- a/libc/libc.arm64.map -+++ b/libc/libc.arm64.map -@@ -1342,6 +1342,7 @@ LIBC_P { # introduced=P - - LIBC_PRIVATE { - global: -+ __get_tls_hooks; # hybris - android_getaddrinfofornet; - android_getaddrinfofornetcontext; - android_gethostbyaddrfornet; -diff --git a/libc/libc.x86.map b/libc/libc.x86.map -index 2855f9e..13e95a2 100644 ---- a/libc/libc.x86.map -+++ b/libc/libc.x86.map -@@ -1411,6 +1411,7 @@ LIBC_PRIVATE { - __futex_wake; # arm x86 mips - __get_thread; # arm x86 mips - __get_tls; # arm x86 mips -+ __get_tls_hooks; # hybris - __getdents64; # arm x86 mips - __open; # arm x86 mips - __page_shift; # arm x86 mips diff --git a/libc/private/__get_tls.h b/libc/private/__get_tls.h -index 04c5fdb..9f37b01 100644 +index 04c5fdbbf..6a4b5728e 100644 --- a/libc/private/__get_tls.h +++ b/libc/private/__get_tls.h -@@ -29,25 +29,17 @@ +@@ -29,25 +29,18 @@ #ifndef __BIONIC_PRIVATE_GET_TLS_H_ #define __BIONIC_PRIVATE_GET_TLS_H_ @@ -127,11 +101,12 @@ index 04c5fdb..9f37b01 100644 +#include "__get_tls_internal.h" + +//#define __get_tls __get_tls_hooks ++ #endif /* __BIONIC_PRIVATE_GET_TLS_H_ */ diff --git a/libc/private/__get_tls_internal.h b/libc/private/__get_tls_internal.h new file mode 100644 -index 0000000..4a8fa5f +index 000000000..4a8fa5fc2 --- /dev/null +++ b/libc/private/__get_tls_internal.h @@ -0,0 +1,54 @@ @@ -190,5 +165,5 @@ index 0000000..4a8fa5f +#endif /* __BIONIC_PRIVATE_GET_TLS_INTERNAL_H_ */ + -- -2.7.4 +2.23.0 diff --git a/bionic/0002-hybris-Add-support-for-get-and-list-of-properties.patch b/bionic/0002-hybris-Add-support-for-get-and-list-of-properties.patch index f9b6faa..43f09f4 100644 --- a/bionic/0002-hybris-Add-support-for-get-and-list-of-properties.patch +++ b/bionic/0002-hybris-Add-support-for-get-and-list-of-properties.patch @@ -1,4 +1,4 @@ -From d6b0d88fd16ed59bc56d0d1fa41b054686fc1f81 Mon Sep 17 00:00:00 2001 +From e710725eb69970ed73c47e2e037908f179a15a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Sun, 17 Dec 2017 00:16:16 +0200 Subject: [PATCH 2/6] (hybris) Add support for get and list of properties. @@ -9,7 +9,7 @@ Change-Id: I089a2a146c06d8ad0c234f0a9a4b5aa07beaeed5 1 file changed, 2 insertions(+) diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h -index 67beb9a..d547585 100644 +index 744a45b71..2f32bc28f 100644 --- a/libc/include/sys/_system_properties.h +++ b/libc/include/sys/_system_properties.h @@ -44,6 +44,8 @@ __BEGIN_DECLS @@ -22,5 +22,5 @@ index 67beb9a..d547585 100644 #define PROP_SUCCESS 0 -- -2.7.4 +2.23.0 diff --git a/bionic/0003-hybris-bionic_tls.h-shifting-TLS-slots-to-avoid-conf.patch b/bionic/0003-hybris-bionic_tls.h-shifting-TLS-slots-to-avoid-conf.patch index ee9d18d..a10706b 100644 --- a/bionic/0003-hybris-bionic_tls.h-shifting-TLS-slots-to-avoid-conf.patch +++ b/bionic/0003-hybris-bionic_tls.h-shifting-TLS-slots-to-avoid-conf.patch @@ -1,4 +1,4 @@ -From 5b22181f0316b519b1712b1f291d2f83bccba640 Mon Sep 17 00:00:00 2001 +From 265be0718cd40ec8edd3e014b3a7501174bafbb4 Mon Sep 17 00:00:00 2001 From: Ricardo Salveti de Araujo Date: Thu, 9 Jan 2014 00:57:01 -0200 Subject: [PATCH 3/6] (hybris) bionic_tls.h: shifting TLS slots to avoid @@ -10,38 +10,32 @@ Signed-off-by: Ricardo Salveti de Araujo Conflicts: libc/private/bionic_tls.h --- - libc/private/bionic_tls.h | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) + libc/private/bionic_asm_tls.h | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) -diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h -index de086f2..af4d4d0 100644 ---- a/libc/private/bionic_tls.h -+++ b/libc/private/bionic_tls.h -@@ -56,12 +56,12 @@ __BEGIN_DECLS - enum { - TLS_SLOT_SELF = 0, // The kernel requires this specific slot for x86. - TLS_SLOT_THREAD_ID, -- TLS_SLOT_ERRNO, -+ TLS_SLOT_ERRNO = 5, +diff --git a/libc/private/bionic_asm_tls.h b/libc/private/bionic_asm_tls.h +index 92f707aad..40e6a5394 100644 +--- a/libc/private/bionic_asm_tls.h ++++ b/libc/private/bionic_asm_tls.h +@@ -84,12 +84,12 @@ + #define TLS_SLOT_BIONIC_TLS -1 + #define TLS_SLOT_DTV 0 + #define TLS_SLOT_THREAD_ID 1 +-#define TLS_SLOT_APP 2 // was historically used for errno +-#define TLS_SLOT_OPENGL 3 +-#define TLS_SLOT_OPENGL_API 4 +-#define TLS_SLOT_STACK_GUARD 5 +-#define TLS_SLOT_SANITIZER 6 // was historically used for dlerror +-#define TLS_SLOT_ART_THREAD_SELF 7 ++#define TLS_SLOT_APP // was historically used for errno ++#define TLS_SLOT_OPENGL 2 ++#define TLS_SLOT_OPENGL_API 5 ++#define TLS_SLOT_STACK_GUARD 6 ++#define TLS_SLOT_SANITIZER 7 // was historically used for dlerror ++#define TLS_SLOT_ART_THREAD_SELF - // These two aren't used by bionic itself, but allow the graphics code to - // access TLS directly rather than using the pthread API. -- TLS_SLOT_OPENGL_API = 3, -- TLS_SLOT_OPENGL = 4, -+ TLS_SLOT_OPENGL_API = 6, -+ TLS_SLOT_OPENGL = 7, - - // This slot is only used to pass information from the dynamic linker to - // libc.so when the C library is loaded in to memory. The C runtime init -@@ -69,7 +69,7 @@ enum { - // we reuse an existing location that isn't needed during libc startup. - TLS_SLOT_BIONIC_PREINIT = TLS_SLOT_OPENGL_API, - -- TLS_SLOT_STACK_GUARD = 5, // GCC requires this specific slot for x86. -+ TLS_SLOT_STACK_GUARD = 8, // GCC requires this specific slot for x86. - TLS_SLOT_DLERROR, - - // Fast storage for Thread::Current() in ART. + // The maximum slot is fixed by the minimum TLS alignment in Bionic executables. + #define MAX_TLS_SLOT 7 -- -2.7.4 +2.23.0 diff --git a/bionic/0004-hybris-disable-tls-usage-in-locale.cpp-to-avoid-prob.patch b/bionic/0004-hybris-disable-tls-usage-in-locale.cpp-to-avoid-prob.patch index ffe8f03..d7fc14d 100644 --- a/bionic/0004-hybris-disable-tls-usage-in-locale.cpp-to-avoid-prob.patch +++ b/bionic/0004-hybris-disable-tls-usage-in-locale.cpp-to-avoid-prob.patch @@ -1,4 +1,4 @@ -From 78c3feee4abb30c1ddcb43c9d0dadd9b53872f54 Mon Sep 17 00:00:00 2001 +From 48e009cf11f2041d662ad597b3c73a044188fdc4 Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Wed, 18 Apr 2018 18:37:09 +0200 Subject: [PATCH 4/6] (hybris) disable tls usage in locale.cpp, to avoid @@ -11,7 +11,7 @@ Signed-off-by: Simonas Leleiva 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libc/bionic/locale.cpp b/libc/bionic/locale.cpp -index 08c9401..52af6da 100644 +index 8358fb0ab..8def0e164 100644 --- a/libc/bionic/locale.cpp +++ b/libc/bionic/locale.cpp @@ -37,11 +37,11 @@ @@ -31,5 +31,5 @@ index 08c9401..52af6da 100644 #if USE_TLS_SLOT #include "bionic/pthread_internal.h" -- -2.7.4 +2.23.0 diff --git a/bionic/0005-hybris-Fix-TLS-slots-for-x86-Aligns-with-this-libhyb.patch b/bionic/0005-hybris-Fix-TLS-slots-for-x86-Aligns-with-this-libhyb.patch index 0fc46b1..eeefc92 100644 --- a/bionic/0005-hybris-Fix-TLS-slots-for-x86-Aligns-with-this-libhyb.patch +++ b/bionic/0005-hybris-Fix-TLS-slots-for-x86-Aligns-with-this-libhyb.patch @@ -1,4 +1,4 @@ -From 829c9f20e760085a4c5872f6f1292c8d0e418e57 Mon Sep 17 00:00:00 2001 +From 8e7d6a5468060dd647fec9b52dfb4f19dbdc39ba Mon Sep 17 00:00:00 2001 From: Ilya Bizyaev Date: Sat, 20 Jan 2018 17:48:27 +0300 Subject: [PATCH 5/6] (hybris) Fix TLS slots for x86 Aligns with this libhybris @@ -6,43 +6,32 @@ Subject: [PATCH 5/6] (hybris) Fix TLS slots for x86 Aligns with this libhybris Change-Id: Ibdbfa1c1672cbac5a687afdedbb1d8ff05861f4f --- - libc/private/bionic_tls.h | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) + libc/private/bionic_asm_tls.h | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) -diff --git a/libc/private/bionic_tls.h b/libc/private/bionic_tls.h -index af4d4d0..07590f6 100644 ---- a/libc/private/bionic_tls.h -+++ b/libc/private/bionic_tls.h -@@ -56,12 +56,16 @@ __BEGIN_DECLS - enum { - TLS_SLOT_SELF = 0, // The kernel requires this specific slot for x86. - TLS_SLOT_THREAD_ID, -- TLS_SLOT_ERRNO = 5, -+ -+ TLS_SLOT_STACK_GUARD = 5, // GCC requires this specific slot for x86. -+ -+ TLS_SLOT_ERRNO, - - // These two aren't used by bionic itself, but allow the graphics code to - // access TLS directly rather than using the pthread API. -- TLS_SLOT_OPENGL_API = 6, -- TLS_SLOT_OPENGL = 7, -+ TLS_SLOT_OPENGL_API, -+ TLS_SLOT_OPENGL, -+ TLS_SLOT_DLERROR, - - // This slot is only used to pass information from the dynamic linker to - // libc.so when the C library is loaded in to memory. The C runtime init -@@ -69,9 +73,6 @@ enum { - // we reuse an existing location that isn't needed during libc startup. - TLS_SLOT_BIONIC_PREINIT = TLS_SLOT_OPENGL_API, - -- TLS_SLOT_STACK_GUARD = 8, // GCC requires this specific slot for x86. -- TLS_SLOT_DLERROR, -- - // Fast storage for Thread::Current() in ART. - TLS_SLOT_ART_THREAD_SELF, +diff --git a/libc/private/bionic_asm_tls.h b/libc/private/bionic_asm_tls.h +index 40e6a5394..07ded2005 100644 +--- a/libc/private/bionic_asm_tls.h ++++ b/libc/private/bionic_asm_tls.h +@@ -104,12 +104,12 @@ + #define TLS_SLOT_SELF 0 + #define TLS_SLOT_THREAD_ID 1 +-#define TLS_SLOT_APP 2 // was historically used for errno +-#define TLS_SLOT_OPENGL 3 +-#define TLS_SLOT_OPENGL_API 4 +-#define TLS_SLOT_STACK_GUARD 5 +-#define TLS_SLOT_SANITIZER 6 // was historically used for dlerror +-#define TLS_SLOT_ART_THREAD_SELF 7 ++#define TLS_SLOT_APP // was historically used for errno ++#define TLS_SLOT_OPENGL 2 ++#define TLS_SLOT_OPENGL_API 5 ++#define TLS_SLOT_STACK_GUARD 6 ++#define TLS_SLOT_SANITIZER 7 // was historically used for dlerror ++#define TLS_SLOT_ART_THREAD_SELF + #define TLS_SLOT_DTV 8 + #define TLS_SLOT_BIONIC_TLS 9 + #define MAX_TLS_SLOT 9 // update this value when reserving a slot -- -2.7.4 +2.23.0 diff --git a/bionic/0006-hybris-don-t-fail-because-of-fsetxattr.patch b/bionic/0006-hybris-don-t-fail-because-of-fsetxattr.patch index 0c82941..e59dcfc 100644 --- a/bionic/0006-hybris-don-t-fail-because-of-fsetxattr.patch +++ b/bionic/0006-hybris-don-t-fail-because-of-fsetxattr.patch @@ -1,4 +1,4 @@ -From f0cc4b60fd962a9f220b3a393558226901f3f83e Mon Sep 17 00:00:00 2001 +From ed1d2fb125692caeddf8dda361350d72ca043bbf Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Thu, 28 Mar 2019 13:10:48 -0400 Subject: [PATCH 6/6] (hybris) don't fail because of fsetxattr @@ -9,7 +9,7 @@ Change-Id: I4d765ff401d6b4f12da0305416cb751eb0c9e96b 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/system_properties/prop_area.cpp b/libc/system_properties/prop_area.cpp -index 42bee9f..04be162 100644 +index 42bee9f3e..04be16230 100644 --- a/libc/system_properties/prop_area.cpp +++ b/libc/system_properties/prop_area.cpp @@ -79,7 +79,7 @@ prop_area* prop_area::map_prop_area_rw(const char* filename, const char* context @@ -22,5 +22,5 @@ index 42bee9f..04be162 100644 } } -- -2.7.4 +2.23.0 diff --git a/build/make/0001-hybris-Reduce-vendorimage-build-size.patch b/build/make/0001-hybris-Reduce-vendorimage-build-size.patch new file mode 100644 index 0000000..93c5695 --- /dev/null +++ b/build/make/0001-hybris-Reduce-vendorimage-build-size.patch @@ -0,0 +1,56 @@ +From e29b091d694c1dc30915455dddcd8d4fdb106b41 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= +Date: Fri, 22 Mar 2019 18:36:56 +0200 +Subject: [PATCH 1/3] (hybris) Reduce vendorimage build size. + +Change-Id: Id025a7d7c81cb19c2881ff6619084b638ce983fb +--- + core/Makefile | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/core/Makefile b/core/Makefile +index 4611fb388..c0cc99793 100644 +--- a/core/Makefile ++++ b/core/Makefile +@@ -19,6 +19,7 @@ $(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \ + Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) + endef + # filter out the duplicate : pairs. ++ALL_PRODUCT_COPY_FILES := + unique_product_copy_files_pairs := + $(foreach cf,$(PRODUCT_COPY_FILES), \ + $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\ +@@ -39,6 +40,7 @@ $(foreach cf,$(unique_product_copy_files_pairs), \ + $(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init,$(dir $(_dest))),\ + $(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\ + $(eval $(call copy-one-file,$(_src),$(_fulldest)))))) \ ++ $(eval ALL_PRODUCT_COPY_FILES += $(_fulldest)) \ + $(eval unique_product_copy_files_destinations += $(_dest)))) + + # Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries) +@@ -2397,6 +2399,12 @@ $(pdk_odex_config_mk) : + PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)) + INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip + ++INTERNAL_VENDORIMAGE_KERNEL_MODULES := \ ++ $(filter $(TARGET_OUT_VENDOR)/lib/modules/%,\ ++ $(ALL_DEFAULT_INSTALLED_MODULES)\ ++ $(ALL_PDK_FUSION_FILES)) ++ ++ + $(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex) + $(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk) + $(INSTALLED_PLATFORM_ZIP) : $(SOONG_ZIP) +@@ -2824,8 +2832,7 @@ INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET) + ifdef BUILT_VENDOR_MANIFEST + $(INSTALLED_VENDORIMAGE_TARGET): $(BUILT_ASSEMBLED_VENDOR_MANIFEST) + endif +-$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR) $(BUILD_IMAGE_SRCS) $(DEPMOD) $(BOARD_VENDOR_KERNEL_MODULES) +- $(build-vendorimage-target) ++$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(ALL_PRODUCT_COPY_FILES) $(INTERNAL_VENDORIMAGE_KERNEL_MODULES) $(BUILD_IMAGE_SRCS) $(DEPMOD) $(BOARD_VENDOR_KERNEL_MODULES) + + .PHONY: vendorimage-nodeps vnod + vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS) $(DEPMOD) +-- +2.23.0 + diff --git a/build/make/0001-hybris-rename-dbus-group-to-adbus-to-avoid-conflicts.patch b/build/make/0001-hybris-rename-dbus-group-to-adbus-to-avoid-conflicts.patch deleted file mode 100644 index f14ae47..0000000 --- a/build/make/0001-hybris-rename-dbus-group-to-adbus-to-avoid-conflicts.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 20db53a968e052d3492674fb5fefd8a785405ad4 Mon Sep 17 00:00:00 2001 -From: Franz-Josef Haider -Date: Thu, 30 Aug 2018 14:42:07 +0200 -Subject: [PATCH 1/3] (hybris) rename dbus group to adbus to avoid conflicts - with mer. - ---- - tools/fs_config/fs_config_generator.py | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/tools/fs_config/fs_config_generator.py b/tools/fs_config/fs_config_generator.py -index 4839578..9dcf19a 100755 ---- a/tools/fs_config/fs_config_generator.py -+++ b/tools/fs_config/fs_config_generator.py -@@ -135,7 +135,8 @@ class AID(object): - _FIXUPS = { - 'media_drm': 'mediadrm', - 'media_ex': 'mediaex', -- 'media_codec': 'mediacodec' -+ 'media_codec': 'mediacodec', -+ 'dbus': 'adbus' - } - - def __init__(self, identifier, value, found): --- -2.7.4 - diff --git a/build/make/0002-hybris-build-minimization-might-be-improveable-but-t.patch b/build/make/0002-hybris-build-minimization-might-be-improveable-but-t.patch index 51d1535..842c4f9 100644 --- a/build/make/0002-hybris-build-minimization-might-be-improveable-but-t.patch +++ b/build/make/0002-hybris-build-minimization-might-be-improveable-but-t.patch @@ -1,4 +1,4 @@ -From 1dba61e7803e8f88b8edf58b990f1af8616e61b7 Mon Sep 17 00:00:00 2001 +From 0135270cfe3fb8d78f5807ac5afd0b746186a99c Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Thu, 7 Jun 2018 15:32:40 +0000 Subject: [PATCH 2/3] (hybris) build minimization (might be improveable, but @@ -6,53 +6,31 @@ Subject: [PATCH 2/3] (hybris) build minimization (might be improveable, but Change-Id: Ic862dc084f5f4e3fa7ccd90b0757deff0f17b802 --- - core/dex_preopt.mk | 109 +--------- - core/droiddoc.mk | 368 +------------------------------- - core/host_dalvik_java_library.mk | 225 +------------------ - core/host_dalvik_static_java_library.mk | 29 +-- - core/java_library.mk | 105 +-------- - core/main.mk | 3 + - core/package.mk | 85 +------- - core/static_java_library.mk | 238 +-------------------- - 8 files changed, 10 insertions(+), 1152 deletions(-) - mode change 100644 => 120000 core/dex_preopt.mk - mode change 100644 => 120000 core/droiddoc.mk - mode change 100644 => 120000 core/host_dalvik_java_library.mk - mode change 100644 => 120000 core/host_dalvik_static_java_library.mk - mode change 100644 => 120000 core/java_library.mk - mode change 100644 => 120000 core/package.mk - mode change 100644 => 120000 core/static_java_library.mk + core/dex_preopt.mk | 49 ----- + core/envsetup.mk | 4 +- + core/host_dalvik_java_library.mk | 191 ------------------ + core/host_dalvik_static_java_library.mk | 28 --- + core/host_java_library.mk | 128 ------------ + core/java_library.mk | 100 ---------- + core/main.mk | 5 +- + core/package.mk | 86 --------- + core/soong_droiddoc_prebuilt.mk | 40 ---- + core/static_java_library.mk | 247 ------------------------ + target/product/base_system.mk | 6 +- + target/product/runtime_libart.mk | 6 +- + 12 files changed, 11 insertions(+), 879 deletions(-) diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk -deleted file mode 100644 -index 7298bde..0000000 +index 180edafbb..e69de29bb 100644 --- a/core/dex_preopt.mk -+++ /dev/null -@@ -1,108 +0,0 @@ ++++ b/core/dex_preopt.mk +@@ -1,49 +0,0 @@ -#################################### -# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time -# -#################################### - --# list of boot classpath jars for dexpreopt --DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS)) --DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS) --PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar)) -- --PRODUCT_SYSTEM_SERVER_CLASSPATH := $(subst $(space),:,$(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),/system/framework/$(m).jar)) -- --DEXPREOPT_BUILD_DIR := $(OUT_DIR) --DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars --DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH)) --DEXPREOPT_BOOT_JAR_DIR := system/framework --DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR) -- --# The default value for LOCAL_DEX_PREOPT --DEX_PREOPT_DEFAULT ?= true -- --# The default filter for which files go into the system_other image (if it is --# being used). To bundle everything one should set this to '%' --SYSTEM_OTHER_ODEX_FILTER ?= app/% priv-app/% +-include $(BUILD_SYSTEM)/dex_preopt_config.mk - -# Method returning whether the install path $(1) should be for system_other. -# Under SANITIZE_LITE, we do not want system_other. Just put things under /data/asan. @@ -62,476 +40,60 @@ index 7298bde..0000000 -install-on-system-other = $(filter-out $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(basename $(notdir $(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(1))))) -endif - --# The default values for pre-opting: always preopt PIC. --# Conditional to building on linux, as dex2oat currently does not work on darwin. --ifeq ($(HOST_OS),linux) -- WITH_DEXPREOPT ?= true -- ifeq (eng,$(TARGET_BUILD_VARIANT)) -- # Don't strip for quick development turnarounds. -- DEX_PREOPT_DEFAULT := nostripping -- # For an eng build only pre-opt the boot image and system server. This gives reasonable performance -- # and still allows a simple workflow: building in frameworks/base and syncing. -- WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY ?= true -- endif -- # Add mini-debug-info to the boot classpath unless explicitly asked not to. -- ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO)) -- PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info -- endif -- -- # Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter -- # only. b/74209329 -- ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT))) -- ifneq (true,$(WITH_DEXPREOPT)) -- ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY)) -- $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds) -- endif -- endif -- endif --endif -- --GLOBAL_DEXPREOPT_FLAGS := -- --# Special rules for building stripped boot jars that override java_library.mk rules +-# We want to install the profile even if we are not using preopt since it is required to generate +-# the image on the device. +-ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED),$(PRODUCT_OUT)) - --# $(1): boot jar module name --define _dexpreopt-boot-jar-remove-classes.dex --_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar --_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar +-# Install boot images. Note that there can be multiple. +-DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := +-$(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := +-$(foreach my_boot_image_name,$(DEXPREOPT_IMAGE_NAMES),$(eval include $(BUILD_SYSTEM)/dex_preopt_libart.mk)) - --$(call dexpreopt-copy-jar,$$(_dbj_src_jar),$$(_dbj_jar_no_dex),$(DEX_PREOPT_DEFAULT)) +-# Build the boot.zip which contains the boot jars and their compilation output +-# We can do this only if preopt is enabled and if the product uses libart config (which sets the +-# default properties for preopting). +-ifeq ($(WITH_DEXPREOPT), true) +-ifeq ($(PRODUCT_USES_ART), true) - --_dbj_jar_no_dex := --_dbj_src_jar := --endef +-boot_zip := $(PRODUCT_OUT)/boot.zip +-bootclasspath_jars := $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES) +-system_server_jars := $(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),$(PRODUCT_OUT)/system/framework/$(m).jar) - --$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b)))) -- --include $(BUILD_SYSTEM)/dex_preopt_libart.mk -- --# Define dexpreopt-one-file based on current default runtime. --# $(1): the input .jar or .apk file --# $(2): the output .odex file --define dexpreopt-one-file --$(call dex2oat-one-file,$(1),$(2)) --endef -- --DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY) --DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) --ifdef TARGET_2ND_ARCH --$(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) --endif # TARGET_2ND_ARCH -- --ifeq ($(PRODUCT_DIST_BOOT_AND_SYSTEM_JARS),true) --boot_profile_jars_zip := $(PRODUCT_OUT)/boot_profile_jars.zip --all_boot_jars := \ -- $(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),$(PRODUCT_OUT)/system/framework/$(m).jar) \ -- $(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),$(PRODUCT_OUT)/system/framework/$(m).jar) -- --$(boot_profile_jars_zip): PRIVATE_JARS := $(all_boot_jars) --$(boot_profile_jars_zip): $(all_boot_jars) $(SOONG_ZIP) -- echo "Create boot profiles package: $@" +-$(boot_zip): PRIVATE_BOOTCLASSPATH_JARS := $(bootclasspath_jars) +-$(boot_zip): PRIVATE_SYSTEM_SERVER_JARS := $(system_server_jars) +-$(boot_zip): $(bootclasspath_jars) $(system_server_jars) $(SOONG_ZIP) $(MERGE_ZIPS) $(DEXPREOPT_IMAGE_ZIP_boot) +- @echo "Create boot package: $@" - rm -f $@ -- $(SOONG_ZIP) -o $@ -C $(PRODUCT_OUT) $(PRIVATE_JARS) -- --droidcore: $(boot_profile_jars_zip) -- --$(call dist-for-goals, droidcore, $(boot_profile_jars_zip)) --endif -diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk -new file mode 120000 -index 0000000..97f5a79 ---- /dev/null -+++ b/core/dex_preopt.mk -@@ -0,0 +1 @@ -+clear_vars.mk -\ No newline at end of file -diff --git a/core/droiddoc.mk b/core/droiddoc.mk -deleted file mode 100644 -index bcd2002..0000000 ---- a/core/droiddoc.mk -+++ /dev/null -@@ -1,367 +0,0 @@ --# --# Copyright (C) 2008 The Android Open Source Project --# --# Licensed under the Apache License, Version 2.0 (the "License"); --# you may not use this file except in compliance with the License. --# You may obtain a copy of the License at --# --# http://www.apache.org/licenses/LICENSE-2.0 --# --# Unless required by applicable law or agreed to in writing, software --# distributed under the License is distributed on an "AS IS" BASIS, --# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --# See the License for the specific language governing permissions and --# limitations under the License. --# -- --$(call record-module-type,DROIDDOC) --########################################################### --## Common logic to both droiddoc and javadoc --########################################################### --LOCAL_IS_HOST_MODULE := $(call true-or-empty,$(LOCAL_IS_HOST_MODULE)) --ifeq ($(LOCAL_IS_HOST_MODULE),true) --my_prefix := HOST_ --LOCAL_HOST_PREFIX := --else --my_prefix := TARGET_ --endif -- --LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS)) --ifndef LOCAL_MODULE_CLASS --$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined) --endif -- --full_src_files := $(patsubst %,$(LOCAL_PATH)/%,$(LOCAL_SRC_FILES)) --out_dir := $(OUT_DOCS)/$(LOCAL_MODULE) --full_target := $(call doc-timestamp-for,$(LOCAL_MODULE)) -- --ifeq ($(LOCAL_DROIDDOC_SOURCE_PATH),) --LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH) --endif -- --ifeq ($(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR),) --LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/$(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) --endif -- --ifeq ($(LOCAL_DROIDDOC_ASSET_DIR),) --LOCAL_DROIDDOC_ASSET_DIR := assets --endif --ifeq ($(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR),) --LOCAL_DROIDDOC_CUSTOM_ASSET_DIR := assets --endif -- --ifeq ($(LOCAL_IS_HOST_MODULE),true) -- --$(full_target): PRIVATE_BOOTCLASSPATH := --full_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\ -- $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES))) -- --else -- --ifneq ($(LOCAL_SDK_VERSION),) -- ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current) -- # Use android_stubs_current if LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS. -- LOCAL_JAVA_LIBRARIES := android_stubs_current $(LOCAL_JAVA_LIBRARIES) -- $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_stubs_current) -- else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current) -- LOCAL_JAVA_LIBRARIES := android_system_stubs_current $(LOCAL_JAVA_LIBRARIES) -- $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_system_stubs_current) -- else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current) -- LOCAL_JAVA_LIBRARIES := android_test_stubs_current $(LOCAL_JAVA_LIBRARIES) -- $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_test_stubs_current) -- else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),core_current) -- LOCAL_JAVA_LIBRARIES := core.current.stubs $(LOCAL_JAVA_LIBRARIES) -- $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, core.current.stubs) -- else -- # core_ is subset of . Instead of defining a prebuilt lib for core_, -- # use the stub for when building for apps. -- _version := $(patsubst core_%,%,$(LOCAL_SDK_VERSION)) -- LOCAL_JAVA_LIBRARIES := sdk_v$(_version) $(LOCAL_JAVA_LIBRARIES) -- $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(_version)) -- _version := -- endif --else -- ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) -- LOCAL_JAVA_LIBRARIES := core-oj core-libart -- else -- LOCAL_JAVA_LIBRARIES := core-oj core-libart ext framework $(LOCAL_JAVA_LIBRARIES) -- endif -- $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, core-oj):$(call java-lib-files, core-libart) --endif # LOCAL_SDK_VERSION --LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES)) -- --full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH) --endif # !LOCAL_IS_HOST_MODULE -- --$(full_target): PRIVATE_CLASSPATH := $(call normalize-path-list,$(full_java_libs)) -- --intermediates.COMMON := $(call local-intermediates-dir,COMMON) -- --$(full_target): PRIVATE_SOURCE_PATH := $(call normalize-path-list,$(LOCAL_DROIDDOC_SOURCE_PATH)) --$(full_target): PRIVATE_JAVA_FILES := $(filter %.java,$(full_src_files)) --$(full_target): PRIVATE_JAVA_FILES += $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES))) --$(full_target): PRIVATE_JAVA_FILES += $(filter %.java,$(LOCAL_GENERATED_SOURCES)) --$(full_target): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) --$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src --$(full_target): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars --$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates.COMMON)/droiddoc-src-list --$(full_target): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/droiddoc-srcjar-list -- --ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),) --$(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR) --endif -- --$(full_target): PRIVATE_OUT_DIR := $(out_dir) --$(full_target): PRIVATE_DROIDDOC_OPTIONS := $(LOCAL_DROIDDOC_OPTIONS) --$(full_target): PRIVATE_STUB_OUT_DIR := $(LOCAL_DROIDDOC_STUB_OUT_DIR) --$(full_target): PRIVATE_METALAVA_DOCS_STUB_OUT_DIR := $(LOCAL_DROIDDOC_METALAVA_DOCS_STUB_OUT_DIR) -- --# Lists the input files for the doc build into a text file --# suitable for the @ syntax of javadoc. --# $(1): the file to create --# $(2): files to include --# $(3): list of directories to search for java files in --define prepare-doc-source-list --$(hide) mkdir -p $(dir $(1)) --$(call dump-words-to-file, $(2), $(1)) --$(hide) for d in $(3) ; do find $$d -name '*.java' -and -not -name '.*' >> $(1) 2> /dev/null ; done ; true --endef -- --########################################################### --## Logic for droiddoc only --########################################################### --ifneq ($(strip $(LOCAL_DROIDDOC_USE_STANDARD_DOCLET)),true) -- --droiddoc_templates := \ -- $(sort $(shell find $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) -type f $(if $(ALLOW_MISSING_DEPENDENCIES),2>/dev/null))) -- --ifdef ALLOW_MISSING_DEPENDENCIES -- ifndef droiddoc_templates -- droiddoc_templates := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) -- endif --endif -- --$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX) --$(full_target): PRIVATE_CURRENT_BUILD := -hdf page.build $(BUILD_ID)-$(BUILD_NUMBER_FROM_FILE) --$(full_target): PRIVATE_CURRENT_TIME := -hdf page.now "$$($(DATE_FROM_FILE) "+%d %b %Y %k:%M")" --$(full_target): PRIVATE_CUSTOM_TEMPLATE_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) --$(full_target): PRIVATE_IN_CUSTOM_ASSET_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR) --$(full_target): PRIVATE_OUT_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_ASSET_DIR) --$(full_target): PRIVATE_OUT_CUSTOM_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR) -- --html_dir_files := --ifneq ($(strip $(LOCAL_DROIDDOC_HTML_DIR)),) --$(full_target): PRIVATE_DROIDDOC_HTML_DIR := -htmldir $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) --html_dir_files := $(sort $(shell find $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) -type f)) --else --$(full_target): PRIVATE_DROIDDOC_HTML_DIR := --endif --ifneq ($(strip $(LOCAL_ADDITIONAL_HTML_DIR)),) --$(full_target): PRIVATE_ADDITIONAL_HTML_DIR := -htmldir2 $(LOCAL_PATH)/$(LOCAL_ADDITIONAL_HTML_DIR) --else --$(full_target): PRIVATE_ADDITIONAL_HTML_DIR := --endif -- --# TODO(nanzhang): Remove it if this is not used any more --$(full_target): PRIVATE_LOCAL_PATH := $(LOCAL_PATH) -- --ifeq ($(strip $(LOCAL_DROIDDOC_USE_METALAVA)),true) --ifneq ($(LOCAL_DROIDDOC_METALAVA_PREVIOUS_API),) --$(full_target): PRIVATE_DROIDDOC_METALAVA_PREVIOUS_API := --previous-api $(LOCAL_DROIDDOC_METALAVA_PREVIOUS_API) --else --$(full_target): PRIVATE_DROIDDOC_METALAVA_PREVIOUS_API := --endif #!LOCAL_DROIDDOC_METALAVA_PREVIOUS_API -- --metalava_annotations_deps := --ifeq ($(strip $(LOCAL_DROIDDOC_METALAVA_ANNOTATIONS_ENABLED)),true) --ifeq ($(LOCAL_DROIDDOC_METALAVA_PREVIOUS_API),) --$(error $(LOCAL_PATH): LOCAL_DROIDDOC_METALAVA_PREVIOUS_API has to be non-empty if metalava annotations was enabled!) --endif --ifeq ($(LOCAL_DROIDDOC_METALAVA_MERGE_ANNOTATIONS_DIR),) --$(error $(LOCAL_PATH): LOCAL_DROIDDOC_METALAVA_MERGE_ANNOTATIONS_DIR has to be non-empty if metalava annotations was enabled!) --endif -- --$(full_target): PRIVATE_DROIDDOC_METALAVA_ANNOTATIONS := --include-annotations --migrate-nullness \ -- --extract-annotations $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(LOCAL_MODULE)_annotations.zip \ -- --merge-annotations $(LOCAL_DROIDDOC_METALAVA_MERGE_ANNOTATIONS_DIR) \ -- --hide HiddenTypedefConstant --hide SuperfluousPrefix --hide AnnotationExtraction --metalava_annotations_deps := $(sort $(shell find $(LOCAL_DROIDDOC_METALAVA_MERGE_ANNOTATIONS_DIR) -type f)) --else --$(full_target): PRIVATE_DROIDDOC_METALAVA_ANNOTATIONS := --endif #LOCAL_DROIDDOC_METALAVA_ANNOTATIONS_ENABLED=true -- --ifneq (,$(filter --generate-documentation,$(LOCAL_DROIDDOC_OPTIONS))) -- --pos = $(if $(findstring $1,$2),$(call pos,$1,$(wordlist 2,$(words $2),$2),x $3),$3) --metalava_args := $(wordlist 1, $(words $(call pos,--generate-documentation,$(LOCAL_DROIDDOC_OPTIONS))), \ -- $(LOCAL_DROIDDOC_OPTIONS)) --remaining_args := $(wordlist $(words $(call pos,--generate-documentation,$(LOCAL_DROIDDOC_OPTIONS))), \ -- $(words $(LOCAL_DROIDDOC_OPTIONS)), $(LOCAL_DROIDDOC_OPTIONS)) --doclava_args := $(wordlist 2, $(words $(remaining_args)), $(remaining_args)) -- --$(full_target): \ -- $(full_src_files) $(LOCAL_GENERATED_SOURCES) \ -- $(droiddoc_templates) \ -- $(HOST_JDK_TOOLS_JAR) \ -- $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX) \ -- $(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX) \ -- $(HOST_OUT_JAVA_LIBRARIES)/metalava$(COMMON_JAVA_PACKAGE_SUFFIX) \ -- $(html_dir_files) \ -- $(full_java_libs) \ -- $(ZIPSYNC) \ -- $(LOCAL_SRCJARS) \ -- $(LOCAL_ADDITIONAL_DEPENDENCIES) \ -- $(LOCAL_DROIDDOC_METALAVA_PREVIOUS_API) \ -- $(metalava_annotations_deps) -- @echo metalava based docs: $(PRIVATE_OUT_DIR) -- $(hide) mkdir -p $(dir $@) -- $(hide) rm -rf $(PRIVATE_STUB_OUT_DIR) -- $(hide) rm -rf $(PRIVATE_METALAVA_DOCS_STUB_OUT_DIR) -- $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ -- $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) -- $(ZIPSYNC) -d $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) -l $(PRIVATE_SRCJAR_LIST_FILE) -f "*.java" $(PRIVATE_SRCJARS) -- $(hide) ( \ -- $(JAVA) -jar $(HOST_OUT_JAVA_LIBRARIES)/metalava$(COMMON_JAVA_PACKAGE_SUFFIX) \ -- -encoding UTF-8 -source 1.8 \@$(PRIVATE_SRC_LIST_FILE) \@$(PRIVATE_SRCJAR_LIST_FILE) \ -- $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \ -- $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \ -- --sourcepath $(PRIVATE_SOURCE_PATH) \ -- --no-banner --color --quiet \ -- $(addprefix --stubs ,$(PRIVATE_STUB_OUT_DIR)) \ -- $(addprefix --doc-stubs ,$(PRIVATE_METALAVA_DOCS_STUB_OUT_DIR)) \ -- --write-stubs-source-list $(intermediates.COMMON)/stubs-src-list \ -- $(metalava_args) $(PRIVATE_DROIDDOC_METALAVA_PREVIOUS_API) $(PRIVATE_DROIDDOC_METALAVA_ANNOTATIONS) \ -- $(JAVADOC) -encoding UTF-8 -source 1.8 STUBS_SOURCE_LIST \ -- -J-Xmx1600m -J-XX:-OmitStackTraceInFastThrow -XDignore.symbol.file \ -- -quiet -doclet com.google.doclava.Doclava -docletpath $(PRIVATE_DOCLETPATH) \ -- -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \ -- $(PRIVATE_DROIDDOC_HTML_DIR) $(PRIVATE_ADDITIONAL_HTML_DIR) \ -- $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \ -- $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \ -- -sourcepath $(PRIVATE_SOURCE_PATH) \ -- -d $(PRIVATE_OUT_DIR) \ -- $(PRIVATE_CURRENT_BUILD) $(PRIVATE_CURRENT_TIME) $(doclava_args) \ -- && touch -f $@ ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45) --else --# no docs generation --$(full_target): \ -- $(full_src_files) $(LOCAL_GENERATED_SOURCES) \ -- $(full_java_libs) \ -- $(HOST_OUT_JAVA_LIBRARIES)/metalava$(COMMON_JAVA_PACKAGE_SUFFIX) \ -- $(ZIPSYNC) \ -- $(LOCAL_SRCJARS) \ -- $(LOCAL_ADDITIONAL_DEPENDENCIES) -- @echo metalava based stubs: $@ -- $(hide) mkdir -p $(dir $@) -- $(hide) rm -rf $(PRIVATE_STUB_OUT_DIR) -- $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ -- $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) -- $(ZIPSYNC) -d $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) -l $(PRIVATE_SRCJAR_LIST_FILE) -f "*.java" $(PRIVATE_SRCJARS) -- $(hide) ( \ -- $(JAVA) -jar $(HOST_OUT_JAVA_LIBRARIES)/metalava$(COMMON_JAVA_PACKAGE_SUFFIX) \ -- -encoding UTF-8 -source 1.8 \@$(PRIVATE_SRC_LIST_FILE) \@$(PRIVATE_SRCJAR_LIST_FILE) \ -- $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \ -- $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \ -- --sourcepath $(PRIVATE_SOURCE_PATH) \ -- $(PRIVATE_DROIDDOC_OPTIONS) $(PRIVATE_DROIDDOC_METALAVA_PREVIOUS_API) $(PRIVATE_DROIDDOC_METALAVA_ANNOTATIONS) \ -- --no-banner --color --quiet \ -- $(addprefix --stubs ,$(PRIVATE_STUB_OUT_DIR)) \ -- && touch -f $@ ) || (rm -rf $(PRIVATE_SRC_LIST_FILE); exit 45) -- --endif # stubs + docs generation --ifeq ($(strip $(LOCAL_DROIDDOC_METALAVA_ANNOTATIONS_ENABLED)),true) --$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(LOCAL_MODULE)_annotations.zip: $(full_target) --endif -- --else # doclava based droiddoc generation -- --# TODO(tobiast): Clean this up once we move to -source 1.9. --# OpenJDK 9 does not have the concept of a "boot classpath" so we should --# then rename PRIVATE_BOOTCLASSPATH to PRIVATE_MODULE or similar. For now, --# keep -bootclasspath here since it works in combination with -source 1.8. --$(full_target): \ -- $(full_src_files) $(LOCAL_GENERATED_SOURCES) \ -- $(droiddoc_templates) \ -- $(HOST_JDK_TOOLS_JAR) \ -- $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX) \ -- $(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX) \ -- $(html_dir_files) \ -- $(full_java_libs) \ -- $(ZIPSYNC) \ -- $(LOCAL_SRCJARS) \ -- $(LOCAL_ADDITIONAL_DEPENDENCIES) -- @echo Docs droiddoc: $(PRIVATE_OUT_DIR) -- $(hide) mkdir -p $(dir $@) -- $(hide) rm -rf $(PRIVATE_STUB_OUT_DIR) -- $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ -- $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) -- $(ZIPSYNC) -d $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) -l $(PRIVATE_SRCJAR_LIST_FILE) -f "*.java" $(PRIVATE_SRCJARS) -- $(hide) ( \ -- $(JAVADOC) \ -- -encoding UTF-8 -source 1.8 \@$(PRIVATE_SRC_LIST_FILE) \@$(PRIVATE_SRCJAR_LIST_FILE) \ -- -J-Xmx1600m -J-XX:-OmitStackTraceInFastThrow -XDignore.symbol.file \ -- -quiet -doclet com.google.doclava.Doclava -docletpath $(PRIVATE_DOCLETPATH) \ -- -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \ -- $(PRIVATE_DROIDDOC_HTML_DIR) $(PRIVATE_ADDITIONAL_HTML_DIR) \ -- $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \ -- $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \ -- -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \ -- -d $(PRIVATE_OUT_DIR) \ -- $(PRIVATE_CURRENT_BUILD) $(PRIVATE_CURRENT_TIME) $(PRIVATE_DROIDDOC_OPTIONS) \ -- $(addprefix -stubs ,$(PRIVATE_STUB_OUT_DIR)) \ -- && touch -f $@ ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45) --endif #LOCAL_DROIDDOC_USE_METALAVA -- --else -- --########################################################### --## Logic for javadoc only --########################################################### --ifdef USE_OPENJDK9 --# For OpenJDK 9 we use --patch-module to define the core libraries code. --# TODO(tobiast): Reorganize this when adding proper support for OpenJDK 9 --# modules. Here we treat all code in core libraries as being in java.base --# to work around the OpenJDK 9 module system. http://b/62049770 --$(full_target): PRIVATE_BOOTCLASSPATH_ARG := --patch-module=java.base=$(PRIVATE_BOOTCLASSPATH) --else --# For OpenJDK 8 we can use -bootclasspath to define the core libraries code. --$(full_target): PRIVATE_BOOTCLASSPATH_ARG := $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) --endif --$(full_target): $(full_src_files) $(LOCAL_GENERATED_SOURCES) $(full_java_libs) $(ZIPSYNC) $(LOCAL_SRCJARS) $(LOCAL_ADDITIONAL_DEPENDENCIES) -- @echo Docs javadoc: $(PRIVATE_OUT_DIR) -- @mkdir -p $(dir $@) -- $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \ -- $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR)) -- $(ZIPSYNC) -d $(PRIVATE_SRCJAR_INTERMEDIATES_DIR) -l $(PRIVATE_SRCJAR_LIST_FILE) -f "*.java" $(PRIVATE_SRCJARS) -- $(hide) ( \ -- $(JAVADOC) -encoding UTF-8 \@$(PRIVATE_SRC_LIST_FILE) \@$(PRIVATE_SRCJAR_LIST_FILE) \ -- $(PRIVATE_DROIDDOC_OPTIONS) -J-Xmx1024m -XDignore.symbol.file -Xdoclint:none -quiet \ -- $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) $(PRIVATE_BOOTCLASSPATH_ARG) \ -- -sourcepath $(PRIVATE_SOURCE_PATH) \ -- -d $(PRIVATE_OUT_DIR) \ -- && touch -f $@ \ -- ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45) -- --endif # !LOCAL_DROIDDOC_USE_STANDARD_DOCLET -- --ALL_DOCS += $(full_target) -- --.PHONY: $(LOCAL_MODULE)-docs --$(LOCAL_MODULE)-docs : $(full_target) -- --ifeq ($(strip $(LOCAL_UNINSTALLABLE_MODULE)),) -- --# Define a rule to create a zip of these docs. --out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip --$(out_zip): PRIVATE_DOCS_DIR := $(out_dir) --$(out_zip): $(full_target) -- @echo Package docs: $@ -- @rm -f $@ -- @mkdir -p $(dir $@) -- $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rqX $$F * ) -- --$(LOCAL_MODULE)-docs.zip : $(out_zip) -- --$(call dist-for-goals,docs,$(out_zip)) -- --endif #!LOCAL_UNINSTALLABLE_MODULE -diff --git a/core/droiddoc.mk b/core/droiddoc.mk -new file mode 120000 -index 0000000..97f5a79 ---- /dev/null -+++ b/core/droiddoc.mk -@@ -0,0 +1 @@ -+clear_vars.mk -\ No newline at end of file +- $(SOONG_ZIP) -o $@.tmp \ +- -C $(dir $(firstword $(PRIVATE_BOOTCLASSPATH_JARS)))/.. $(addprefix -f ,$(PRIVATE_BOOTCLASSPATH_JARS)) \ +- -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_SYSTEM_SERVER_JARS)) +- $(MERGE_ZIPS) $@ $@.tmp $(DEXPREOPT_IMAGE_ZIP_boot) +- rm -f $@.tmp +- +-$(call dist-for-goals, droidcore, $(boot_zip)) +- +-endif #PRODUCT_USES_ART +-endif #WITH_DEXPREOPT +diff --git a/core/envsetup.mk b/core/envsetup.mk +index 5131598a9..3e7b35b1a 100644 +--- a/core/envsetup.mk ++++ b/core/envsetup.mk +@@ -250,8 +250,8 @@ endef + # java code with dalvikvm/art. + # Jars present in the runtime apex. These should match exactly the list of + # Java libraries in the runtime apex build rule. +-RUNTIME_APEX_JARS := core-oj core-libart okhttp bouncycastle apache-xml +-TARGET_CORE_JARS := $(RUNTIME_APEX_JARS) conscrypt ++#RUNTIME_APEX_JARS := core-oj core-libart okhttp bouncycastle apache-xml ++TARGET_CORE_JARS := + ifeq ($(EMMA_INSTRUMENT),true) + ifneq ($(EMMA_INSTRUMENT_STATIC),true) + # For instrumented build, if Jacoco is not being included statically diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk -deleted file mode 100644 -index 1ef0ccb..0000000 +index 2a251e84e..8b1378917 100644 --- a/core/host_dalvik_java_library.mk -+++ /dev/null -@@ -1,224 +0,0 @@ ++++ b/core/host_dalvik_java_library.mk +@@ -1,192 +1 @@ -# -# Copyright (C) 2013 The Android Open Source Project -# @@ -548,7 +110,7 @@ index 1ef0ccb..0000000 -# limitations under the License. -# -$(call record-module-type,HOST_DALVIK_JAVA_LIBRARY) -- + -# -# Rules for building a host dalvik java library. These libraries -# are meant to be used by a dalvik VM instance running on the host. @@ -567,7 +129,6 @@ index 1ef0ccb..0000000 -full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar -full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar -full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar --full_classes_desugar_jar := $(intermediates.COMMON)/desugar.classes.jar -full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar -full_classes_jar := $(intermediates.COMMON)/classes.jar -built_dex := $(intermediates.COMMON)/classes.dex @@ -577,7 +138,6 @@ index 1ef0ccb..0000000 - $(full_classes_turbine_jar) \ - $(full_classes_compiled_jar) \ - $(full_classes_combined_jar) \ -- $(full_classes_desugar_jar) \ - $(full_classes_jarjar_jar) \ - $(full_classes_jar) \ - $(built_dex) \ @@ -692,22 +252,6 @@ index 1ef0ccb..0000000 - -$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar))) - --ifneq ($(USE_D8_DESUGAR),true) --my_desugaring := --ifeq ($(LOCAL_JAVA_LANGUAGE_VERSION),1.8) --my_desugaring := true --$(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) --$(full_classes_desugar_jar): $(full_classes_jar) $(full_java_header_libs) $(DESUGAR) -- $(desugar-classes-jar) --endif --else --my_desugaring := --endif -- --ifndef my_desugaring --full_classes_desugar_jar := $(full_classes_jar) --endif -- -ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) -# No dex; all we want are the .class files with resources. -$(LOCAL_BUILT_MODULE) : $(java_resource_sources) @@ -718,57 +262,34 @@ index 1ef0ccb..0000000 -else # !LOCAL_IS_STATIC_JAVA_LIBRARY -$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON) -$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) --$(built_dex): $(full_classes_desugar_jar) $(DX) $(ZIP2ZIP) --ifneq ($(USE_D8_DESUGAR),true) +-$(built_dex): $(full_classes_jar) $(DX) $(ZIP2ZIP) - $(transform-classes.jar-to-dex) --else -- $(transform-classes-d8.jar-to-dex) --endif - -$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) -$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar) --$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) +-$(LOCAL_BUILT_MODULE): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP) -$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources) - @echo "Host Jar: $(PRIVATE_MODULE) ($@)" -- $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@) -- $(add-dex-to-package) +- rm -rf $@.parts +- mkdir -p $@.parts +- $(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE)) +- $(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE)) +- $(MERGE_ZIPS) -j $@ $@.parts/dex.zip $@.parts/res.zip +- rm -rf $@.parts - -endif # !LOCAL_IS_STATIC_JAVA_LIBRARY - --ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION))) -- my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) -- my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) --else -- my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK) -- my_sdk_version := $(PLATFORM_SDK_VERSION) --endif -- --ifdef LOCAL_MIN_SDK_VERSION -- my_min_sdk_version := $(LOCAL_MIN_SDK_VERSION) --else -- my_min_sdk_version := $(call codename-or-sdk-to-sdk,$(my_default_app_target_sdk)) --endif -- --$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(my_default_app_target_sdk) --$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(my_sdk_version) --$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(my_min_sdk_version) +-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call module-target-sdk-version) +-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(call module-sdk-version) +-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(call codename-or-sdk-to-sdk,$(call module-min-sdk-version)) - -USE_CORE_LIB_BOOTCLASSPATH := - -endif -diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk -new file mode 120000 -index 0000000..97f5a79 ---- /dev/null -+++ b/core/host_dalvik_java_library.mk -@@ -0,0 +1 @@ -+clear_vars.mk -\ No newline at end of file diff --git a/core/host_dalvik_static_java_library.mk b/core/host_dalvik_static_java_library.mk -deleted file mode 100644 -index 78faf73..0000000 +index 78faf73a5..e69de29bb 100644 --- a/core/host_dalvik_static_java_library.mk -+++ /dev/null ++++ b/core/host_dalvik_static_java_library.mk @@ -1,28 +0,0 @@ -# -# Copyright (C) 2013 The Android Open Source Project @@ -798,20 +319,144 @@ index 78faf73..0000000 -include $(BUILD_SYSTEM)/host_dalvik_java_library.mk - -LOCAL_IS_STATIC_JAVA_LIBRARY := -diff --git a/core/host_dalvik_static_java_library.mk b/core/host_dalvik_static_java_library.mk -new file mode 120000 -index 0000000..97f5a79 ---- /dev/null -+++ b/core/host_dalvik_static_java_library.mk -@@ -0,0 +1 @@ -+clear_vars.mk -\ No newline at end of file +diff --git a/core/host_java_library.mk b/core/host_java_library.mk +index c8d2ee78c..e69de29bb 100644 +--- a/core/host_java_library.mk ++++ b/core/host_java_library.mk +@@ -1,128 +0,0 @@ +-# +-# Copyright (C) 2008 The Android Open Source Project +-# +-# Licensed under the Apache License, Version 2.0 (the "License"); +-# you may not use this file except in compliance with the License. +-# You may obtain a copy of the License at +-# +-# http://www.apache.org/licenses/LICENSE-2.0 +-# +-# Unless required by applicable law or agreed to in writing, software +-# distributed under the License is distributed on an "AS IS" BASIS, +-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-# See the License for the specific language governing permissions and +-# limitations under the License. +-# +- +-$(call record-module-type,HOST_JAVA_LIBRARY) +- +-# +-# Standard rules for building a host java library. +-# +- +-####################################### +-include $(BUILD_SYSTEM)/host_java_library_common.mk +-####################################### +- +-# Enable emma instrumentation only if the module asks so. +-ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) +-ifneq (true,$(EMMA_INSTRUMENT)) +-LOCAL_EMMA_INSTRUMENT := +-endif +-endif +- +-full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar +-full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar +-full_classes_jar := $(intermediates.COMMON)/classes.jar +-java_source_list_file := $(intermediates.COMMON)/java-source-list +-full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar +-full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar +- +-LOCAL_INTERMEDIATE_TARGETS += \ +- $(full_classes_compiled_jar) \ +- $(full_classes_jarjar_jar) \ +- $(java_source_list_file) \ +- $(full_classes_combined_jar) +- +-####################################### +-include $(BUILD_SYSTEM)/base_rules.mk +-####################################### +- +-java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \ +- $(filter %.java,$(LOCAL_GENERATED_SOURCES)) +-all_java_sources := $(java_sources) +- +-include $(BUILD_SYSTEM)/java_common.mk +- +-# The layers file allows you to enforce a layering between java packages. +-# Run build/make/tools/java-layers.py for more details. +-layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) +- +-# List of dependencies for anything that needs all java sources in place +-java_sources_deps := \ +- $(java_sources) \ +- $(java_resource_sources) \ +- $(proto_java_sources_file_stamp) \ +- $(LOCAL_SRCJARS) \ +- $(LOCAL_ADDITIONAL_DEPENDENCIES) +- +-$(java_source_list_file): $(java_sources_deps) +- $(write-java-source-list) +- +-$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) +-$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) +-$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := +-$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := +-$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := +-$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) +-$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list +-$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars +-$(full_classes_compiled_jar): \ +- $(java_source_list_file) \ +- $(java_sources_deps) \ +- $(full_java_libs) \ +- $(full_java_bootclasspath_libs) \ +- $(annotation_processor_deps) \ +- $(NORMALIZE_PATH) \ +- $(ZIPTIME) \ +- $(JAR_ARGS) \ +- $(ZIPSYNC) \ +- | $(SOONG_JAVAC_WRAPPER) +- $(transform-host-java-to-package) +- $(remove-timestamps-from-package) +- +-javac-check : $(full_classes_compiled_jar) +-javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar) +-.PHONY: javac-check-$(LOCAL_MODULE) +- +-$(full_classes_combined_jar): $(full_classes_compiled_jar) \ +- $(jar_manifest_file) \ +- $(full_static_java_libs) | $(MERGE_ZIPS) +- $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ +- $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf) +- $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \ +- -stripDir META-INF -zipToNotStrip $< $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES)) +- +-# Run jarjar if necessary, otherwise just copy the file. +-ifneq ($(strip $(LOCAL_JARJAR_RULES)),) +-$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) +-$(full_classes_jarjar_jar): $(full_classes_combined_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) +- @echo JarJar: $@ +- $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ +-else +-full_classes_jarjar_jar := $(full_classes_combined_jar) +-endif +- +- +-####################################### +-LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jarjar_jar) +- +-include $(BUILD_SYSTEM)/jacoco.mk +-####################################### +- +-$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(LOCAL_BUILT_MODULE))) +-$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_jar))) +- +-ifeq ($(TURBINE_ENABLED),false) +-$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_header_jar))) +-endif diff --git a/core/java_library.mk b/core/java_library.mk -deleted file mode 100644 -index 1b914f5..0000000 +index c706cea72..e69de29bb 100644 --- a/core/java_library.mk -+++ /dev/null -@@ -1,104 +0,0 @@ ++++ b/core/java_library.mk +@@ -1,100 +0,0 @@ -########################################################### -## Standard rules for building a java library. -## @@ -864,6 +509,8 @@ index 1b914f5..0000000 -LOCAL_EMMA_INSTRUMENT := false -endif # EMMA_INSTRUMENT - +-my_dex_jar := $(common_javalib.jar) +- -################################# -include $(BUILD_SYSTEM)/java.mk -################################# @@ -871,19 +518,22 @@ index 1b914f5..0000000 -ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) -# There are some dependencies outside the build system that assume classes.jar -# is available as javalib.jar so copy it there too. --$(eval $(call copy-one-file,$(full_classes_proguard_jar),$(common_javalib.jar))) +-$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(common_javalib.jar))) - --$(eval $(call copy-one-file,$(full_classes_proguard_jar),$(LOCAL_BUILT_MODULE))) +-$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(LOCAL_BUILT_MODULE))) - -else # !LOCAL_IS_STATIC_JAVA_LIBRARY - -$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) -$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar) --$(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) +-$(common_javalib.jar): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP) -$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN) - @echo "target Jar: $(PRIVATE_MODULE) ($@)" -- $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@.tmp) -- $(call add-dex-to-package-arg,$@.tmp) +- rm -rf $@.parts && mkdir -p $@.parts +- $(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE)) +- $(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE)) +- $(MERGE_ZIPS) -j $@.tmp $@.parts/dex.zip $@.parts/res.zip +- rm -rf $@.parts - $(hide) $(ZIPTIME) $@.tmp - $(call commit-change-for-toc,$@) -ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) @@ -894,41 +544,33 @@ index 1b914f5..0000000 -.KATI_RESTAT: $(common_javalib.jar) - -ifdef LOCAL_DEX_PREOPT --ifneq ($(dexpreopt_boot_jar_module),) # boot jar --# boot jar's rules are defined in dex_preopt.mk --dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar --$(eval $(call copy-one-file,$(dexpreopted_boot_jar),$(LOCAL_BUILT_MODULE))) - --# For libart boot jars, we don't have .odex files. --else # ! boot jar --$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE) --# Use pattern rule - we may have multiple built odex files. --$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar) -- @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" -- $(call dexpreopt-one-file,$<,$@) -- --$(eval $(call dexpreopt-copy-jar,$(common_javalib.jar),$(LOCAL_BUILT_MODULE),$(LOCAL_DEX_PREOPT))) -- --endif # ! boot jar +-$(LOCAL_BUILT_MODULE): PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh +-$(LOCAL_BUILT_MODULE): $(intermediates)/strip.sh +-$(LOCAL_BUILT_MODULE): | $(DEXPREOPT_STRIP_DEPS) +-$(LOCAL_BUILT_MODULE): .KATI_DEPFILE := $(LOCAL_BUILT_MODULE).d +-$(LOCAL_BUILT_MODULE): $(common_javalib.jar) +- $(PRIVATE_STRIP_SCRIPT) $< $@ - -else # LOCAL_DEX_PREOPT -$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE))) - -endif # LOCAL_DEX_PREOPT -endif # !LOCAL_IS_STATIC_JAVA_LIBRARY -diff --git a/core/java_library.mk b/core/java_library.mk -new file mode 120000 -index 0000000..97f5a79 ---- /dev/null -+++ b/core/java_library.mk -@@ -0,0 +1 @@ -+clear_vars.mk -\ No newline at end of file diff --git a/core/main.mk b/core/main.mk -index 1946edb..035856b 100644 +index df5c13cc2..db5a177d6 100644 --- a/core/main.mk +++ b/core/main.mk -@@ -455,6 +455,9 @@ subdir_makefiles_total := $(words $(subdir_makefiles)) +@@ -179,8 +179,6 @@ endif + # Bring in standard build system definitions. + include $(BUILD_SYSTEM)/definitions.mk + +-# Bring in dex_preopt.mk +-include $(BUILD_SYSTEM)/dex_preopt.mk + + ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),) + $(info ***************************************************************) +@@ -478,6 +476,9 @@ subdir_makefiles_total := $(words int $(subdir_makefiles) post finish) $(foreach mk,$(subdir_makefiles),$(info [$(call inc_and_print,subdir_makefiles_inc)/$(subdir_makefiles_total)] including $(mk) ...)$(eval include $(mk))) @@ -939,11 +581,10 @@ index 1946edb..035856b 100644 # Bring in the PDK platform.zip modules. include $(BUILD_SYSTEM)/pdk_fusion_modules.mk diff --git a/core/package.mk b/core/package.mk -deleted file mode 100644 -index f3713fc..0000000 +index 854e0093c..e69de29bb 100644 --- a/core/package.mk -+++ /dev/null -@@ -1,84 +0,0 @@ ++++ b/core/package.mk +@@ -1,86 +0,0 @@ -# We don't automatically set up rules to build packages for both -# TARGET_ARCH and TARGET_2ND_ARCH. -# To build it for TARGET_2ND_ARCH in a 64bit product, use "LOCAL_MULTILIB := 32". @@ -954,7 +595,9 @@ index f3713fc..0000000 -include $(BUILD_SYSTEM)/multilib.mk - -ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true) -- ifneq ($(TARGET_SUPPORTS_64_BIT_APPS)|$(my_module_multilib),|64) +- ifeq ($(TARGET_SUPPORTS_64_BIT_APPS),true) +- my_module_multilib := first +- else ifneq ($(my_module_multilib),64) - my_module_multilib := first - endif -endif @@ -1028,20 +671,56 @@ index f3713fc..0000000 -LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := - -my_module_arch_supported := -diff --git a/core/package.mk b/core/package.mk -new file mode 120000 -index 0000000..97f5a79 ---- /dev/null -+++ b/core/package.mk -@@ -0,0 +1 @@ -+clear_vars.mk -\ No newline at end of file +diff --git a/core/soong_droiddoc_prebuilt.mk b/core/soong_droiddoc_prebuilt.mk +index bf1f10bd9..e69de29bb 100644 +--- a/core/soong_droiddoc_prebuilt.mk ++++ b/core/soong_droiddoc_prebuilt.mk +@@ -1,40 +0,0 @@ +-# Droiddoc prebuilt coming from Soong. +- +-ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) +- $(call pretty-error,soong_droiddoc_prebuilt.mk may only be used from Soong) +-endif +- +-ifdef LOCAL_DROIDDOC_STUBS_SRCJAR +-$(eval $(call copy-one-file,$(LOCAL_DROIDDOC_STUBS_SRCJAR),$(OUT_DOCS)/$(LOCAL_MODULE)-stubs.srcjar)) +-ALL_DOCS += $(OUT_DOCS)/$(LOCAL_MODULE)-stubs.srcjar +- +-.PHONY: $(LOCAL_MODULE) +-$(LOCAL_MODULE) : $(OUT_DOCS)/$(LOCAL_MODULE)-stubs.srcjar +-endif +- +-ifdef LOCAL_DROIDDOC_DOC_ZIP +-$(eval $(call copy-one-file,$(LOCAL_DROIDDOC_DOC_ZIP),$(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip)) +-$(call dist-for-goals,docs,$(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip) +- +-.PHONY: $(LOCAL_MODULE) $(LOCAL_MODULE)-docs.zip +-$(LOCAL_MODULE) $(LOCAL_MODULE)-docs.zip : $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip +-ALL_DOCS += $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip +-endif +- +-ifdef LOCAL_DROIDDOC_ANNOTATIONS_ZIP +-$(eval $(call copy-one-file,$(LOCAL_DROIDDOC_ANNOTATIONS_ZIP),$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(LOCAL_MODULE)_annotations.zip)) +-endif +- +-ifdef LOCAL_DROIDDOC_API_VERSIONS_XML +-$(eval $(call copy-one-file,$(LOCAL_DROIDDOC_API_VERSIONS_XML),$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(LOCAL_MODULE)_generated-api-versions.xml)) +-endif +- +-ifdef LOCAL_DROIDDOC_JDIFF_DOC_ZIP +-$(eval $(call copy-one-file,$(LOCAL_DROIDDOC_JDIFF_DOC_ZIP),$(OUT_DOCS)/$(LOCAL_MODULE)-jdiff-docs.zip)) +-$(call dist-for-goals,docs,$(OUT_DOCS)/$(LOCAL_MODULE)-jdiff-docs.zip) +- +-ALL_DOCS += $(OUT_DOCS)/$(LOCAL_MODULE)-jdiff-docs.zip +- +-.PHONY: $(LOCAL_MODULE) $(LOCAL_MODULE)-jdiff +-$(LOCAL_MODULE) $(LOCAL_MODULE)-jdiff : $(OUT_DOCS)/$(LOCAL_MODULE)-jdiff-docs.zip +-endif diff --git a/core/static_java_library.mk b/core/static_java_library.mk -deleted file mode 100644 -index 0429dd2..0000000 +index ee759b9d8..e69de29bb 100644 --- a/core/static_java_library.mk -+++ /dev/null -@@ -1,237 +0,0 @@ ++++ b/core/static_java_library.mk +@@ -1,247 +0,0 @@ -# -# Copyright (C) 2008 The Android Open Source Project -# @@ -1072,13 +751,15 @@ index 0429dd2..0000000 - -my_res_package := - +-# Process Support Library dependencies. +-include $(BUILD_SYSTEM)/support_libraries.mk +- +-include $(BUILD_SYSTEM)/force_aapt2.mk +- -ifdef LOCAL_AAPT2_ONLY -LOCAL_USE_AAPT2 := true -endif - --# Process Support Library dependencies. --include $(BUILD_SYSTEM)/support_libraries.mk -- -# Hack to build static Java library with Android resource -# See bug 5714516 -all_resources := @@ -1088,8 +769,8 @@ index 0429dd2..0000000 -need_compile_res := true -LOCAL_RESOURCE_DIR := $(foreach d,$(LOCAL_RESOURCE_DIR),$(call clean-path,$(d))) -endif --ifdef LOCAL_USE_AAPT2 --ifneq ($(LOCAL_STATIC_ANDROID_LIBRARIES),) +-ifeq ($(LOCAL_USE_AAPT2),true) +-ifneq ($(strip $(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),) -need_compile_res := true -endif -endif @@ -1126,15 +807,23 @@ index 0429dd2..0000000 -R_file_stamp := $(intermediates.COMMON)/src/R.stamp -LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp) - --ifdef LOCAL_USE_AAPT2 --# For library we treat all the resource equal with no overlay. --my_res_resources := $(all_resources) --my_overlay_resources := --# For libraries put everything in the COMMON intermediate directory. --my_res_package := $(intermediates.COMMON)/package-res.apk +-ifeq ($(LOCAL_USE_AAPT2),true) +- ifneq ($(strip $(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),) +- # If we are using static android libraries, every source file becomes an overlay. +- # This is to emulate old AAPT behavior which simulated library support. +- my_res_resources := +- my_overlay_resources := $(all_resources) +- else +- # Otherwise, for a library we treat all the resource equal with no overlay. +- my_res_resources := $(all_resources) +- my_overlay_resources := +- endif +- # For libraries put everything in the COMMON intermediate directory. +- my_res_package := $(intermediates.COMMON)/package-res.apk - --LOCAL_INTERMEDIATE_TARGETS += $(my_res_package) +- LOCAL_INTERMEDIATE_TARGETS += $(my_res_package) -endif # LOCAL_USE_AAPT2 +- -endif # need_compile_res - -all_res_assets := $(all_resources) @@ -1152,17 +841,17 @@ index 0429dd2..0000000 -framework_res_package_export := -# Please refer to package.mk -ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) --ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),) +-ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS_USE_PREBUILT_SDK),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),) -framework_res_package_export := \ -- $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar +- $(call resolve-prebuilt-sdk-jar-path,$(LOCAL_SDK_RES_VERSION)) -else -framework_res_package_export := \ - $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk -endif -endif - --ifdef LOCAL_USE_AAPT2 --import_proguard_flag_files := $(strip $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\ +-ifeq ($(LOCAL_USE_AAPT2),true) +-import_proguard_flag_files := $(strip $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ - $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags)) -$(intermediates.COMMON)/export_proguard_flags: $(import_proguard_flag_files) $(addprefix $(LOCAL_PATH)/,$(LOCAL_EXPORT_PROGUARD_FLAG_FILES)) - @echo "Export proguard flags: $@" @@ -1184,7 +873,7 @@ index 0429dd2..0000000 - -# add --non-constant-id to prevent inlining constants. -# AAR needs text symbol file R.txt. --ifdef LOCAL_USE_AAPT2 +-ifeq ($(LOCAL_USE_AAPT2),true) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --static-lib --output-text-symbols $(intermediates.COMMON)/R.txt -ifndef LOCAL_AAPT_NAMESPACES - $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS += --no-static-lib-packages @@ -1212,10 +901,10 @@ index 0429dd2..0000000 -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := - --ifdef LOCAL_USE_AAPT2 +-ifeq ($(LOCAL_USE_AAPT2),true) - # One more level with name res so we can zip up the flat resources that can be linked by apps. - my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res -- ifneq (,$(renderscript_target_api)) +- ifneq (,$(filter-out current,$(renderscript_target_api))) - ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) - my_generated_res_zips := $(rs_generated_res_zip) - endif # renderscript_target_api < 21 @@ -1279,14 +968,40 @@ index 0429dd2..0000000 -aar_classes_jar := -all_res_assets := -LOCAL_IS_STATIC_JAVA_LIBRARY := -diff --git a/core/static_java_library.mk b/core/static_java_library.mk -new file mode 120000 -index 0000000..97f5a79 ---- /dev/null -+++ b/core/static_java_library.mk -@@ -0,0 +1 @@ -+clear_vars.mk -\ No newline at end of file +diff --git a/target/product/base_system.mk b/target/product/base_system.mk +index 822d2ead8..9cb6a21ef 100644 +--- a/target/product/base_system.mk ++++ b/target/product/base_system.mk +@@ -309,9 +309,9 @@ PRODUCT_HOST_PACKAGES += \ + tz_version_host \ + tz_version_host_runtime_apex \ + +-ifeq ($(TARGET_CORE_JARS),) +-$(error TARGET_CORE_JARS is empty; cannot initialize PRODUCT_BOOT_JARS variable) +-endif ++#ifeq ($(TARGET_CORE_JARS),) ++#$(error TARGET_CORE_JARS is empty; cannot initialize PRODUCT_BOOT_JARS variable) ++#endif + + # The order matters for runtime class lookup performance. + PRODUCT_BOOT_JARS := \ +diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk +index a88ba3c8d..4ab27994b 100644 +--- a/target/product/runtime_libart.mk ++++ b/target/product/runtime_libart.mk +@@ -16,9 +16,9 @@ + + # Provides a functioning ART environment without Android frameworks + +-ifeq ($(TARGET_CORE_JARS),) +-$(error TARGET_CORE_JARS is empty; cannot update PRODUCT_PACKAGES variable) +-endif ++#ifeq ($(TARGET_CORE_JARS),) ++#$(error TARGET_CORE_JARS is empty; cannot update PRODUCT_PACKAGES variable) ++#endif + + # Minimal boot classpath. This should be a subset of PRODUCT_BOOT_JARS, and equivalent to + # TARGET_CORE_JARS. -- -2.7.4 +2.23.0 diff --git a/build/make/0003-hybris-Disable-APEX-check-we-don-t-care-about-it.patch b/build/make/0003-hybris-Disable-APEX-check-we-don-t-care-about-it.patch new file mode 100644 index 0000000..93b57e5 --- /dev/null +++ b/build/make/0003-hybris-Disable-APEX-check-we-don-t-care-about-it.patch @@ -0,0 +1,26 @@ +From ac37739a9491b65bb26517af54c56c7375cc274e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= +Date: Fri, 18 Oct 2019 11:43:31 +0200 +Subject: [PATCH 3/3] (hybris) Disable APEX check, we don't care about it. + +Change-Id: I1099755d6ec01f10b70c78ca68af822ccafb2b6f +--- + core/main.mk | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/core/main.mk b/core/main.mk +index db5a177d6..09a8f3f63 100644 +--- a/core/main.mk ++++ b/core/main.mk +@@ -1247,7 +1247,7 @@ APEX_MODULE_LIBS += \ + + # An option to disable the check below, for local use since some build targets + # still may create these libraries in /system (b/129006418). +-DISABLE_APEX_LIBS_ABSENCE_CHECK ?= ++DISABLE_APEX_LIBS_ABSENCE_CHECK ?= 1 + + # Bionic should not be in /system, except for the bootstrap instance. + APEX_LIBS_ABSENCE_CHECK_EXCLUDE := lib/bootstrap lib64/bootstrap +-- +2.23.0 + diff --git a/build/make/0003-hybris-Reduce-vendorimage-build-size.patch b/build/make/0003-hybris-Reduce-vendorimage-build-size.patch deleted file mode 100644 index 4c8c9e2..0000000 --- a/build/make/0003-hybris-Reduce-vendorimage-build-size.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 406f994725894d4076f84a4210277f40ae43f2cf Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= -Date: Fri, 22 Mar 2019 18:36:56 +0200 -Subject: [PATCH 3/3] (hybris) Reduce vendorimage build size. - -Change-Id: Id025a7d7c81cb19c2881ff6619084b638ce983fb ---- - core/Makefile | 9 ++++++++- - 1 file changed, 8 insertions(+), 1 deletion(-) - -diff --git a/core/Makefile b/core/Makefile -index 0a2f6e3..e790be1 100644 ---- a/core/Makefile -+++ b/core/Makefile -@@ -19,6 +19,7 @@ $(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \ - Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) - endef - # filter out the duplicate : pairs. -+ALL_PRODUCT_COPY_FILES := - unique_product_copy_files_pairs := - $(foreach cf,$(PRODUCT_COPY_FILES), \ - $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\ -@@ -38,6 +39,7 @@ $(foreach cf,$(unique_product_copy_files_pairs), \ - $(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \ - $(eval $(call copy-one-file,$(_src),$(_fulldest))))) \ - $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \ -+ $(eval ALL_PRODUCT_COPY_FILES += $(_fulldest)) \ - $(eval unique_product_copy_files_destinations += $(_dest)))) - - # Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries) -@@ -1989,6 +1991,11 @@ INTERNAL_VENDORIMAGE_FILES := \ - $(ALL_PDK_FUSION_FILES)) \ - $(PDK_FUSION_SYMLINK_STAMP) - -+INTERNAL_VENDORIMAGE_KERNEL_MODULES := \ -+ $(filter $(TARGET_OUT_VENDOR)/lib/modules/%,\ -+ $(ALL_DEFAULT_INSTALLED_MODULES)\ -+ $(ALL_PDK_FUSION_FILES)) -+ - # platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES). - $(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES) - -@@ -2018,7 +2025,7 @@ endef - - # We just build this directly to the install location. - INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET) --$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR) $(BUILD_IMAGE_SRCS) $(DEPMOD) $(BOARD_VENDOR_KERNEL_MODULES) -+$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(ALL_PRODUCT_COPY_FILES) $(INTERNAL_VENDORIMAGE_KERNEL_MODULES) $(filter fstab%, $(product_MODULES)) $(filter ueventd%, $(product_MODULES)) $(BUILD_IMAGE_SRCS) $(DEPMOD) $(BOARD_VENDOR_KERNEL_MODULES) - $(build-vendorimage-target) - - .PHONY: vendorimage-nodeps vnod --- -2.7.4 - diff --git a/frameworks/av/0001-hybris-AudioService-is-disabled-in-hybris-adaptation.patch b/frameworks/av/0001-hybris-AudioService-is-disabled-in-hybris-adaptation.patch index b066e79..cada968 100644 --- a/frameworks/av/0001-hybris-AudioService-is-disabled-in-hybris-adaptation.patch +++ b/frameworks/av/0001-hybris-AudioService-is-disabled-in-hybris-adaptation.patch @@ -1,36 +1,49 @@ -From 3b3570a33ce50318bb4eb6b4f9b4ede9665308b0 Mon Sep 17 00:00:00 2001 +From aadb47d6bedbb0052b7dc2a62b8fa6df3f65d536 Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Sun, 30 Oct 2016 14:07:11 +0000 -Subject: [PATCH 1/1] (hybris) AudioService is disabled in hybris adaptations +Subject: [PATCH] (hybris) AudioService is disabled in hybris adaptations +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit Without this patch, camera is waiting for AudioService indefinitely Change-Id: Id572746cc77c8d26e3a8e7fc1dc05b17ac282ed4 Signed-off-by: Simonas Leleiva +Signed-off-by: Björn Bidar --- - services/camera/libcameraservice/CameraService.cpp | 2 ++ - 1 file changed, 2 insertions(+) + services/camera/libcameraservice/CameraService.cpp | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp -index 2bf42b6..a760848 100644 +index 3e6210294..5950c63ee 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp -@@ -2025,6 +2025,7 @@ void CameraService::loadSound() { - LOG1("CameraService::loadSound ref=%d", mSoundRef); - if (mSoundRef++) return; - +@@ -2231,10 +2231,14 @@ void CameraService::increaseSoundRef() { + Mutex::Autolock lock(mSoundLock); + mSoundRef++; + } +- ++#if defined(__clang__) ++#pragma clang diagnostic push ++#pragma clang diagnostic ignored "-Wunused-parameter" ++#endif + void CameraService::loadSoundLocked(sound_kind kind) { + ATRACE_CALL(); +- ++#pragma clang diagnostic pop +/* - mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/product/media/audio/ui/camera_click.ogg"); - if (mSoundPlayer[SOUND_SHUTTER] == nullptr) { - mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg"); -@@ -2038,6 +2039,7 @@ void CameraService::loadSound() { - if (mSoundPlayer[SOUND_RECORDING_STOP] == nullptr) { - mSoundPlayer[SOUND_RECORDING_STOP] = newMediaPlayer("/system/media/audio/ui/VideoStop.ogg"); + LOG1("CameraService::loadSoundLocked ref=%d", mSoundRef); + if (SOUND_SHUTTER == kind && mSoundPlayer[SOUND_SHUTTER] == NULL) { + mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/product/media/audio/ui/camera_click.ogg"); +@@ -2253,6 +2257,7 @@ void CameraService::loadSoundLocked(sound_kind kind) { + mSoundPlayer[SOUND_RECORDING_STOP] = newMediaPlayer("/system/media/audio/ui/VideoStop.ogg"); + } } -+*/ ++ */ } - void CameraService::releaseSound() { + void CameraService::decreaseSoundRef() { -- -2.7.4 +2.23.0 diff --git a/frameworks/base/0001-hybris-Disable-some-tests-to-avoid-build-errors.patch b/frameworks/base/0001-hybris-Disable-some-tests-to-avoid-build-errors.patch new file mode 100644 index 0000000..3f9ea6a --- /dev/null +++ b/frameworks/base/0001-hybris-Disable-some-tests-to-avoid-build-errors.patch @@ -0,0 +1,51 @@ +From 79f3537ae0e6f7ec4f90eea3cb9964504bef59d2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= +Date: Mon, 21 Oct 2019 07:12:52 +0200 +Subject: [PATCH] (hybris) Disable some tests to avoid build errors. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Disables these tests to avoid build errors because some parts that +they need are disabled in the build system to minimize the build process. + +Change-Id: I14adf0fe1015491ac9d2ad8b2f7a570c695f2690 +Signed-off-by: Björn Bidar +--- + .../Android.mk | 23 ------------------- + 1 file changed, 23 deletions(-) + +diff --git a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/Android.mk b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/Android.mk +index a6f87ea2e5d..40c005e8e63 100644 +--- a/core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/Android.mk ++++ b/core/tests/hosttests/test-apps/MultiDexLegacyTestAppWithCorruptedDex/Android.mk +@@ -13,26 +13,3 @@ + # limitations under the License. + + LOCAL_PATH:= $(call my-dir) +- +-include $(CLEAR_VARS) +- +-LOCAL_MODULE_TAGS := tests +- +-LOCAL_SRC_FILES := $(call all-java-files-under, src) +- +-LOCAL_SDK_VERSION := 18 +- +-LOCAL_PACKAGE_NAME := MultiDexLegacyTestApp_corrupted +- +-LOCAL_STATIC_JAVA_LIBRARIES := android-support-multidex +- +-LOCAL_DEX_PREOPT := false +- +-include $(BUILD_PACKAGE) +- +-corrupted_classes2_dex := $(dir $(built_dex))/classes2.dex +- +-$(corrupted_classes2_dex): $(built_dex) +- $(hide) touch $@ +- +-$(LOCAL_BUILT_MODULE): $(corrupted_classes2_dex) +-- +2.23.0 + diff --git a/frameworks/native/0001-hybris-Use-mini-services-and-disable-starting-unneed.patch b/frameworks/native/0001-hybris-Use-mini-services-and-disable-starting-unneed.patch index 8ab7768..158ee9d 100644 --- a/frameworks/native/0001-hybris-Use-mini-services-and-disable-starting-unneed.patch +++ b/frameworks/native/0001-hybris-Use-mini-services-and-disable-starting-unneed.patch @@ -1,4 +1,4 @@ -From e58de07caa2c0c08b734a0ffa87bb2e9b8d2c020 Mon Sep 17 00:00:00 2001 +From 2d948dadf24d983b57b2777349b801cd046e14c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Thu, 13 Jul 2017 00:53:55 +0300 Subject: [PATCH 1/5] (hybris) Use mini services and disable starting unneeded @@ -6,14 +6,14 @@ Subject: [PATCH 1/5] (hybris) Use mini services and disable starting unneeded Change-Id: I6e80eb3e2d92ddfbd83f1933971c3f24e9570d28 --- - cmds/servicemanager/servicemanager.rc | 37 ++++++++++++++++++++++++++--------- - 1 file changed, 28 insertions(+), 9 deletions(-) + cmds/servicemanager/servicemanager.rc | 36 +++++++++++++++++++-------- + 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/cmds/servicemanager/servicemanager.rc b/cmds/servicemanager/servicemanager.rc -index 4d93cb4..1930612 100644 +index 152ac28ba..1f447f9b0 100644 --- a/cmds/servicemanager/servicemanager.rc +++ b/cmds/servicemanager/servicemanager.rc -@@ -4,14 +4,33 @@ service servicemanager /system/bin/servicemanager +@@ -4,15 +4,31 @@ service servicemanager /system/bin/servicemanager group system readproc critical onrestart restart healthd @@ -26,18 +26,17 @@ index 4d93cb4..1930612 100644 - onrestart restart cameraserver - onrestart restart keystore - onrestart restart gatekeeperd -+# onrestart restart zygote -+# onrestart restart audioserver -+# onrestart restart media -+# onrestart restart surfaceflinger -+# onrestart restart inputflinger -+# onrestart restart drm -+# onrestart restart cameraserver -+# onrestart restart keystore -+# onrestart restart gatekeeperd -+ onrestart restart miniaf -+ onrestart restart minimedia -+ onrestart restart minisf +- onrestart restart thermalservice ++ #onrestart restart zygote ++ #onrestart restart audioserver ++ #onrestart restart media ++ #onrestart restart surfaceflinger ++ #onrestart restart inputflinger ++ #onrestart restart drm ++ #onrestart restart cameraserver ++ #onrestart restart keystore ++ #onrestart restart gatekeeperd ++ #onrestart restart thermalservice writepid /dev/cpuset/system-background/tasks shutdown critical + @@ -57,5 +56,5 @@ index 4d93cb4..1930612 100644 + user system + group audio -- -2.7.4 +2.23.0 diff --git a/frameworks/native/0002-hybris-Pick-GLES-shared-objects-from-appropriate-pat.patch b/frameworks/native/0002-hybris-Pick-GLES-shared-objects-from-appropriate-pat.patch index acd09ae..4d1900c 100644 --- a/frameworks/native/0002-hybris-Pick-GLES-shared-objects-from-appropriate-pat.patch +++ b/frameworks/native/0002-hybris-Pick-GLES-shared-objects-from-appropriate-pat.patch @@ -1,4 +1,4 @@ -From 44eff29a55aed4d115ea468b00d4345ffcdf7a2d Mon Sep 17 00:00:00 2001 +From 2270d2fdcae29295e47b5b4ae87688b14a29defd Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Wed, 15 Jul 2015 08:29:08 +0000 Subject: [PATCH 2/5] (hybris) Pick GLES shared objects from appropriate paths @@ -11,10 +11,10 @@ Signed-off-by: Simonas Leleiva 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp -index 91a3455..386991a 100644 +index 038a43233..426b9d7de 100644 --- a/opengl/libs/EGL/Loader.cpp +++ b/opengl/libs/EGL/Loader.cpp -@@ -178,9 +178,9 @@ static void* load_wrapper(const char* path) { +@@ -140,9 +140,9 @@ static void* load_wrapper(const char* path) { #ifndef EGL_WRAPPER_DIR #if defined(__LP64__) @@ -26,19 +26,23 @@ index 91a3455..386991a 100644 #endif #endif -@@ -240,9 +240,9 @@ void* Loader::open(egl_connection_t* cnx) +@@ -320,13 +320,13 @@ void* Loader::open(egl_connection_t* cnx) + HAL_SUBNAME_KEY_PROPERTIES[0], HAL_SUBNAME_KEY_PROPERTIES[1]); - LOG_ALWAYS_FATAL_IF(!hnd, "couldn't find an OpenGL ES implementation"); + if (!cnx->libEgl) { +- cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so"); ++ cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "libEGL.so"); + } + if (!cnx->libGles1) { +- cnx->libGles1 = load_wrapper(EGL_WRAPPER_DIR "/libGLESv1_CM.so"); ++ cnx->libGles1 = load_wrapper(EGL_WRAPPER_DIR "libGLESv1_CM.so"); + } + if (!cnx->libGles2) { +- cnx->libGles2 = load_wrapper(EGL_WRAPPER_DIR "/libGLESv2.so"); ++ cnx->libGles2 = load_wrapper(EGL_WRAPPER_DIR "libGLESv2.so"); + } -- cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "/libEGL.so"); -- cnx->libGles2 = load_wrapper(EGL_WRAPPER_DIR "/libGLESv2.so"); -- cnx->libGles1 = load_wrapper(EGL_WRAPPER_DIR "/libGLESv1_CM.so"); -+ cnx->libEgl = load_wrapper(EGL_WRAPPER_DIR "libEGL.so"); -+ cnx->libGles2 = load_wrapper(EGL_WRAPPER_DIR "libGLESv2.so"); -+ cnx->libGles1 = load_wrapper(EGL_WRAPPER_DIR "libGLESv1_CM.so"); - - LOG_ALWAYS_FATAL_IF(!cnx->libEgl, - "couldn't load system EGL wrapper libraries"); + if (!cnx->libEgl || !cnx->libGles2 || !cnx->libGles1) { -- -2.7.4 +2.23.0 diff --git a/frameworks/native/0003-hybris-Use-private-__get_tls_hooks-from-bionic.patch b/frameworks/native/0003-hybris-Use-private-__get_tls_hooks-from-bionic.patch index 925e330..dd0ddf4 100644 --- a/frameworks/native/0003-hybris-Use-private-__get_tls_hooks-from-bionic.patch +++ b/frameworks/native/0003-hybris-Use-private-__get_tls_hooks-from-bionic.patch @@ -1,4 +1,4 @@ -From bb8d83f75b1b0a7eb2aeb63ef53fd83f750205b2 Mon Sep 17 00:00:00 2001 +From 5bc15a22820c54bc59f50209d189d28900846d54 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 25 Nov 2014 14:55:27 +0100 Subject: [PATCH 3/5] (hybris) Use private __get_tls_hooks from bionic @@ -11,10 +11,10 @@ Signed-off-by: David Greaves 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/opengl/libs/EGL/egl.cpp b/opengl/libs/EGL/egl.cpp -index f53cf3f..2d8a98a 100644 +index 25b1009ba..51a5582c7 100644 --- a/opengl/libs/EGL/egl.cpp +++ b/opengl/libs/EGL/egl.cpp -@@ -234,7 +234,7 @@ void gl_noop() { +@@ -241,7 +241,7 @@ void gl_noop() { // ---------------------------------------------------------------------------- void setGlThreadSpecific(gl_hooks_t const *value) { @@ -24,7 +24,7 @@ index f53cf3f..2d8a98a 100644 } diff --git a/opengl/libs/hooks.h b/opengl/libs/hooks.h -index 81dbe0e..dfb08a5 100644 +index 63a0e140c..9eac975f1 100644 --- a/opengl/libs/hooks.h +++ b/opengl/libs/hooks.h @@ -34,7 +34,7 @@ @@ -36,7 +36,7 @@ index 81dbe0e..dfb08a5 100644 #undef NELEM #define NELEM(x) (sizeof(x)/sizeof(*(x))) -@@ -76,16 +76,8 @@ struct gl_hooks_t { +@@ -80,16 +80,8 @@ struct gl_hooks_t { EGLAPI void setGlThreadSpecific(gl_hooks_t const *value); @@ -55,5 +55,5 @@ index 81dbe0e..dfb08a5 100644 return hooks; } -- -2.7.4 +2.23.0 diff --git a/frameworks/native/0004-hybris-Allow-surfaceflinger-to-be-started-from-Sailf.patch b/frameworks/native/0004-hybris-Allow-surfaceflinger-to-be-started-from-Sailf.patch index c1e829e..4018ba2 100644 --- a/frameworks/native/0004-hybris-Allow-surfaceflinger-to-be-started-from-Sailf.patch +++ b/frameworks/native/0004-hybris-Allow-surfaceflinger-to-be-started-from-Sailf.patch @@ -1,4 +1,4 @@ -From 43efb446b6872bdff454f1a67048e400345704f4 Mon Sep 17 00:00:00 2001 +From 22ca067d2f9d82d82b7be22431a3fab8c103dbbf Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Wed, 18 Apr 2018 19:00:03 +0200 Subject: [PATCH 4/5] (hybris) Allow surfaceflinger to be started from @@ -7,29 +7,13 @@ Subject: [PATCH 4/5] (hybris) Allow surfaceflinger to be started from Change-Id: Ibaecd8d27524bbb0d3bc7b40017bf92736b8629d Signed-off-by: Simonas Leleiva --- - services/surfaceflinger/Client.cpp | 2 +- - services/surfaceflinger/StartPropertySetThread.cpp | 5 +- - services/surfaceflinger/SurfaceFlinger.cpp | 6 +- - services/surfaceflinger/SurfaceFlinger_hwc1.cpp | 4078 ++++++++++++++++++++ - services/surfaceflinger/surfaceflinger.rc | 1 + - 5 files changed, 4086 insertions(+), 6 deletions(-) - create mode 100644 services/surfaceflinger/SurfaceFlinger_hwc1.cpp + services/surfaceflinger/StartPropertySetThread.cpp | 5 +++-- + services/surfaceflinger/SurfaceFlinger.cpp | 6 +++--- + services/surfaceflinger/surfaceflinger.rc | 1 + + 3 files changed, 7 insertions(+), 5 deletions(-) -diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp -index 0b59147..54ed16e 100644 ---- a/services/surfaceflinger/Client.cpp -+++ b/services/surfaceflinger/Client.cpp -@@ -131,7 +131,7 @@ status_t Client::onTransact( - // uid we require the sAccessSurfaceFlinger permission. - // We grant an exception in the case that the Client has a "parent layer", as its - // effects will be scoped to that layer. -- if (CC_UNLIKELY(pid != self_pid && uid != AID_GRAPHICS && uid != AID_SYSTEM && uid != 0) -+ if (CC_UNLIKELY(pid != self_pid && uid != AID_GRAPHICS && uid != AID_SYSTEM && uid != 0 && uid != 100000) - && (getParentLayer() == nullptr)) { - // we're called from a different process, do the real check - if (!PermissionCache::checkCallingPermission(sAccessSurfaceFlinger)) diff --git a/services/surfaceflinger/StartPropertySetThread.cpp b/services/surfaceflinger/StartPropertySetThread.cpp -index db82772..27cc95a 100644 +index db82772f4..27cc95abc 100644 --- a/services/surfaceflinger/StartPropertySetThread.cpp +++ b/services/surfaceflinger/StartPropertySetThread.cpp @@ -29,10 +29,11 @@ status_t StartPropertySetThread::Start() { @@ -47,28 +31,19 @@ index db82772..27cc95a 100644 return false; } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp -index 25cb589..4a18104 100644 +index 6166789fc..f4c338f54 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp -@@ -3412,7 +3412,7 @@ bool callingThreadHasUnscopedSurfaceFlingerAccess() { +@@ -3882,7 +3882,7 @@ bool SurfaceFlinger::callingThreadHasUnscopedSurfaceFlingerAccess() { + IPCThreadState* ipc = IPCThreadState::self(); const int pid = ipc->getCallingPid(); const int uid = ipc->getCallingUid(); - - if ((uid != AID_GRAPHICS && uid != AID_SYSTEM) && -+ if ((uid != AID_GRAPHICS && uid != AID_SYSTEM && uid != 100000) && - !PermissionCache::checkPermission(sAccessSurfaceFlinger, pid, uid)) { ++ if ((uid != AID_GRAPHICS && uid != AID_SYSTEM && uid != 10000) && + !PermissionCache::checkPermission(sAccessSurfaceFlinger, pid, uid)) { return false; } -@@ -4566,7 +4566,7 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) { - IPCThreadState* ipc = IPCThreadState::self(); - const int pid = ipc->getCallingPid(); - const int uid = ipc->getCallingUid(); -- if ((uid != AID_GRAPHICS) && -+ if ((uid != AID_GRAPHICS && uid != 100000) && - !PermissionCache::checkPermission(sReadFramebuffer, pid, uid)) { - ALOGE("Permission Denial: can't read framebuffer pid=%d, uid=%d", pid, uid); - return PERMISSION_DENIED; -@@ -4577,7 +4577,7 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) { +@@ -5134,7 +5134,7 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) { IPCThreadState* ipc = IPCThreadState::self(); const int pid = ipc->getCallingPid(); const int uid = ipc->getCallingUid(); @@ -77,4092 +52,17 @@ index 25cb589..4a18104 100644 !PermissionCache::checkPermission(sReadFramebuffer, pid, uid)) { ALOGE("Permission Denial: can't read framebuffer pid=%d, uid=%d", pid, uid); return PERMISSION_DENIED; -diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp -new file mode 100644 -index 0000000..cafd666 ---- /dev/null -+++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp -@@ -0,0 +1,4078 @@ -+/* -+ * Copyright (C) 2007 The Android Open Source Project -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#define ATRACE_TAG ATRACE_TAG_GRAPHICS -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include -+ -+#include -+#include -+ -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include -+ -+#include "Client.h" -+#include "clz.h" -+#include "Colorizer.h" -+#include "DdmConnection.h" -+#include "DisplayDevice.h" -+#include "DispSync.h" -+#include "EventControlThread.h" -+#include "EventThread.h" -+#include "Layer.h" -+#include "LayerVector.h" -+#include "LayerDim.h" -+#include "MonitoredProducer.h" -+#include "SurfaceFlinger.h" -+ -+#include "DisplayHardware/FramebufferSurface.h" -+#include "DisplayHardware/HWComposer.h" -+#include "DisplayHardware/VirtualDisplaySurface.h" -+ -+#include "Effects/Daltonizer.h" -+ -+#include "RenderEngine/RenderEngine.h" -+#include -+ -+#include -+#include -+ -+#define DISPLAY_COUNT 1 -+ -+/* -+ * DEBUG_SCREENSHOTS: set to true to check that screenshots are not all -+ * black pixels. -+ */ -+#define DEBUG_SCREENSHOTS false -+ -+extern "C" EGLAPI const char* eglQueryStringImplementationANDROID(EGLDisplay dpy, EGLint name); -+ -+namespace android { -+// --------------------------------------------------------------------------- -+ -+using namespace android::hardware::configstore; -+using namespace android::hardware::configstore::V1_0; -+ -+const String16 sHardwareTest("android.permission.HARDWARE_TEST"); -+const String16 sAccessSurfaceFlinger("android.permission.ACCESS_SURFACE_FLINGER"); -+const String16 sReadFramebuffer("android.permission.READ_FRAME_BUFFER"); -+const String16 sDump("android.permission.DUMP"); -+ -+// --------------------------------------------------------------------------- -+int64_t SurfaceFlinger::vsyncPhaseOffsetNs; -+int64_t SurfaceFlinger::sfVsyncPhaseOffsetNs; -+bool SurfaceFlinger::useContextPriority; -+int64_t SurfaceFlinger::dispSyncPresentTimeOffset; -+bool SurfaceFlinger::useHwcForRgbToYuv; -+uint64_t SurfaceFlinger::maxVirtualDisplaySize; -+bool SurfaceFlinger::hasSyncFramework; -+int64_t SurfaceFlinger::maxFrameBufferAcquiredBuffers; -+ -+SurfaceFlinger::SurfaceFlinger() -+ : BnSurfaceComposer(), -+ mTransactionFlags(0), -+ mTransactionPending(false), -+ mAnimTransactionPending(false), -+ mLayersRemoved(false), -+ mLayersAdded(false), -+ mRepaintEverything(0), -+ mRenderEngine(NULL), -+ mBootTime(systemTime()), -+ mVisibleRegionsDirty(false), -+ mHwWorkListDirty(false), -+ mAnimCompositionPending(false), -+ mDebugRegion(0), -+ mDebugDDMS(0), -+ mDebugDisableHWC(0), -+ mDebugDisableTransformHint(0), -+ mDebugInSwapBuffers(0), -+ mLastSwapBufferTime(0), -+ mDebugInTransaction(0), -+ mLastTransactionTime(0), -+ mBootFinished(false), -+ mForceFullDamage(false), -+ mInterceptor(this), -+ mPrimaryDispSync("PrimaryDispSync"), -+ mPrimaryHWVsyncEnabled(false), -+ mHWVsyncAvailable(false), -+ mDaltonize(false), -+ mHasColorMatrix(false), -+ mHasPoweredOff(false), -+ mFrameBuckets(), -+ mTotalTime(0), -+ mLastSwapTime(0), -+ mNumLayers(0) -+{ -+ ALOGI("SurfaceFlinger is starting"); -+ -+ vsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs, -+ &ISurfaceFlingerConfigs::vsyncEventPhaseOffsetNs>(1000000); -+ -+ sfVsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs, -+ &ISurfaceFlingerConfigs::vsyncSfEventPhaseOffsetNs>(1000000); -+ -+ maxVirtualDisplaySize = getUInt64(0); -+ -+ hasSyncFramework = getBool< ISurfaceFlingerConfigs, -+ &ISurfaceFlingerConfigs::hasSyncFramework>(true); -+ -+ useContextPriority = getBool< ISurfaceFlingerConfigs, -+ &ISurfaceFlingerConfigs::useContextPriority>(false); -+ -+ dispSyncPresentTimeOffset = getInt64< ISurfaceFlingerConfigs, -+ &ISurfaceFlingerConfigs::presentTimeOffsetFromVSyncNs>(0); -+ -+ useHwcForRgbToYuv = getBool< ISurfaceFlingerConfigs, -+ &ISurfaceFlingerConfigs::useHwcForRGBtoYUV>(false); -+ -+ maxFrameBufferAcquiredBuffers = getInt64< ISurfaceFlingerConfigs, -+ &ISurfaceFlingerConfigs::maxFrameBufferAcquiredBuffers>(2); -+ -+ char value[PROPERTY_VALUE_MAX]; -+ -+ property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); -+ mGpuToCpuSupported = !atoi(value); -+ -+ property_get("debug.sf.showupdates", value, "0"); -+ mDebugRegion = atoi(value); -+ -+ property_get("debug.sf.ddms", value, "0"); -+ mDebugDDMS = atoi(value); -+ if (mDebugDDMS) { -+ if (!startDdmConnection()) { -+ // start failed, and DDMS debugging not enabled -+ mDebugDDMS = 0; -+ } -+ } -+ ALOGI_IF(mDebugRegion, "showupdates enabled"); -+ ALOGI_IF(mDebugDDMS, "DDMS debugging enabled"); -+ -+ property_get("debug.sf.enable_hwc_vds", value, "0"); -+ mUseHwcVirtualDisplays = atoi(value); -+ ALOGI_IF(!mUseHwcVirtualDisplays, "Enabling HWC virtual displays"); -+ -+ property_get("ro.sf.disable_triple_buffer", value, "1"); -+ mLayerTripleBufferingDisabled = atoi(value); -+ ALOGI_IF(mLayerTripleBufferingDisabled, "Disabling Triple Buffering"); -+} -+ -+void SurfaceFlinger::onFirstRef() -+{ -+ mEventQueue.init(this); -+} -+ -+SurfaceFlinger::~SurfaceFlinger() -+{ -+ EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); -+ eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); -+ eglTerminate(display); -+} -+ -+void SurfaceFlinger::binderDied(const wp& /* who */) -+{ -+ // the window manager died on us. prepare its eulogy. -+ -+ // restore initial conditions (default device unblank, etc) -+ initializeDisplays(); -+ -+ // restart the boot-animation -+ startBootAnim(); -+} -+ -+static sp initClient(const sp& client) { -+ status_t err = client->initCheck(); -+ if (err == NO_ERROR) { -+ return client; -+ } -+ return nullptr; -+} -+ -+sp SurfaceFlinger::createConnection() { -+ return initClient(new Client(this)); -+} -+ -+sp SurfaceFlinger::createScopedConnection( -+ const sp& gbp) { -+ if (authenticateSurfaceTexture(gbp) == false) { -+ return nullptr; -+ } -+ const auto& layer = (static_cast(gbp.get()))->getLayer(); -+ if (layer == nullptr) { -+ return nullptr; -+ } -+ -+ return initClient(new Client(this, layer)); -+} -+ -+sp SurfaceFlinger::createDisplay(const String8& displayName, -+ bool secure) -+{ -+ class DisplayToken : public BBinder { -+ sp flinger; -+ virtual ~DisplayToken() { -+ // no more references, this display must be terminated -+ Mutex::Autolock _l(flinger->mStateLock); -+ flinger->mCurrentState.displays.removeItem(this); -+ flinger->setTransactionFlags(eDisplayTransactionNeeded); -+ } -+ public: -+ explicit DisplayToken(const sp& flinger) -+ : flinger(flinger) { -+ } -+ }; -+ -+ sp token = new DisplayToken(this); -+ -+ Mutex::Autolock _l(mStateLock); -+ DisplayDeviceState info(DisplayDevice::DISPLAY_VIRTUAL, secure); -+ info.displayName = displayName; -+ mCurrentState.displays.add(token, info); -+ mInterceptor.saveDisplayCreation(info); -+ return token; -+} -+ -+void SurfaceFlinger::destroyDisplay(const sp& display) { -+ Mutex::Autolock _l(mStateLock); -+ -+ ssize_t idx = mCurrentState.displays.indexOfKey(display); -+ if (idx < 0) { -+ ALOGW("destroyDisplay: invalid display token"); -+ return; -+ } -+ -+ const DisplayDeviceState& info(mCurrentState.displays.valueAt(idx)); -+ if (!info.isVirtualDisplay()) { -+ ALOGE("destroyDisplay called for non-virtual display"); -+ return; -+ } -+ mInterceptor.saveDisplayDeletion(info.displayId); -+ mCurrentState.displays.removeItemsAt(idx); -+ setTransactionFlags(eDisplayTransactionNeeded); -+} -+ -+void SurfaceFlinger::createBuiltinDisplayLocked(DisplayDevice::DisplayType type) { -+ ALOGW_IF(mBuiltinDisplays[type], -+ "Overwriting display token for display type %d", type); -+ mBuiltinDisplays[type] = new BBinder(); -+ // All non-virtual displays are currently considered secure. -+ DisplayDeviceState info(type, true); -+ mCurrentState.displays.add(mBuiltinDisplays[type], info); -+ mInterceptor.saveDisplayCreation(info); -+} -+ -+sp SurfaceFlinger::getBuiltInDisplay(int32_t id) { -+ if (uint32_t(id) >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { -+ ALOGE("getDefaultDisplay: id=%d is not a valid default display id", id); -+ return NULL; -+ } -+ return mBuiltinDisplays[id]; -+} -+ -+void SurfaceFlinger::bootFinished() -+{ -+ if (mStartPropertySetThread->join() != NO_ERROR) { -+ ALOGE("Join StartPropertySetThread failed!"); -+ } -+ const nsecs_t now = systemTime(); -+ const nsecs_t duration = now - mBootTime; -+ ALOGI("Boot is finished (%ld ms)", long(ns2ms(duration)) ); -+ mBootFinished = true; -+ -+ // wait patiently for the window manager death -+ const String16 name("window"); -+ sp window(defaultServiceManager()->getService(name)); -+ if (window != 0) { -+ window->linkToDeath(static_cast(this)); -+ } -+ -+ // stop boot animation -+ // formerly we would just kill the process, but we now ask it to exit so it -+ // can choose where to stop the animation. -+ property_set("service.bootanim.exit", "1"); -+ -+ const int LOGTAG_SF_STOP_BOOTANIM = 60110; -+ LOG_EVENT_LONG(LOGTAG_SF_STOP_BOOTANIM, -+ ns2ms(systemTime(SYSTEM_TIME_MONOTONIC))); -+} -+ -+void SurfaceFlinger::deleteTextureAsync(uint32_t texture) { -+ class MessageDestroyGLTexture : public MessageBase { -+ RenderEngine& engine; -+ uint32_t texture; -+ public: -+ MessageDestroyGLTexture(RenderEngine& engine, uint32_t texture) -+ : engine(engine), texture(texture) { -+ } -+ virtual bool handler() { -+ engine.deleteTextures(1, &texture); -+ return true; -+ } -+ }; -+ postMessageAsync(new MessageDestroyGLTexture(getRenderEngine(), texture)); -+} -+ -+class DispSyncSource : public VSyncSource, private DispSync::Callback { -+public: -+ DispSyncSource(DispSync* dispSync, nsecs_t phaseOffset, bool traceVsync, -+ const char* name) : -+ mName(name), -+ mValue(0), -+ mTraceVsync(traceVsync), -+ mVsyncOnLabel(String8::format("VsyncOn-%s", name)), -+ mVsyncEventLabel(String8::format("VSYNC-%s", name)), -+ mDispSync(dispSync), -+ mCallbackMutex(), -+ mCallback(), -+ mVsyncMutex(), -+ mPhaseOffset(phaseOffset), -+ mEnabled(false) {} -+ -+ virtual ~DispSyncSource() {} -+ -+ virtual void setVSyncEnabled(bool enable) { -+ Mutex::Autolock lock(mVsyncMutex); -+ if (enable) { -+ status_t err = mDispSync->addEventListener(mName, mPhaseOffset, -+ static_cast(this)); -+ if (err != NO_ERROR) { -+ ALOGE("error registering vsync callback: %s (%d)", -+ strerror(-err), err); -+ } -+ //ATRACE_INT(mVsyncOnLabel.string(), 1); -+ } else { -+ status_t err = mDispSync->removeEventListener( -+ static_cast(this)); -+ if (err != NO_ERROR) { -+ ALOGE("error unregistering vsync callback: %s (%d)", -+ strerror(-err), err); -+ } -+ //ATRACE_INT(mVsyncOnLabel.string(), 0); -+ } -+ mEnabled = enable; -+ } -+ -+ virtual void setCallback(const sp& callback) { -+ Mutex::Autolock lock(mCallbackMutex); -+ mCallback = callback; -+ } -+ -+ virtual void setPhaseOffset(nsecs_t phaseOffset) { -+ Mutex::Autolock lock(mVsyncMutex); -+ -+ // Normalize phaseOffset to [0, period) -+ auto period = mDispSync->getPeriod(); -+ phaseOffset %= period; -+ if (phaseOffset < 0) { -+ // If we're here, then phaseOffset is in (-period, 0). After this -+ // operation, it will be in (0, period) -+ phaseOffset += period; -+ } -+ mPhaseOffset = phaseOffset; -+ -+ // If we're not enabled, we don't need to mess with the listeners -+ if (!mEnabled) { -+ return; -+ } -+ -+ // Remove the listener with the old offset -+ status_t err = mDispSync->removeEventListener( -+ static_cast(this)); -+ if (err != NO_ERROR) { -+ ALOGE("error unregistering vsync callback: %s (%d)", -+ strerror(-err), err); -+ } -+ -+ // Add a listener with the new offset -+ err = mDispSync->addEventListener(mName, mPhaseOffset, -+ static_cast(this)); -+ if (err != NO_ERROR) { -+ ALOGE("error registering vsync callback: %s (%d)", -+ strerror(-err), err); -+ } -+ } -+ -+private: -+ virtual void onDispSyncEvent(nsecs_t when) { -+ sp callback; -+ { -+ Mutex::Autolock lock(mCallbackMutex); -+ callback = mCallback; -+ -+ if (mTraceVsync) { -+ mValue = (mValue + 1) % 2; -+ ATRACE_INT(mVsyncEventLabel.string(), mValue); -+ } -+ } -+ -+ if (callback != NULL) { -+ callback->onVSyncEvent(when); -+ } -+ } -+ -+ const char* const mName; -+ -+ int mValue; -+ -+ const bool mTraceVsync; -+ const String8 mVsyncOnLabel; -+ const String8 mVsyncEventLabel; -+ -+ DispSync* mDispSync; -+ -+ Mutex mCallbackMutex; // Protects the following -+ sp mCallback; -+ -+ Mutex mVsyncMutex; // Protects the following -+ nsecs_t mPhaseOffset; -+ bool mEnabled; -+}; -+ -+class InjectVSyncSource : public VSyncSource { -+public: -+ InjectVSyncSource() {} -+ -+ virtual ~InjectVSyncSource() {} -+ -+ virtual void setCallback(const sp& callback) { -+ std::lock_guard lock(mCallbackMutex); -+ mCallback = callback; -+ } -+ -+ virtual void onInjectSyncEvent(nsecs_t when) { -+ std::lock_guard lock(mCallbackMutex); -+ mCallback->onVSyncEvent(when); -+ } -+ -+ virtual void setVSyncEnabled(bool) {} -+ virtual void setPhaseOffset(nsecs_t) {} -+ -+private: -+ std::mutex mCallbackMutex; // Protects the following -+ sp mCallback; -+}; -+ -+// Do not call property_set on main thread which will be blocked by init -+// Use StartPropertySetThread instead. -+void SurfaceFlinger::init() { -+ ALOGI( "SurfaceFlinger's main thread ready to run. " -+ "Initializing graphics H/W..."); -+ -+ Mutex::Autolock _l(mStateLock); -+ -+ // initialize EGL for the default display -+ mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); -+ eglInitialize(mEGLDisplay, NULL, NULL); -+ -+ // start the EventThread -+ sp vsyncSrc = new DispSyncSource(&mPrimaryDispSync, -+ vsyncPhaseOffsetNs, true, "app"); -+ mEventThread = new EventThread(vsyncSrc, *this, false); -+ sp sfVsyncSrc = new DispSyncSource(&mPrimaryDispSync, -+ sfVsyncPhaseOffsetNs, true, "sf"); -+ mSFEventThread = new EventThread(sfVsyncSrc, *this, true); -+ mEventQueue.setEventThread(mSFEventThread); -+ -+ // set EventThread and SFEventThread to SCHED_FIFO to minimize jitter -+ struct sched_param param = {0}; -+ param.sched_priority = 2; -+ if (sched_setscheduler(mSFEventThread->getTid(), SCHED_FIFO, ¶m) != 0) { -+ ALOGE("Couldn't set SCHED_FIFO for SFEventThread"); -+ } -+ if (sched_setscheduler(mEventThread->getTid(), SCHED_FIFO, ¶m) != 0) { -+ ALOGE("Couldn't set SCHED_FIFO for EventThread"); -+ } -+ -+ // Initialize the H/W composer object. There may or may not be an -+ // actual hardware composer underneath. -+ mHwc.reset(new HWComposer(this, -+ *static_cast(this))); -+ -+ // get a RenderEngine for the given display / config (can't fail) -+ mRenderEngine = RenderEngine::create(mEGLDisplay, -+ mHwc->getVisualID(), 0); -+ -+ // retrieve the EGL context that was selected/created -+ mEGLContext = mRenderEngine->getEGLContext(); -+ -+ LOG_ALWAYS_FATAL_IF(mEGLContext == EGL_NO_CONTEXT, -+ "couldn't create EGLContext"); -+ -+ // initialize our non-virtual displays -+ for (size_t i=0 ; iisConnected(i) || type==DisplayDevice::DISPLAY_PRIMARY) { -+ // All non-virtual displays are currently considered secure. -+ bool isSecure = true; -+ createBuiltinDisplayLocked(type); -+ wp token = mBuiltinDisplays[i]; -+ -+ sp producer; -+ sp consumer; -+ BufferQueue::createBufferQueue(&producer, &consumer); -+ -+ sp fbs = new FramebufferSurface(*mHwc, i, -+ consumer); -+ int32_t hwcId = allocateHwcDisplayId(type); -+ sp hw = new DisplayDevice(this, -+ type, hwcId, mHwc->getFormat(hwcId), isSecure, token, -+ fbs, producer, -+ mRenderEngine->getEGLConfig(), false); -+ if (i > DisplayDevice::DISPLAY_PRIMARY) { -+ // FIXME: currently we don't get blank/unblank requests -+ // for displays other than the main display, so we always -+ // assume a connected display is unblanked. -+ ALOGD("marking display %zu as acquired/unblanked", i); -+ hw->setPowerMode(HWC_POWER_MODE_NORMAL); -+ } -+ mDisplays.add(token, hw); -+ } -+ } -+ -+ // make the GLContext current so that we can create textures when creating Layers -+ // (which may happens before we render something) -+ getDefaultDisplayDeviceLocked()->makeCurrent(mEGLDisplay, mEGLContext); -+ -+ mEventControlThread = new EventControlThread(this); -+ mEventControlThread->run("EventControl", PRIORITY_URGENT_DISPLAY); -+ -+ // set a fake vsync period if there is no HWComposer -+ if (mHwc->initCheck() != NO_ERROR) { -+ mPrimaryDispSync.setPeriod(16666667); -+ } -+ -+ // initialize our drawing state -+ mDrawingState = mCurrentState; -+ -+ // set initial conditions (e.g. unblank default device) -+ initializeDisplays(); -+ -+ mRenderEngine->primeCache(); -+ -+ // Inform native graphics APIs that the present timestamp is NOT supported: -+ mStartPropertySetThread = new StartPropertySetThread(false); -+ if (mStartPropertySetThread->Start() != NO_ERROR) { -+ ALOGE("Run StartPropertySetThread failed!"); -+ } -+ -+ ALOGV("Done initializing"); -+} -+ -+int32_t SurfaceFlinger::allocateHwcDisplayId(DisplayDevice::DisplayType type) { -+ return (uint32_t(type) < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) ? -+ type : mHwc->allocateDisplayId(); -+} -+ -+void SurfaceFlinger::startBootAnim() { -+ // Start boot animation service by setting a property mailbox -+ // if property setting thread is already running, Start() will be just a NOP -+ mStartPropertySetThread->Start(); -+ // Wait until property was set -+ if (mStartPropertySetThread->join() != NO_ERROR) { -+ ALOGE("Join StartPropertySetThread failed!"); -+ } -+} -+ -+size_t SurfaceFlinger::getMaxTextureSize() const { -+ return mRenderEngine->getMaxTextureSize(); -+} -+ -+size_t SurfaceFlinger::getMaxViewportDims() const { -+ return mRenderEngine->getMaxViewportDims(); -+} -+ -+// ---------------------------------------------------------------------------- -+ -+bool SurfaceFlinger::authenticateSurfaceTexture( -+ const sp& bufferProducer) const { -+ Mutex::Autolock _l(mStateLock); -+ return authenticateSurfaceTextureLocked(bufferProducer); -+} -+ -+bool SurfaceFlinger::authenticateSurfaceTextureLocked( -+ const sp& bufferProducer) const { -+ sp surfaceTextureBinder(IInterface::asBinder(bufferProducer)); -+ return mGraphicBufferProducerList.indexOf(surfaceTextureBinder) >= 0; -+} -+ -+status_t SurfaceFlinger::getSupportedFrameTimestamps( -+ std::vector* outSupported) const { -+ *outSupported = { -+ FrameEvent::REQUESTED_PRESENT, -+ FrameEvent::ACQUIRE, -+ FrameEvent::LATCH, -+ FrameEvent::FIRST_REFRESH_START, -+ FrameEvent::LAST_REFRESH_START, -+ FrameEvent::GPU_COMPOSITION_DONE, -+ FrameEvent::DEQUEUE_READY, -+ FrameEvent::RELEASE, -+ }; -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::getDisplayConfigs(const sp& display, -+ Vector* configs) { -+ if ((configs == NULL) || (display.get() == NULL)) { -+ return BAD_VALUE; -+ } -+ -+ int32_t type = getDisplayType(display); -+ if (type < 0) return type; -+ -+ // TODO: Not sure if display density should handled by SF any longer -+ class Density { -+ static int getDensityFromProperty(char const* propName) { -+ char property[PROPERTY_VALUE_MAX]; -+ int density = 0; -+ if (property_get(propName, property, NULL) > 0) { -+ density = atoi(property); -+ } -+ return density; -+ } -+ public: -+ static int getEmuDensity() { -+ return getDensityFromProperty("qemu.sf.lcd_density"); } -+ static int getBuildDensity() { -+ return getDensityFromProperty("ro.sf.lcd_density"); } -+ }; -+ -+ configs->clear(); -+ -+ const Vector& hwConfigs = -+ getHwComposer().getConfigs(type); -+ for (size_t c = 0; c < hwConfigs.size(); ++c) { -+ const HWComposer::DisplayConfig& hwConfig = hwConfigs[c]; -+ DisplayInfo info = DisplayInfo(); -+ -+ float xdpi = hwConfig.xdpi; -+ float ydpi = hwConfig.ydpi; -+ -+ if (type == DisplayDevice::DISPLAY_PRIMARY) { -+ // The density of the device is provided by a build property -+ float density = Density::getBuildDensity() / 160.0f; -+ if (density == 0) { -+ // the build doesn't provide a density -- this is wrong! -+ // use xdpi instead -+ ALOGE("ro.sf.lcd_density must be defined as a build property"); -+ density = xdpi / 160.0f; -+ } -+ if (Density::getEmuDensity()) { -+ // if "qemu.sf.lcd_density" is specified, it overrides everything -+ xdpi = ydpi = density = Density::getEmuDensity(); -+ density /= 160.0f; -+ } -+ info.density = density; -+ -+ // TODO: this needs to go away (currently needed only by webkit) -+ sp hw(getDefaultDisplayDevice()); -+ info.orientation = hw->getOrientation(); -+ } else { -+ // TODO: where should this value come from? -+ static const int TV_DENSITY = 213; -+ info.density = TV_DENSITY / 160.0f; -+ info.orientation = 0; -+ } -+ -+ info.w = hwConfig.width; -+ info.h = hwConfig.height; -+ info.xdpi = xdpi; -+ info.ydpi = ydpi; -+ info.fps = float(1e9 / hwConfig.refresh); -+ info.appVsyncOffset = vsyncPhaseOffsetNs; -+ -+ // This is how far in advance a buffer must be queued for -+ // presentation at a given time. If you want a buffer to appear -+ // on the screen at time N, you must submit the buffer before -+ // (N - presentationDeadline). -+ // -+ // Normally it's one full refresh period (to give SF a chance to -+ // latch the buffer), but this can be reduced by configuring a -+ // DispSync offset. Any additional delays introduced by the hardware -+ // composer or panel must be accounted for here. -+ // -+ // We add an additional 1ms to allow for processing time and -+ // differences between the ideal and actual refresh rate. -+ info.presentationDeadline = -+ hwConfig.refresh - sfVsyncPhaseOffsetNs + 1000000; -+ -+ // All non-virtual displays are currently considered secure. -+ info.secure = true; -+ -+ configs->push_back(info); -+ } -+ -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::getDisplayStats(const sp& /* display */, -+ DisplayStatInfo* stats) { -+ if (stats == NULL) { -+ return BAD_VALUE; -+ } -+ -+ // FIXME for now we always return stats for the primary display -+ memset(stats, 0, sizeof(*stats)); -+ stats->vsyncTime = mPrimaryDispSync.computeNextRefresh(0); -+ stats->vsyncPeriod = mPrimaryDispSync.getPeriod(); -+ return NO_ERROR; -+} -+ -+int SurfaceFlinger::getActiveConfig(const sp& display) { -+ sp device(getDisplayDevice(display)); -+ if (device != NULL) { -+ return device->getActiveConfig(); -+ } -+ return BAD_VALUE; -+} -+ -+void SurfaceFlinger::setActiveConfigInternal(const sp& hw, int mode) { -+ ALOGD("Set active config mode=%d, type=%d flinger=%p", mode, hw->getDisplayType(), -+ this); -+ int32_t type = hw->getDisplayType(); -+ int currentMode = hw->getActiveConfig(); -+ -+ if (mode == currentMode) { -+ ALOGD("Screen type=%d is already mode=%d", hw->getDisplayType(), mode); -+ return; -+ } -+ -+ if (type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { -+ ALOGW("Trying to set config for virtual display"); -+ return; -+ } -+ -+ hw->setActiveConfig(mode); -+ getHwComposer().setActiveConfig(type, mode); -+} -+ -+status_t SurfaceFlinger::setActiveConfig(const sp& display, int mode) { -+ class MessageSetActiveConfig: public MessageBase { -+ SurfaceFlinger& mFlinger; -+ sp mDisplay; -+ int mMode; -+ public: -+ MessageSetActiveConfig(SurfaceFlinger& flinger, const sp& disp, -+ int mode) : -+ mFlinger(flinger), mDisplay(disp) { mMode = mode; } -+ virtual bool handler() { -+ Vector configs; -+ mFlinger.getDisplayConfigs(mDisplay, &configs); -+ if (mMode < 0 || mMode >= static_cast(configs.size())) { -+ ALOGE("Attempt to set active config = %d for display with %zu configs", -+ mMode, configs.size()); -+ } -+ sp hw(mFlinger.getDisplayDevice(mDisplay)); -+ if (hw == NULL) { -+ ALOGE("Attempt to set active config = %d for null display %p", -+ mMode, mDisplay.get()); -+ } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) { -+ ALOGW("Attempt to set active config = %d for virtual display", -+ mMode); -+ } else { -+ mFlinger.setActiveConfigInternal(hw, mMode); -+ } -+ return true; -+ } -+ }; -+ sp msg = new MessageSetActiveConfig(*this, display, mode); -+ postMessageSync(msg); -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::getDisplayColorModes(const sp& display, -+ Vector* outColorModes) { -+ if (outColorModes == nullptr || display.get() == nullptr) { -+ return BAD_VALUE; -+ } -+ -+ int32_t type = getDisplayType(display); -+ if (type < 0) return type; -+ -+ std::set colorModes; -+ for (const HWComposer::DisplayConfig& hwConfig : getHwComposer().getConfigs(type)) { -+ colorModes.insert(hwConfig.colorMode); -+ } -+ -+ outColorModes->clear(); -+ std::copy(colorModes.cbegin(), colorModes.cend(), std::back_inserter(*outColorModes)); -+ -+ return NO_ERROR; -+} -+ -+android_color_mode_t SurfaceFlinger::getActiveColorMode(const sp& display) { -+ if (display.get() == nullptr) return static_cast(BAD_VALUE); -+ -+ int32_t type = getDisplayType(display); -+ if (type < 0) return static_cast(type); -+ -+ return getHwComposer().getColorMode(type); -+} -+ -+status_t SurfaceFlinger::setActiveColorMode(const sp& display, -+ android_color_mode_t colorMode) { -+ if (display.get() == nullptr || colorMode < 0) { -+ return BAD_VALUE; -+ } -+ -+ int32_t type = getDisplayType(display); -+ if (type < 0) return type; -+ const Vector& hwConfigs = getHwComposer().getConfigs(type); -+ HWComposer::DisplayConfig desiredConfig = hwConfigs[getHwComposer().getCurrentConfig(type)]; -+ desiredConfig.colorMode = colorMode; -+ for (size_t c = 0; c < hwConfigs.size(); ++c) { -+ const HWComposer::DisplayConfig config = hwConfigs[c]; -+ if (config == desiredConfig) { -+ return setActiveConfig(display, c); -+ } -+ } -+ return BAD_VALUE; -+} -+ -+status_t SurfaceFlinger::clearAnimationFrameStats() { -+ Mutex::Autolock _l(mStateLock); -+ mAnimFrameTracker.clearStats(); -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::getAnimationFrameStats(FrameStats* outStats) const { -+ Mutex::Autolock _l(mStateLock); -+ mAnimFrameTracker.getStats(outStats); -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::getHdrCapabilities(const sp& /*display*/, -+ HdrCapabilities* outCapabilities) const { -+ // HWC1 does not provide HDR capabilities -+ *outCapabilities = HdrCapabilities(); -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::enableVSyncInjections(bool enable) { -+ if (enable == mInjectVSyncs) { -+ return NO_ERROR; -+ } -+ -+ if (enable) { -+ mInjectVSyncs = enable; -+ ALOGV("VSync Injections enabled"); -+ if (mVSyncInjector.get() == nullptr) { -+ mVSyncInjector = new InjectVSyncSource(); -+ mInjectorEventThread = new EventThread(mVSyncInjector, *this, false); -+ } -+ mEventQueue.setEventThread(mInjectorEventThread); -+ } else { -+ mInjectVSyncs = enable; -+ ALOGV("VSync Injections disabled"); -+ mEventQueue.setEventThread(mSFEventThread); -+ mVSyncInjector.clear(); -+ } -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::injectVSync(nsecs_t when) { -+ if (!mInjectVSyncs) { -+ ALOGE("VSync Injections not enabled"); -+ return BAD_VALUE; -+ } -+ if (mInjectVSyncs && mInjectorEventThread.get() != nullptr) { -+ ALOGV("Injecting VSync inside SurfaceFlinger"); -+ mVSyncInjector->onInjectSyncEvent(when); -+ } -+ return NO_ERROR; -+} -+ -+// ---------------------------------------------------------------------------- -+ -+sp SurfaceFlinger::createDisplayEventConnection( -+ ISurfaceComposer::VsyncSource vsyncSource) { -+ if (vsyncSource == eVsyncSourceSurfaceFlinger) { -+ return mSFEventThread->createEventConnection(); -+ } else { -+ return mEventThread->createEventConnection(); -+ } -+} -+ -+// ---------------------------------------------------------------------------- -+ -+void SurfaceFlinger::waitForEvent() { -+ mEventQueue.waitMessage(); -+} -+ -+void SurfaceFlinger::signalTransaction() { -+ mEventQueue.invalidate(); -+} -+ -+void SurfaceFlinger::signalLayerUpdate() { -+ mEventQueue.invalidate(); -+} -+ -+void SurfaceFlinger::signalRefresh() { -+ mEventQueue.refresh(); -+} -+ -+status_t SurfaceFlinger::postMessageAsync(const sp& msg, -+ nsecs_t reltime, uint32_t /* flags */) { -+ return mEventQueue.postMessage(msg, reltime); -+} -+ -+status_t SurfaceFlinger::postMessageSync(const sp& msg, -+ nsecs_t reltime, uint32_t /* flags */) { -+ status_t res = mEventQueue.postMessage(msg, reltime); -+ if (res == NO_ERROR) { -+ msg->wait(); -+ } -+ return res; -+} -+ -+void SurfaceFlinger::run() { -+ do { -+ waitForEvent(); -+ } while (true); -+} -+ -+void SurfaceFlinger::enableHardwareVsync() { -+ Mutex::Autolock _l(mHWVsyncLock); -+ if (!mPrimaryHWVsyncEnabled && mHWVsyncAvailable) { -+ mPrimaryDispSync.beginResync(); -+ //eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true); -+ mEventControlThread->setVsyncEnabled(true); -+ mPrimaryHWVsyncEnabled = true; -+ } -+} -+ -+void SurfaceFlinger::resyncToHardwareVsync(bool makeAvailable) { -+ Mutex::Autolock _l(mHWVsyncLock); -+ -+ if (makeAvailable) { -+ mHWVsyncAvailable = true; -+ } else if (!mHWVsyncAvailable) { -+ // Hardware vsync is not currently available, so abort the resync -+ // attempt for now -+ return; -+ } -+ -+ const nsecs_t period = -+ getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY); -+ -+ mPrimaryDispSync.reset(); -+ mPrimaryDispSync.setPeriod(period); -+ -+ if (!mPrimaryHWVsyncEnabled) { -+ mPrimaryDispSync.beginResync(); -+ //eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, true); -+ mEventControlThread->setVsyncEnabled(true); -+ mPrimaryHWVsyncEnabled = true; -+ } -+} -+ -+void SurfaceFlinger::disableHardwareVsync(bool makeUnavailable) { -+ Mutex::Autolock _l(mHWVsyncLock); -+ if (mPrimaryHWVsyncEnabled) { -+ //eventControl(HWC_DISPLAY_PRIMARY, SurfaceFlinger::EVENT_VSYNC, false); -+ mEventControlThread->setVsyncEnabled(false); -+ mPrimaryDispSync.endResync(); -+ mPrimaryHWVsyncEnabled = false; -+ } -+ if (makeUnavailable) { -+ mHWVsyncAvailable = false; -+ } -+} -+ -+void SurfaceFlinger::resyncWithRateLimit() { -+ static constexpr nsecs_t kIgnoreDelay = ms2ns(500); -+ if (systemTime() - mLastSwapTime > kIgnoreDelay) { -+ resyncToHardwareVsync(false); -+ } -+} -+ -+void SurfaceFlinger::onVSyncReceived(HWComposer* /*composer*/, int type, -+ nsecs_t timestamp) { -+ bool needsHwVsync = false; -+ -+ { // Scope for the lock -+ Mutex::Autolock _l(mHWVsyncLock); -+ if (type == 0 && mPrimaryHWVsyncEnabled) { -+ needsHwVsync = mPrimaryDispSync.addResyncSample(timestamp); -+ } -+ } -+ -+ if (needsHwVsync) { -+ enableHardwareVsync(); -+ } else { -+ disableHardwareVsync(false); -+ } -+} -+ -+void SurfaceFlinger::getCompositorTiming(CompositorTiming* compositorTiming) { -+ std::lock_guard lock(mCompositorTimingLock); -+ *compositorTiming = mCompositorTiming; -+} -+ -+void SurfaceFlinger::onHotplugReceived(HWComposer* /*composer*/, int type, bool connected) { -+ if (mEventThread == NULL) { -+ // This is a temporary workaround for b/7145521. A non-null pointer -+ // does not mean EventThread has finished initializing, so this -+ // is not a correct fix. -+ ALOGW("WARNING: EventThread not started, ignoring hotplug"); -+ return; -+ } -+ -+ if (uint32_t(type) < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { -+ Mutex::Autolock _l(mStateLock); -+ if (connected) { -+ createBuiltinDisplayLocked((DisplayDevice::DisplayType)type); -+ } else { -+ mCurrentState.displays.removeItem(mBuiltinDisplays[type]); -+ mBuiltinDisplays[type].clear(); -+ } -+ setTransactionFlags(eDisplayTransactionNeeded); -+ -+ // Defer EventThread notification until SF has updated mDisplays. -+ } -+} -+ -+void SurfaceFlinger::onInvalidateReceived(HWComposer* /*composer*/) { -+ repaintEverything(); -+} -+ -+void SurfaceFlinger::eventControl(int disp, int event, int enabled) { -+ ATRACE_CALL(); -+ getHwComposer().eventControl(disp, event, enabled); -+} -+ -+void SurfaceFlinger::onMessageReceived(int32_t what) { -+ ATRACE_CALL(); -+ switch (what) { -+ case MessageQueue::INVALIDATE: { -+ bool refreshNeeded = handleMessageTransaction(); -+ refreshNeeded |= handleMessageInvalidate(); -+ refreshNeeded |= mRepaintEverything; -+ if (refreshNeeded) { -+ // Signal a refresh if a transaction modified the window state, -+ // a new buffer was latched, or if HWC has requested a full -+ // repaint -+ signalRefresh(); -+ } -+ break; -+ } -+ case MessageQueue::REFRESH: { -+ handleMessageRefresh(); -+ break; -+ } -+ } -+} -+ -+bool SurfaceFlinger::handleMessageTransaction() { -+ uint32_t transactionFlags = peekTransactionFlags(); -+ if (transactionFlags) { -+ handleTransaction(transactionFlags); -+ return true; -+ } -+ return false; -+} -+ -+bool SurfaceFlinger::handleMessageInvalidate() { -+ ATRACE_CALL(); -+ return handlePageFlip(); -+} -+ -+void SurfaceFlinger::handleMessageRefresh() { -+ ATRACE_CALL(); -+ -+ nsecs_t refreshStartTime = systemTime(SYSTEM_TIME_MONOTONIC); -+ -+ preComposition(refreshStartTime); -+ rebuildLayerStacks(); -+ setUpHWComposer(); -+ doDebugFlashRegions(); -+ doComposition(); -+ postComposition(refreshStartTime); -+} -+ -+void SurfaceFlinger::doDebugFlashRegions() -+{ -+ // is debugging enabled -+ if (CC_LIKELY(!mDebugRegion)) -+ return; -+ -+ const bool repaintEverything = mRepaintEverything; -+ for (size_t dpy=0 ; dpy& hw(mDisplays[dpy]); -+ if (hw->isDisplayOn()) { -+ // transform the dirty region into this screen's coordinate space -+ const Region dirtyRegion(hw->getDirtyRegion(repaintEverything)); -+ if (!dirtyRegion.isEmpty()) { -+ // redraw the whole screen -+ doComposeSurfaces(hw, Region(hw->bounds())); -+ -+ // and draw the dirty region -+ const int32_t height = hw->getHeight(); -+ RenderEngine& engine(getRenderEngine()); -+ engine.fillRegionWithColor(dirtyRegion, height, 1, 0, 1, 1); -+ -+ hw->compositionComplete(); -+ hw->swapBuffers(getHwComposer()); -+ } -+ } -+ } -+ -+ postFramebuffer(); -+ -+ if (mDebugRegion > 1) { -+ usleep(mDebugRegion * 1000); -+ } -+ -+ HWComposer& hwc(getHwComposer()); -+ if (hwc.initCheck() == NO_ERROR) { -+ status_t err = hwc.prepare(); -+ ALOGE_IF(err, "HWComposer::prepare failed (%s)", strerror(-err)); -+ } -+} -+ -+void SurfaceFlinger::preComposition(nsecs_t refreshStartTime) -+{ -+ bool needExtraInvalidate = false; -+ mDrawingState.traverseInZOrder([&](Layer* layer) { -+ if (layer->onPreComposition(refreshStartTime)) { -+ needExtraInvalidate = true; -+ } -+ }); -+ -+ if (needExtraInvalidate) { -+ signalLayerUpdate(); -+ } -+} -+ -+void SurfaceFlinger::updateCompositorTiming( -+ nsecs_t vsyncPhase, nsecs_t vsyncInterval, nsecs_t compositeTime, -+ std::shared_ptr& presentFenceTime) { -+ // Update queue of past composite+present times and determine the -+ // most recently known composite to present latency. -+ mCompositePresentTimes.push({compositeTime, presentFenceTime}); -+ nsecs_t compositeToPresentLatency = -1; -+ while (!mCompositePresentTimes.empty()) { -+ CompositePresentTime& cpt = mCompositePresentTimes.front(); -+ // Cached values should have been updated before calling this method, -+ // which helps avoid duplicate syscalls. -+ nsecs_t displayTime = cpt.display->getCachedSignalTime(); -+ if (displayTime == Fence::SIGNAL_TIME_PENDING) { -+ break; -+ } -+ compositeToPresentLatency = displayTime - cpt.composite; -+ mCompositePresentTimes.pop(); -+ } -+ -+ // Don't let mCompositePresentTimes grow unbounded, just in case. -+ while (mCompositePresentTimes.size() > 16) { -+ mCompositePresentTimes.pop(); -+ } -+ -+ setCompositorTimingSnapped( -+ vsyncPhase, vsyncInterval, compositeToPresentLatency); -+} -+ -+void SurfaceFlinger::setCompositorTimingSnapped(nsecs_t vsyncPhase, -+ nsecs_t vsyncInterval, nsecs_t compositeToPresentLatency) { -+ // Integer division and modulo round toward 0 not -inf, so we need to -+ // treat negative and positive offsets differently. -+ nsecs_t idealLatency = (sfVsyncPhaseOffsetNs > 0) ? -+ (vsyncInterval - (sfVsyncPhaseOffsetNs % vsyncInterval)) : -+ ((-sfVsyncPhaseOffsetNs) % vsyncInterval); -+ -+ // Just in case sfVsyncPhaseOffsetNs == -vsyncInterval. -+ if (idealLatency <= 0) { -+ idealLatency = vsyncInterval; -+ } -+ -+ // Snap the latency to a value that removes scheduling jitter from the -+ // composition and present times, which often have >1ms of jitter. -+ // Reducing jitter is important if an app attempts to extrapolate -+ // something (such as user input) to an accurate diasplay time. -+ // Snapping also allows an app to precisely calculate sfVsyncPhaseOffsetNs -+ // with (presentLatency % interval). -+ nsecs_t bias = vsyncInterval / 2; -+ int64_t extraVsyncs = -+ (compositeToPresentLatency - idealLatency + bias) / vsyncInterval; -+ nsecs_t snappedCompositeToPresentLatency = (extraVsyncs > 0) ? -+ idealLatency + (extraVsyncs * vsyncInterval) : idealLatency; -+ -+ std::lock_guard lock(mCompositorTimingLock); -+ mCompositorTiming.deadline = vsyncPhase - idealLatency; -+ mCompositorTiming.interval = vsyncInterval; -+ mCompositorTiming.presentLatency = snappedCompositeToPresentLatency; -+} -+ -+void SurfaceFlinger::postComposition(nsecs_t refreshStartTime) -+{ -+ const HWComposer& hwc = getHwComposer(); -+ const sp hw(getDefaultDisplayDevice()); -+ -+ mGlCompositionDoneTimeline.updateSignalTimes(); -+ std::shared_ptr glCompositionDoneFenceTime; -+ if (getHwComposer().hasGlesComposition(hw->getHwcDisplayId())) { -+ glCompositionDoneFenceTime = -+ std::make_shared(hw->getClientTargetAcquireFence()); -+ mGlCompositionDoneTimeline.push(glCompositionDoneFenceTime); -+ } else { -+ glCompositionDoneFenceTime = FenceTime::NO_FENCE; -+ } -+ -+ mDisplayTimeline.updateSignalTimes(); -+ sp retireFence = mHwc->getDisplayFence(HWC_DISPLAY_PRIMARY); -+ auto retireFenceTime = std::make_shared(retireFence); -+ mDisplayTimeline.push(retireFenceTime); -+ -+ nsecs_t vsyncPhase = mPrimaryDispSync.computeNextRefresh(0); -+ nsecs_t vsyncInterval = mPrimaryDispSync.getPeriod(); -+ -+ // We use the refreshStartTime which might be sampled a little later than -+ // when we started doing work for this frame, but that should be okay -+ // since updateCompositorTiming has snapping logic. -+ updateCompositorTiming( -+ vsyncPhase, vsyncInterval, refreshStartTime, retireFenceTime); -+ CompositorTiming compositorTiming; -+ { -+ std::lock_guard lock(mCompositorTimingLock); -+ compositorTiming = mCompositorTiming; -+ } -+ -+ mDrawingState.traverseInZOrder([&](Layer* layer) { -+ // TODO(brianderson): The retire fence is incorrectly passed in as the -+ // present fence. Fix this if this file lives on. -+ bool frameLatched = layer->onPostComposition(glCompositionDoneFenceTime, -+ retireFenceTime, compositorTiming); -+ if (frameLatched) { -+ recordBufferingStats(layer->getName().string(), -+ layer->getOccupancyHistory(false)); -+ } -+ }); -+ -+ if (retireFence->isValid()) { -+ if (mPrimaryDispSync.addPresentFence(retireFenceTime)) { -+ enableHardwareVsync(); -+ } else { -+ disableHardwareVsync(false); -+ } -+ } -+ -+ if (!hasSyncFramework) { -+ if (hw->isDisplayOn()) { -+ enableHardwareVsync(); -+ } -+ } -+ -+ if (mAnimCompositionPending) { -+ mAnimCompositionPending = false; -+ -+ if (retireFenceTime->isValid()) { -+ mAnimFrameTracker.setActualPresentFence(std::move(retireFenceTime)); -+ } else { -+ // The HWC doesn't support present fences, so use the refresh -+ // timestamp instead. -+ nsecs_t presentTime = hwc.getRefreshTimestamp(HWC_DISPLAY_PRIMARY); -+ mAnimFrameTracker.setActualPresentTime(presentTime); -+ } -+ mAnimFrameTracker.advanceFrame(); -+ } -+ -+ if (hw->getPowerMode() == HWC_POWER_MODE_OFF) { -+ return; -+ } -+ -+ nsecs_t currentTime = systemTime(); -+ if (mHasPoweredOff) { -+ mHasPoweredOff = false; -+ } else { -+ nsecs_t period = mPrimaryDispSync.getPeriod(); -+ nsecs_t elapsedTime = currentTime - mLastSwapTime; -+ size_t numPeriods = static_cast(elapsedTime / period); -+ if (numPeriods < NUM_BUCKETS - 1) { -+ mFrameBuckets[numPeriods] += elapsedTime; -+ } else { -+ mFrameBuckets[NUM_BUCKETS - 1] += elapsedTime; -+ } -+ mTotalTime += elapsedTime; -+ } -+ mLastSwapTime = currentTime; -+} -+ -+void SurfaceFlinger::rebuildLayerStacks() { -+ // rebuild the visible layer list per screen -+ if (CC_UNLIKELY(mVisibleRegionsDirty)) { -+ ATRACE_CALL(); -+ mVisibleRegionsDirty = false; -+ invalidateHwcGeometry(); -+ -+ for (size_t dpy=0 ; dpy > layersSortedByZ; -+ const sp& hw(mDisplays[dpy]); -+ const Transform& tr(hw->getTransform()); -+ const Rect bounds(hw->getBounds()); -+ if (hw->isDisplayOn()) { -+ computeVisibleRegions(hw, dirtyRegion, opaqueRegion); -+ -+ mDrawingState.traverseInZOrder([&](Layer* layer) { -+ if (layer->getLayerStack() == hw->getLayerStack()) { -+ Region drawRegion(tr.transform( -+ layer->visibleNonTransparentRegion)); -+ drawRegion.andSelf(bounds); -+ if (!drawRegion.isEmpty()) { -+ layersSortedByZ.add(layer); -+ } -+ } -+ }); -+ } -+ hw->setVisibleLayersSortedByZ(layersSortedByZ); -+ hw->undefinedRegion.set(bounds); -+ hw->undefinedRegion.subtractSelf(tr.transform(opaqueRegion)); -+ hw->dirtyRegion.orSelf(dirtyRegion); -+ } -+ } -+} -+ -+void SurfaceFlinger::setUpHWComposer() { -+ for (size_t dpy=0 ; dpygetDirtyRegion(false).isEmpty(); -+ bool empty = mDisplays[dpy]->getVisibleLayersSortedByZ().size() == 0; -+ bool wasEmpty = !mDisplays[dpy]->lastCompositionHadVisibleLayers; -+ -+ // If nothing has changed (!dirty), don't recompose. -+ // If something changed, but we don't currently have any visible layers, -+ // and didn't when we last did a composition, then skip it this time. -+ // The second rule does two things: -+ // - When all layers are removed from a display, we'll emit one black -+ // frame, then nothing more until we get new layers. -+ // - When a display is created with a private layer stack, we won't -+ // emit any black frames until a layer is added to the layer stack. -+ bool mustRecompose = dirty && !(empty && wasEmpty); -+ -+ ALOGV_IF(mDisplays[dpy]->getDisplayType() == DisplayDevice::DISPLAY_VIRTUAL, -+ "dpy[%zu]: %s composition (%sdirty %sempty %swasEmpty)", dpy, -+ mustRecompose ? "doing" : "skipping", -+ dirty ? "+" : "-", -+ empty ? "+" : "-", -+ wasEmpty ? "+" : "-"); -+ -+ mDisplays[dpy]->beginFrame(mustRecompose); -+ -+ if (mustRecompose) { -+ mDisplays[dpy]->lastCompositionHadVisibleLayers = !empty; -+ } -+ } -+ -+ HWComposer& hwc(getHwComposer()); -+ if (hwc.initCheck() == NO_ERROR) { -+ // build the h/w work list -+ if (CC_UNLIKELY(mHwWorkListDirty)) { -+ mHwWorkListDirty = false; -+ for (size_t dpy=0 ; dpy hw(mDisplays[dpy]); -+ const int32_t id = hw->getHwcDisplayId(); -+ if (id >= 0) { -+ const Vector< sp >& currentLayers( -+ hw->getVisibleLayersSortedByZ()); -+ const size_t count = currentLayers.size(); -+ if (hwc.createWorkList(id, count) == NO_ERROR) { -+ HWComposer::LayerListIterator cur = hwc.begin(id); -+ const HWComposer::LayerListIterator end = hwc.end(id); -+ for (size_t i=0 ; cur!=end && i& layer(currentLayers[i]); -+ layer->setGeometry(hw, *cur); -+ if (mDebugDisableHWC || mDebugRegion || mDaltonize || mHasColorMatrix) { -+ cur->setSkip(true); -+ } -+ } -+ } -+ } -+ } -+ } -+ -+ // set the per-frame data -+ for (size_t dpy=0 ; dpy hw(mDisplays[dpy]); -+ const int32_t id = hw->getHwcDisplayId(); -+ if (id >= 0) { -+ const Vector< sp >& currentLayers( -+ hw->getVisibleLayersSortedByZ()); -+ const size_t count = currentLayers.size(); -+ HWComposer::LayerListIterator cur = hwc.begin(id); -+ const HWComposer::LayerListIterator end = hwc.end(id); -+ for (size_t i=0 ; cur!=end && i& layer(currentLayers[i]); -+ layer->setPerFrameData(hw, *cur); -+ } -+ } -+ } -+ -+ // If possible, attempt to use the cursor overlay on each display. -+ for (size_t dpy=0 ; dpy hw(mDisplays[dpy]); -+ const int32_t id = hw->getHwcDisplayId(); -+ if (id >= 0) { -+ const Vector< sp >& currentLayers( -+ hw->getVisibleLayersSortedByZ()); -+ const size_t count = currentLayers.size(); -+ HWComposer::LayerListIterator cur = hwc.begin(id); -+ const HWComposer::LayerListIterator end = hwc.end(id); -+ for (size_t i=0 ; cur!=end && i& layer(currentLayers[i]); -+ if (layer->isPotentialCursor()) { -+ cur->setIsCursorLayerHint(); -+ break; -+ } -+ } -+ } -+ } -+ -+ status_t err = hwc.prepare(); -+ ALOGE_IF(err, "HWComposer::prepare failed (%s)", strerror(-err)); -+ -+ for (size_t dpy=0 ; dpy hw(mDisplays[dpy]); -+ hw->prepareFrame(hwc); -+ } -+ } -+} -+ -+void SurfaceFlinger::doComposition() { -+ ATRACE_CALL(); -+ const bool repaintEverything = android_atomic_and(0, &mRepaintEverything); -+ for (size_t dpy=0 ; dpy& hw(mDisplays[dpy]); -+ if (hw->isDisplayOn()) { -+ // transform the dirty region into this screen's coordinate space -+ const Region dirtyRegion(hw->getDirtyRegion(repaintEverything)); -+ -+ // repaint the framebuffer (if needed) -+ doDisplayComposition(hw, dirtyRegion); -+ -+ hw->dirtyRegion.clear(); -+ hw->flip(hw->swapRegion); -+ hw->swapRegion.clear(); -+ } -+ // inform the h/w that we're done compositing -+ hw->compositionComplete(); -+ } -+ postFramebuffer(); -+} -+ -+void SurfaceFlinger::postFramebuffer() -+{ -+ ATRACE_CALL(); -+ -+ const nsecs_t now = systemTime(); -+ mDebugInSwapBuffers = now; -+ -+ HWComposer& hwc(getHwComposer()); -+ if (hwc.initCheck() == NO_ERROR) { -+ if (!hwc.supportsFramebufferTarget()) { -+ // EGL spec says: -+ // "surface must be bound to the calling thread's current context, -+ // for the current rendering API." -+ getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext); -+ } -+ hwc.commit(); -+ } -+ -+ // make the default display current because the VirtualDisplayDevice code cannot -+ // deal with dequeueBuffer() being called outside of the composition loop; however -+ // the code below can call glFlush() which is allowed (and does in some case) call -+ // dequeueBuffer(). -+ getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext); -+ -+ for (size_t dpy=0 ; dpy hw(mDisplays[dpy]); -+ const Vector< sp >& currentLayers(hw->getVisibleLayersSortedByZ()); -+ hw->onSwapBuffersCompleted(hwc); -+ const size_t count = currentLayers.size(); -+ int32_t id = hw->getHwcDisplayId(); -+ if (id >=0 && hwc.initCheck() == NO_ERROR) { -+ HWComposer::LayerListIterator cur = hwc.begin(id); -+ const HWComposer::LayerListIterator end = hwc.end(id); -+ for (size_t i = 0; cur != end && i < count; ++i, ++cur) { -+ currentLayers[i]->onLayerDisplayed(hw, &*cur); -+ } -+ } else { -+ for (size_t i = 0; i < count; i++) { -+ currentLayers[i]->onLayerDisplayed(hw, NULL); -+ } -+ } -+ } -+ -+ mLastSwapBufferTime = systemTime() - now; -+ mDebugInSwapBuffers = 0; -+ -+ uint32_t flipCount = getDefaultDisplayDevice()->getPageFlipCount(); -+ if (flipCount % LOG_FRAME_STATS_PERIOD == 0) { -+ logFrameStats(); -+ } -+} -+ -+void SurfaceFlinger::handleTransaction(uint32_t transactionFlags) -+{ -+ ATRACE_CALL(); -+ -+ // here we keep a copy of the drawing state (that is the state that's -+ // going to be overwritten by handleTransactionLocked()) outside of -+ // mStateLock so that the side-effects of the State assignment -+ // don't happen with mStateLock held (which can cause deadlocks). -+ State drawingState(mDrawingState); -+ -+ Mutex::Autolock _l(mStateLock); -+ const nsecs_t now = systemTime(); -+ mDebugInTransaction = now; -+ -+ // Here we're guaranteed that some transaction flags are set -+ // so we can call handleTransactionLocked() unconditionally. -+ // We call getTransactionFlags(), which will also clear the flags, -+ // with mStateLock held to guarantee that mCurrentState won't change -+ // until the transaction is committed. -+ -+ transactionFlags = getTransactionFlags(eTransactionMask); -+ handleTransactionLocked(transactionFlags); -+ -+ mLastTransactionTime = systemTime() - now; -+ mDebugInTransaction = 0; -+ invalidateHwcGeometry(); -+ // here the transaction has been committed -+} -+ -+void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) -+{ -+ // Notify all layers of available frames -+ mCurrentState.traverseInZOrder([](Layer* layer) { -+ layer->notifyAvailableFrames(); -+ }); -+ -+ /* -+ * Traversal of the children -+ * (perform the transaction for each of them if needed) -+ */ -+ -+ if (transactionFlags & eTraversalNeeded) { -+ mCurrentState.traverseInZOrder([&](Layer* layer) { -+ uint32_t trFlags = layer->getTransactionFlags(eTransactionNeeded); -+ if (!trFlags) return; -+ -+ const uint32_t flags = layer->doTransaction(0); -+ if (flags & Layer::eVisibleRegion) -+ mVisibleRegionsDirty = true; -+ }); -+ } -+ -+ /* -+ * Perform display own transactions if needed -+ */ -+ -+ if (transactionFlags & eDisplayTransactionNeeded) { -+ // here we take advantage of Vector's copy-on-write semantics to -+ // improve performance by skipping the transaction entirely when -+ // know that the lists are identical -+ const KeyedVector< wp, DisplayDeviceState>& curr(mCurrentState.displays); -+ const KeyedVector< wp, DisplayDeviceState>& draw(mDrawingState.displays); -+ if (!curr.isIdenticalTo(draw)) { -+ mVisibleRegionsDirty = true; -+ const size_t cc = curr.size(); -+ size_t dc = draw.size(); -+ -+ // find the displays that were removed -+ // (ie: in drawing state but not in current state) -+ // also handle displays that changed -+ // (ie: displays that are in both lists) -+ for (size_t i=0 ; i defaultDisplay(getDefaultDisplayDeviceLocked()); -+ defaultDisplay->makeCurrent(mEGLDisplay, mEGLContext); -+ sp hw(getDisplayDeviceLocked(draw.keyAt(i))); -+ if (hw != NULL) -+ hw->disconnect(getHwComposer()); -+ if (draw[i].type < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) -+ mEventThread->onHotplugReceived(draw[i].type, false); -+ mDisplays.removeItem(draw.keyAt(i)); -+ } else { -+ ALOGW("trying to remove the main display"); -+ } -+ } else { -+ // this display is in both lists. see if something changed. -+ const DisplayDeviceState& state(curr[j]); -+ const wp& display(curr.keyAt(j)); -+ const sp state_binder = IInterface::asBinder(state.surface); -+ const sp draw_binder = IInterface::asBinder(draw[i].surface); -+ if (state_binder != draw_binder) { -+ // changing the surface is like destroying and -+ // recreating the DisplayDevice, so we just remove it -+ // from the drawing state, so that it get re-added -+ // below. -+ sp hw(getDisplayDeviceLocked(display)); -+ if (hw != NULL) -+ hw->disconnect(getHwComposer()); -+ mDisplays.removeItem(display); -+ mDrawingState.displays.removeItemsAt(i); -+ dc--; i--; -+ // at this point we must loop to the next item -+ continue; -+ } -+ -+ const sp disp(getDisplayDeviceLocked(display)); -+ if (disp != NULL) { -+ if (state.layerStack != draw[i].layerStack) { -+ disp->setLayerStack(state.layerStack); -+ } -+ if ((state.orientation != draw[i].orientation) -+ || (state.viewport != draw[i].viewport) -+ || (state.frame != draw[i].frame)) -+ { -+ disp->setProjection(state.orientation, -+ state.viewport, state.frame); -+ } -+ if (state.width != draw[i].width || state.height != draw[i].height) { -+ disp->setDisplaySize(state.width, state.height); -+ } -+ } -+ } -+ } -+ -+ // find displays that were added -+ // (ie: in current state but not in drawing state) -+ for (size_t i=0 ; i dispSurface; -+ sp producer; -+ sp bqProducer; -+ sp bqConsumer; -+ BufferQueue::createBufferQueue(&bqProducer, &bqConsumer); -+ -+ int32_t hwcDisplayId = -1; -+ if (state.isVirtualDisplay()) { -+ // Virtual displays without a surface are dormant: -+ // they have external state (layer stack, projection, -+ // etc.) but no internal state (i.e. a DisplayDevice). -+ if (state.surface != NULL) { -+ -+ int width = 0; -+ int status = state.surface->query( -+ NATIVE_WINDOW_WIDTH, &width); -+ ALOGE_IF(status != NO_ERROR, -+ "Unable to query width (%d)", status); -+ int height = 0; -+ status = state.surface->query( -+ NATIVE_WINDOW_HEIGHT, &height); -+ ALOGE_IF(status != NO_ERROR, -+ "Unable to query height (%d)", status); -+ if (mUseHwcVirtualDisplays && -+ (SurfaceFlinger::maxVirtualDisplaySize == 0 || -+ (width <= static_cast(SurfaceFlinger::maxVirtualDisplaySize) && -+ height <= static_cast(SurfaceFlinger::maxVirtualDisplaySize)))) { -+ hwcDisplayId = allocateHwcDisplayId(state.type); -+ } -+ -+ sp vds = new VirtualDisplaySurface( -+ *mHwc, hwcDisplayId, state.surface, -+ bqProducer, bqConsumer, state.displayName); -+ -+ dispSurface = vds; -+ producer = vds; -+ } -+ } else { -+ ALOGE_IF(state.surface!=NULL, -+ "adding a supported display, but rendering " -+ "surface is provided (%p), ignoring it", -+ state.surface.get()); -+ hwcDisplayId = allocateHwcDisplayId(state.type); -+ // for supported (by hwc) displays we provide our -+ // own rendering surface -+ dispSurface = new FramebufferSurface(*mHwc, state.type, -+ bqConsumer); -+ producer = bqProducer; -+ } -+ -+ const wp& display(curr.keyAt(i)); -+ if (dispSurface != NULL) { -+ sp hw = new DisplayDevice(this, -+ state.type, hwcDisplayId, -+ mHwc->getFormat(hwcDisplayId), state.isSecure, -+ display, dispSurface, producer, -+ mRenderEngine->getEGLConfig(), false); -+ hw->setLayerStack(state.layerStack); -+ hw->setProjection(state.orientation, -+ state.viewport, state.frame); -+ hw->setDisplayName(state.displayName); -+ mDisplays.add(display, hw); -+ if (state.isVirtualDisplay()) { -+ if (hwcDisplayId >= 0) { -+ mHwc->setVirtualDisplayProperties(hwcDisplayId, -+ hw->getWidth(), hw->getHeight(), -+ hw->getFormat()); -+ } -+ } else { -+ mEventThread->onHotplugReceived(state.type, true); -+ } -+ } -+ } -+ } -+ } -+ } -+ -+ if (transactionFlags & (eTraversalNeeded|eDisplayTransactionNeeded)) { -+ // The transform hint might have changed for some layers -+ // (either because a display has changed, or because a layer -+ // as changed). -+ // -+ // Walk through all the layers in currentLayers, -+ // and update their transform hint. -+ // -+ // If a layer is visible only on a single display, then that -+ // display is used to calculate the hint, otherwise we use the -+ // default display. -+ // -+ // NOTE: we do this here, rather than in rebuildLayerStacks() so that -+ // the hint is set before we acquire a buffer from the surface texture. -+ // -+ // NOTE: layer transactions have taken place already, so we use their -+ // drawing state. However, SurfaceFlinger's own transaction has not -+ // happened yet, so we must use the current state layer list -+ // (soon to become the drawing state list). -+ // -+ sp disp; -+ uint32_t currentlayerStack = 0; -+ bool first = true; -+ mCurrentState.traverseInZOrder([&](Layer* layer) { -+ // NOTE: we rely on the fact that layers are sorted by -+ // layerStack first (so we don't have to traverse the list -+ // of displays for every layer). -+ uint32_t layerStack = layer->getLayerStack(); -+ if (first || currentlayerStack != layerStack) { -+ currentlayerStack = layerStack; -+ // figure out if this layerstack is mirrored -+ // (more than one display) if so, pick the default display, -+ // if not, pick the only display it's on. -+ disp.clear(); -+ for (size_t dpy=0 ; dpy hw(mDisplays[dpy]); -+ if (hw->getLayerStack() == currentlayerStack) { -+ if (disp == NULL) { -+ disp = hw; -+ } else { -+ disp = NULL; -+ break; -+ } -+ } -+ } -+ } -+ if (disp == NULL) { -+ // NOTE: TEMPORARY FIX ONLY. Real fix should cause layers to -+ // redraw after transform hint changes. See bug 8508397. -+ -+ // could be null when this layer is using a layerStack -+ // that is not visible on any display. Also can occur at -+ // screen off/on times. -+ disp = getDefaultDisplayDeviceLocked(); -+ } -+ layer->updateTransformHint(disp); -+ -+ first = false; -+ }); -+ } -+ -+ -+ /* -+ * Perform our own transaction if needed -+ */ -+ -+ if (mLayersAdded) { -+ mLayersAdded = false; -+ // Layers have been added. -+ mVisibleRegionsDirty = true; -+ } -+ -+ // some layers might have been removed, so -+ // we need to update the regions they're exposing. -+ if (mLayersRemoved) { -+ mLayersRemoved = false; -+ mVisibleRegionsDirty = true; -+ mDrawingState.traverseInZOrder([&](Layer* layer) { -+ if (mLayersPendingRemoval.indexOf(layer) >= 0) { -+ // this layer is not visible anymore -+ // TODO: we could traverse the tree from front to back and -+ // compute the actual visible region -+ // TODO: we could cache the transformed region -+ Region visibleReg; -+ visibleReg.set(layer->computeScreenBounds()); -+ invalidateLayerStack(layer, visibleReg); -+ } -+ }); -+ } -+ -+ commitTransaction(); -+ -+ updateCursorAsync(); -+} -+ -+void SurfaceFlinger::updateCursorAsync() -+{ -+ HWComposer& hwc(getHwComposer()); -+ for (size_t dpy=0 ; dpy hw(mDisplays[dpy]); -+ const int32_t id = hw->getHwcDisplayId(); -+ if (id < 0) { -+ continue; -+ } -+ const Vector< sp >& currentLayers( -+ hw->getVisibleLayersSortedByZ()); -+ const size_t count = currentLayers.size(); -+ HWComposer::LayerListIterator cur = hwc.begin(id); -+ const HWComposer::LayerListIterator end = hwc.end(id); -+ for (size_t i=0 ; cur!=end && igetCompositionType() != HWC_CURSOR_OVERLAY) { -+ continue; -+ } -+ const sp& layer(currentLayers[i]); -+ Rect cursorPos = layer->getPosition(hw); -+ hwc.setCursorPositionAsync(id, cursorPos); -+ break; -+ } -+ } -+} -+ -+void SurfaceFlinger::commitTransaction() -+{ -+ if (!mLayersPendingRemoval.isEmpty()) { -+ // Notify removed layers now that they can't be drawn from -+ for (const auto& l : mLayersPendingRemoval) { -+ recordBufferingStats(l->getName().string(), -+ l->getOccupancyHistory(true)); -+ l->onRemoved(); -+ } -+ mLayersPendingRemoval.clear(); -+ } -+ -+ // If this transaction is part of a window animation then the next frame -+ // we composite should be considered an animation as well. -+ mAnimCompositionPending = mAnimTransactionPending; -+ -+ mDrawingState = mCurrentState; -+ mDrawingState.traverseInZOrder([](Layer* layer) { -+ layer->commitChildList(); -+ }); -+ mTransactionPending = false; -+ mAnimTransactionPending = false; -+ mTransactionCV.broadcast(); -+} -+ -+void SurfaceFlinger::computeVisibleRegions(const sp& displayDevice, -+ Region& outDirtyRegion, Region& outOpaqueRegion) -+{ -+ ATRACE_CALL(); -+ -+ Region aboveOpaqueLayers; -+ Region aboveCoveredLayers; -+ Region dirty; -+ -+ outDirtyRegion.clear(); -+ -+ mDrawingState.traverseInReverseZOrder([&](Layer* layer) { -+ // start with the whole surface at its current location -+ const Layer::State& s(layer->getDrawingState()); -+ -+ // only consider the layers on the given layer stack -+ if (layer->getLayerStack() != displayDevice->getLayerStack()) -+ return; -+ -+ /* -+ * opaqueRegion: area of a surface that is fully opaque. -+ */ -+ Region opaqueRegion; -+ -+ /* -+ * visibleRegion: area of a surface that is visible on screen -+ * and not fully transparent. This is essentially the layer's -+ * footprint minus the opaque regions above it. -+ * Areas covered by a translucent surface are considered visible. -+ */ -+ Region visibleRegion; -+ -+ /* -+ * coveredRegion: area of a surface that is covered by all -+ * visible regions above it (which includes the translucent areas). -+ */ -+ Region coveredRegion; -+ -+ /* -+ * transparentRegion: area of a surface that is hinted to be completely -+ * transparent. This is only used to tell when the layer has no visible -+ * non-transparent regions and can be removed from the layer list. It -+ * does not affect the visibleRegion of this layer or any layers -+ * beneath it. The hint may not be correct if apps don't respect the -+ * SurfaceView restrictions (which, sadly, some don't). -+ */ -+ Region transparentRegion; -+ -+ -+ // handle hidden surfaces by setting the visible region to empty -+ if (CC_LIKELY(layer->isVisible())) { -+ const bool translucent = !layer->isOpaque(s); -+ Rect bounds(layer->computeScreenBounds()); -+ visibleRegion.set(bounds); -+ Transform tr = layer->getTransform(); -+ if (!visibleRegion.isEmpty()) { -+ // Remove the transparent area from the visible region -+ if (translucent) { -+ if (tr.preserveRects()) { -+ // transform the transparent region -+ transparentRegion = tr.transform(s.activeTransparentRegion); -+ } else { -+ // transformation too complex, can't do the -+ // transparent region optimization. -+ transparentRegion.clear(); -+ } -+ } -+ -+ // compute the opaque region -+ const int32_t layerOrientation = tr.getOrientation(); -+ if (s.alpha==255 && !translucent && -+ ((layerOrientation & Transform::ROT_INVALID) == false)) { -+ // the opaque region is the layer's footprint -+ opaqueRegion = visibleRegion; -+ } -+ } -+ } -+ -+ // Clip the covered region to the visible region -+ coveredRegion = aboveCoveredLayers.intersect(visibleRegion); -+ -+ // Update aboveCoveredLayers for next (lower) layer -+ aboveCoveredLayers.orSelf(visibleRegion); -+ -+ // subtract the opaque region covered by the layers above us -+ visibleRegion.subtractSelf(aboveOpaqueLayers); -+ -+ // compute this layer's dirty region -+ if (layer->contentDirty) { -+ // we need to invalidate the whole region -+ dirty = visibleRegion; -+ // as well, as the old visible region -+ dirty.orSelf(layer->visibleRegion); -+ layer->contentDirty = false; -+ } else { -+ /* compute the exposed region: -+ * the exposed region consists of two components: -+ * 1) what's VISIBLE now and was COVERED before -+ * 2) what's EXPOSED now less what was EXPOSED before -+ * -+ * note that (1) is conservative, we start with the whole -+ * visible region but only keep what used to be covered by -+ * something -- which mean it may have been exposed. -+ * -+ * (2) handles areas that were not covered by anything but got -+ * exposed because of a resize. -+ */ -+ const Region newExposed = visibleRegion - coveredRegion; -+ const Region oldVisibleRegion = layer->visibleRegion; -+ const Region oldCoveredRegion = layer->coveredRegion; -+ const Region oldExposed = oldVisibleRegion - oldCoveredRegion; -+ dirty = (visibleRegion&oldCoveredRegion) | (newExposed-oldExposed); -+ } -+ dirty.subtractSelf(aboveOpaqueLayers); -+ -+ // accumulate to the screen dirty region -+ outDirtyRegion.orSelf(dirty); -+ -+ // Update aboveOpaqueLayers for next (lower) layer -+ aboveOpaqueLayers.orSelf(opaqueRegion); -+ -+ // Store the visible region in screen space -+ layer->setVisibleRegion(visibleRegion); -+ layer->setCoveredRegion(coveredRegion); -+ layer->setVisibleNonTransparentRegion( -+ visibleRegion.subtract(transparentRegion)); -+ }); -+ -+ outOpaqueRegion = aboveOpaqueLayers; -+} -+ -+void SurfaceFlinger::invalidateLayerStack(const sp& layer, const Region& dirty) { -+ uint32_t layerStack = layer->getLayerStack(); -+ for (size_t dpy=0 ; dpy& hw(mDisplays[dpy]); -+ if (hw->getLayerStack() == layerStack) { -+ hw->dirtyRegion.orSelf(dirty); -+ } -+ } -+} -+ -+bool SurfaceFlinger::handlePageFlip() -+{ -+ nsecs_t latchTime = systemTime(); -+ Region dirtyRegion; -+ -+ bool visibleRegions = false; -+ bool frameQueued = false; -+ -+ // Store the set of layers that need updates. This set must not change as -+ // buffers are being latched, as this could result in a deadlock. -+ // Example: Two producers share the same command stream and: -+ // 1.) Layer 0 is latched -+ // 2.) Layer 0 gets a new frame -+ // 2.) Layer 1 gets a new frame -+ // 3.) Layer 1 is latched. -+ // Display is now waiting on Layer 1's frame, which is behind layer 0's -+ // second frame. But layer 0's second frame could be waiting on display. -+ Vector layersWithQueuedFrames; -+ mDrawingState.traverseInZOrder([&](Layer* layer) { -+ if (layer->hasQueuedFrame()) { -+ frameQueued = true; -+ if (layer->shouldPresentNow(mPrimaryDispSync)) { -+ layersWithQueuedFrames.push_back(layer); -+ } else { -+ layer->useEmptyDamage(); -+ } -+ } else { -+ layer->useEmptyDamage(); -+ } -+ }); -+ for (size_t i = 0, count = layersWithQueuedFrames.size() ; ilatchBuffer(visibleRegions, latchTime)); -+ layer->useSurfaceDamage(); -+ invalidateLayerStack(layer, dirty); -+ } -+ -+ mVisibleRegionsDirty |= visibleRegions; -+ -+ // If we will need to wake up at some time in the future to deal with a -+ // queued frame that shouldn't be displayed during this vsync period, wake -+ // up during the next vsync period to check again. -+ if (frameQueued && layersWithQueuedFrames.empty()) { -+ signalLayerUpdate(); -+ } -+ -+ // Only continue with the refresh if there is actually new work to do -+ return !layersWithQueuedFrames.empty(); -+} -+ -+void SurfaceFlinger::invalidateHwcGeometry() -+{ -+ mHwWorkListDirty = true; -+} -+ -+ -+void SurfaceFlinger::doDisplayComposition(const sp& hw, -+ const Region& inDirtyRegion) -+{ -+ // We only need to actually compose the display if: -+ // 1) It is being handled by hardware composer, which may need this to -+ // keep its virtual display state machine in sync, or -+ // 2) There is work to be done (the dirty region isn't empty) -+ bool isHwcDisplay = hw->getHwcDisplayId() >= 0; -+ if (!isHwcDisplay && inDirtyRegion.isEmpty()) { -+ return; -+ } -+ -+ Region dirtyRegion(inDirtyRegion); -+ -+ // compute the invalid region -+ hw->swapRegion.orSelf(dirtyRegion); -+ -+ uint32_t flags = hw->getFlags(); -+ if (flags & DisplayDevice::SWAP_RECTANGLE) { -+ // we can redraw only what's dirty, but since SWAP_RECTANGLE only -+ // takes a rectangle, we must make sure to update that whole -+ // rectangle in that case -+ dirtyRegion.set(hw->swapRegion.bounds()); -+ } else { -+ if (flags & DisplayDevice::PARTIAL_UPDATES) { -+ // We need to redraw the rectangle that will be updated -+ // (pushed to the framebuffer). -+ // This is needed because PARTIAL_UPDATES only takes one -+ // rectangle instead of a region (see DisplayDevice::flip()) -+ dirtyRegion.set(hw->swapRegion.bounds()); -+ } else { -+ // we need to redraw everything (the whole screen) -+ dirtyRegion.set(hw->bounds()); -+ hw->swapRegion = dirtyRegion; -+ } -+ } -+ -+ if (CC_LIKELY(!mDaltonize && !mHasColorMatrix)) { -+ if (!doComposeSurfaces(hw, dirtyRegion)) return; -+ } else { -+ RenderEngine& engine(getRenderEngine()); -+ mat4 colorMatrix = mColorMatrix; -+ if (mDaltonize) { -+ colorMatrix = colorMatrix * mDaltonizer(); -+ } -+ mat4 oldMatrix = engine.setupColorTransform(colorMatrix); -+ doComposeSurfaces(hw, dirtyRegion); -+ engine.setupColorTransform(oldMatrix); -+ } -+ -+ // update the swap region and clear the dirty region -+ hw->swapRegion.orSelf(dirtyRegion); -+ -+ // swap buffers (presentation) -+ hw->swapBuffers(getHwComposer()); -+} -+ -+bool SurfaceFlinger::doComposeSurfaces(const sp& hw, const Region& dirty) -+{ -+ RenderEngine& engine(getRenderEngine()); -+ const int32_t id = hw->getHwcDisplayId(); -+ HWComposer& hwc(getHwComposer()); -+ HWComposer::LayerListIterator cur = hwc.begin(id); -+ const HWComposer::LayerListIterator end = hwc.end(id); -+ -+ bool hasGlesComposition = hwc.hasGlesComposition(id); -+ if (hasGlesComposition) { -+ if (!hw->makeCurrent(mEGLDisplay, mEGLContext)) { -+ ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s", -+ hw->getDisplayName().string()); -+ eglMakeCurrent(mEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); -+ if(!getDefaultDisplayDevice()->makeCurrent(mEGLDisplay, mEGLContext)) { -+ ALOGE("DisplayDevice::makeCurrent on default display failed. Aborting."); -+ } -+ return false; -+ } -+ -+ // Never touch the framebuffer if we don't have any framebuffer layers -+ const bool hasHwcComposition = hwc.hasHwcComposition(id); -+ if (hasHwcComposition) { -+ // when using overlays, we assume a fully transparent framebuffer -+ // NOTE: we could reduce how much we need to clear, for instance -+ // remove where there are opaque FB layers. however, on some -+ // GPUs doing a "clean slate" clear might be more efficient. -+ // We'll revisit later if needed. -+ engine.clearWithColor(0, 0, 0, 0); -+ } else { -+ // we start with the whole screen area -+ const Region bounds(hw->getBounds()); -+ -+ // we remove the scissor part -+ // we're left with the letterbox region -+ // (common case is that letterbox ends-up being empty) -+ const Region letterbox(bounds.subtract(hw->getScissor())); -+ -+ // compute the area to clear -+ Region region(hw->undefinedRegion.merge(letterbox)); -+ -+ // but limit it to the dirty region -+ region.andSelf(dirty); -+ -+ // screen is already cleared here -+ if (!region.isEmpty()) { -+ // can happen with SurfaceView -+ drawWormhole(hw, region); -+ } -+ } -+ -+ if (hw->getDisplayType() != DisplayDevice::DISPLAY_PRIMARY) { -+ // just to be on the safe side, we don't set the -+ // scissor on the main display. It should never be needed -+ // anyways (though in theory it could since the API allows it). -+ const Rect& bounds(hw->getBounds()); -+ const Rect& scissor(hw->getScissor()); -+ if (scissor != bounds) { -+ // scissor doesn't match the screen's dimensions, so we -+ // need to clear everything outside of it and enable -+ // the GL scissor so we don't draw anything where we shouldn't -+ -+ // enable scissor for this frame -+ const uint32_t height = hw->getHeight(); -+ engine.setScissor(scissor.left, height - scissor.bottom, -+ scissor.getWidth(), scissor.getHeight()); -+ } -+ } -+ } -+ -+ /* -+ * and then, render the layers targeted at the framebuffer -+ */ -+ -+ const Vector< sp >& layers(hw->getVisibleLayersSortedByZ()); -+ const size_t count = layers.size(); -+ const Transform& tr = hw->getTransform(); -+ if (cur != end) { -+ // we're using h/w composer -+ for (size_t i=0 ; i& layer(layers[i]); -+ const Region clip(dirty.intersect(tr.transform(layer->visibleRegion))); -+ if (!clip.isEmpty()) { -+ switch (cur->getCompositionType()) { -+ case HWC_CURSOR_OVERLAY: -+ case HWC_OVERLAY: { -+ const Layer::State& state(layer->getDrawingState()); -+ if ((cur->getHints() & HWC_HINT_CLEAR_FB) -+ && i -+ && layer->isOpaque(state) && (state.alpha == 0xFF) -+ && hasGlesComposition) { -+ // never clear the very first layer since we're -+ // guaranteed the FB is already cleared -+ layer->clearWithOpenGL(hw); -+ } -+ break; -+ } -+ case HWC_FRAMEBUFFER: { -+ layer->draw(hw, clip); -+ break; -+ } -+ case HWC_FRAMEBUFFER_TARGET: { -+ // this should not happen as the iterator shouldn't -+ // let us get there. -+ ALOGW("HWC_FRAMEBUFFER_TARGET found in hwc list (index=%zu)", i); -+ break; -+ } -+ } -+ } -+ layer->setAcquireFence(hw, *cur); -+ } -+ } else { -+ // we're not using h/w composer -+ for (size_t i=0 ; i& layer(layers[i]); -+ const Region clip(dirty.intersect( -+ tr.transform(layer->visibleRegion))); -+ if (!clip.isEmpty()) { -+ layer->draw(hw, clip); -+ } -+ } -+ } -+ -+ // disable scissor at the end of the frame -+ engine.disableScissor(); -+ return true; -+} -+ -+void SurfaceFlinger::drawWormhole(const sp& hw, const Region& region) const { -+ const int32_t height = hw->getHeight(); -+ RenderEngine& engine(getRenderEngine()); -+ engine.fillRegionWithColor(region, height, 0, 0, 0, 0); -+} -+ -+status_t SurfaceFlinger::addClientLayer(const sp& client, -+ const sp& handle, -+ const sp& gbc, -+ const sp& lbc, -+ const sp& parent) -+{ -+ // add this layer to the current state list -+ { -+ Mutex::Autolock _l(mStateLock); -+ if (mNumLayers >= MAX_LAYERS) { -+ return NO_MEMORY; -+ } -+ if (parent == nullptr) { -+ mCurrentState.layersSortedByZ.add(lbc); -+ } else { -+ if (mCurrentState.layersSortedByZ.indexOf(parent) < 0) { -+ ALOGE("addClientLayer called with a removed parent"); -+ return NAME_NOT_FOUND; -+ } -+ parent->addChild(lbc); -+ } -+ -+ mGraphicBufferProducerList.add(IInterface::asBinder(gbc)); -+ mLayersAdded = true; -+ mNumLayers++; -+ } -+ -+ // attach this layer to the client -+ client->attachLayer(handle, lbc); -+ -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::removeLayer(const sp& layer, bool topLevelOnly) { -+ Mutex::Autolock _l(mStateLock); -+ -+ const auto& p = layer->getParent(); -+ ssize_t index; -+ if (p != nullptr) { -+ if (topLevelOnly) { -+ return NO_ERROR; -+ } -+ -+ sp ancestor = p; -+ while (ancestor->getParent() != nullptr) { -+ ancestor = ancestor->getParent(); -+ } -+ if (mCurrentState.layersSortedByZ.indexOf(ancestor) < 0) { -+ ALOGE("removeLayer called with a layer whose parent has been removed"); -+ return NAME_NOT_FOUND; -+ } -+ -+ index = p->removeChild(layer); -+ } else { -+ index = mCurrentState.layersSortedByZ.remove(layer); -+ } -+ -+ // As a matter of normal operation, the LayerCleaner will produce a second -+ // attempt to remove the surface. The Layer will be kept alive in mDrawingState -+ // so we will succeed in promoting it, but it's already been removed -+ // from mCurrentState. As long as we can find it in mDrawingState we have no problem -+ // otherwise something has gone wrong and we are leaking the layer. -+ if (index < 0 && mDrawingState.layersSortedByZ.indexOf(layer) < 0) { -+ ALOGE("Failed to find layer (%s) in layer parent (%s).", -+ layer->getName().string(), -+ (p != nullptr) ? p->getName().string() : "no-parent"); -+ return BAD_VALUE; -+ } else if (index < 0) { -+ return NO_ERROR; -+ } -+ -+ layer->onRemovedFromCurrentState(); -+ mLayersPendingRemoval.add(layer); -+ mLayersRemoved = true; -+ mNumLayers -= 1 + layer->getChildrenCount(); -+ setTransactionFlags(eTransactionNeeded); -+ return NO_ERROR; -+} -+ -+uint32_t SurfaceFlinger::peekTransactionFlags() { -+ return android_atomic_release_load(&mTransactionFlags); -+} -+ -+uint32_t SurfaceFlinger::getTransactionFlags(uint32_t flags) { -+ return android_atomic_and(~flags, &mTransactionFlags) & flags; -+} -+ -+uint32_t SurfaceFlinger::setTransactionFlags(uint32_t flags) { -+ uint32_t old = android_atomic_or(flags, &mTransactionFlags); -+ if ((old & flags)==0) { // wake the server up -+ signalTransaction(); -+ } -+ return old; -+} -+ -+void SurfaceFlinger::setTransactionState( -+ const Vector& state, -+ const Vector& displays, -+ uint32_t flags) -+{ -+ ATRACE_CALL(); -+ Mutex::Autolock _l(mStateLock); -+ uint32_t transactionFlags = 0; -+ -+ if (flags & eAnimation) { -+ // For window updates that are part of an animation we must wait for -+ // previous animation "frames" to be handled. -+ while (mAnimTransactionPending) { -+ status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5)); -+ if (CC_UNLIKELY(err != NO_ERROR)) { -+ // just in case something goes wrong in SF, return to the -+ // caller after a few seconds. -+ ALOGW_IF(err == TIMED_OUT, "setTransactionState timed out " -+ "waiting for previous animation frame"); -+ mAnimTransactionPending = false; -+ break; -+ } -+ } -+ } -+ -+ size_t count = displays.size(); -+ for (size_t i=0 ; i binder = IInterface::asBinder(s.client); -+ if (binder != NULL) { -+ if (binder->queryLocalInterface(ISurfaceComposerClient::descriptor) != NULL) { -+ sp client( static_cast(s.client.get()) ); -+ transactionFlags |= setClientStateLocked(client, s.state); -+ } -+ } -+ } -+ } -+ -+ // If a synchronous transaction is explicitly requested without any changes, -+ // force a transaction anyway. This can be used as a flush mechanism for -+ // previous async transactions. -+ if (transactionFlags == 0 && (flags & eSynchronous)) { -+ transactionFlags = eTransactionNeeded; -+ } -+ -+ if (transactionFlags) { -+ if (mInterceptor.isEnabled()) { -+ mInterceptor.saveTransaction(state, mCurrentState.displays, displays, flags); -+ } -+ -+ // this triggers the transaction -+ setTransactionFlags(transactionFlags); -+ -+ // if this is a synchronous transaction, wait for it to take effect -+ // before returning. -+ if (flags & eSynchronous) { -+ mTransactionPending = true; -+ } -+ if (flags & eAnimation) { -+ mAnimTransactionPending = true; -+ } -+ while (mTransactionPending) { -+ status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5)); -+ if (CC_UNLIKELY(err != NO_ERROR)) { -+ // just in case something goes wrong in SF, return to the -+ // called after a few seconds. -+ ALOGW_IF(err == TIMED_OUT, "setTransactionState timed out!"); -+ mTransactionPending = false; -+ break; -+ } -+ } -+ } -+} -+ -+uint32_t SurfaceFlinger::setDisplayStateLocked(const DisplayState& s) -+{ -+ ssize_t dpyIdx = mCurrentState.displays.indexOfKey(s.token); -+ if (dpyIdx < 0) -+ return 0; -+ -+ uint32_t flags = 0; -+ DisplayDeviceState& disp(mCurrentState.displays.editValueAt(dpyIdx)); -+ if (disp.isValid()) { -+ const uint32_t what = s.what; -+ if (what & DisplayState::eSurfaceChanged) { -+ if (IInterface::asBinder(disp.surface) != IInterface::asBinder(s.surface)) { -+ disp.surface = s.surface; -+ flags |= eDisplayTransactionNeeded; -+ } -+ } -+ if (what & DisplayState::eLayerStackChanged) { -+ if (disp.layerStack != s.layerStack) { -+ disp.layerStack = s.layerStack; -+ flags |= eDisplayTransactionNeeded; -+ } -+ } -+ if (what & DisplayState::eDisplayProjectionChanged) { -+ if (disp.orientation != s.orientation) { -+ disp.orientation = s.orientation; -+ flags |= eDisplayTransactionNeeded; -+ } -+ if (disp.frame != s.frame) { -+ disp.frame = s.frame; -+ flags |= eDisplayTransactionNeeded; -+ } -+ if (disp.viewport != s.viewport) { -+ disp.viewport = s.viewport; -+ flags |= eDisplayTransactionNeeded; -+ } -+ } -+ if (what & DisplayState::eDisplaySizeChanged) { -+ if (disp.width != s.width) { -+ disp.width = s.width; -+ flags |= eDisplayTransactionNeeded; -+ } -+ if (disp.height != s.height) { -+ disp.height = s.height; -+ flags |= eDisplayTransactionNeeded; -+ } -+ } -+ } -+ return flags; -+} -+ -+uint32_t SurfaceFlinger::setClientStateLocked( -+ const sp& client, -+ const layer_state_t& s) -+{ -+ uint32_t flags = 0; -+ sp layer(client->getLayerUser(s.surface)); -+ if (layer != 0) { -+ const uint32_t what = s.what; -+ bool geometryAppliesWithResize = -+ what & layer_state_t::eGeometryAppliesWithResize; -+ if (what & layer_state_t::ePositionChanged) { -+ if (layer->setPosition(s.x, s.y, !geometryAppliesWithResize)) { -+ flags |= eTraversalNeeded; -+ } -+ } -+ if (what & layer_state_t::eLayerChanged) { -+ // NOTE: index needs to be calculated before we update the state -+ const auto& p = layer->getParent(); -+ if (p == nullptr) { -+ ssize_t idx = mCurrentState.layersSortedByZ.indexOf(layer); -+ if (layer->setLayer(s.z) && idx >= 0) { -+ mCurrentState.layersSortedByZ.removeAt(idx); -+ mCurrentState.layersSortedByZ.add(layer); -+ // we need traversal (state changed) -+ // AND transaction (list changed) -+ flags |= eTransactionNeeded|eTraversalNeeded; -+ } -+ } else { -+ if (p->setChildLayer(layer, s.z)) { -+ flags |= eTransactionNeeded|eTraversalNeeded; -+ } -+ } -+ } -+ if (what & layer_state_t::eSizeChanged) { -+ if (layer->setSize(s.w, s.h)) { -+ flags |= eTraversalNeeded; -+ } -+ } -+ if (what & layer_state_t::eAlphaChanged) { -+ if (layer->setAlpha(uint8_t(255.0f*s.alpha+0.5f))) -+ flags |= eTraversalNeeded; -+ } -+ if (what & layer_state_t::eMatrixChanged) { -+ if (layer->setMatrix(s.matrix)) -+ flags |= eTraversalNeeded; -+ } -+ if (what & layer_state_t::eTransparentRegionChanged) { -+ if (layer->setTransparentRegionHint(s.transparentRegion)) -+ flags |= eTraversalNeeded; -+ } -+ if (what & layer_state_t::eFlagsChanged) { -+ if (layer->setFlags(s.flags, s.mask)) -+ flags |= eTraversalNeeded; -+ } -+ if (what & layer_state_t::eCropChanged) { -+ if (layer->setCrop(s.crop, !geometryAppliesWithResize)) -+ flags |= eTraversalNeeded; -+ } -+ if (what & layer_state_t::eFinalCropChanged) { -+ if (layer->setFinalCrop(s.finalCrop, !geometryAppliesWithResize)) -+ flags |= eTraversalNeeded; -+ } -+ if (what & layer_state_t::eLayerStackChanged) { -+ ssize_t idx = mCurrentState.layersSortedByZ.indexOf(layer); -+ // We only allow setting layer stacks for top level layers, -+ // everything else inherits layer stack from its parent. -+ if (layer->hasParent()) { -+ ALOGE("Attempt to set layer stack on layer with parent (%s) is invalid", -+ layer->getName().string()); -+ } else if (idx < 0) { -+ ALOGE("Attempt to set layer stack on layer without parent (%s) that " -+ "that also does not appear in the top level layer list. Something" -+ " has gone wrong.", layer->getName().string()); -+ } else if (layer->setLayerStack(s.layerStack)) { -+ mCurrentState.layersSortedByZ.removeAt(idx); -+ mCurrentState.layersSortedByZ.add(layer); -+ // we need traversal (state changed) -+ // AND transaction (list changed) -+ flags |= eTransactionNeeded|eTraversalNeeded; -+ } -+ } -+ if (what & layer_state_t::eDeferTransaction) { -+ if (s.barrierHandle != nullptr) { -+ layer->deferTransactionUntil(s.barrierHandle, s.frameNumber); -+ } else if (s.barrierGbp != nullptr) { -+ const sp& gbp = s.barrierGbp; -+ if (authenticateSurfaceTextureLocked(gbp)) { -+ const auto& otherLayer = -+ (static_cast(gbp.get()))->getLayer(); -+ layer->deferTransactionUntil(otherLayer, s.frameNumber); -+ } else { -+ ALOGE("Attempt to defer transaction to to an" -+ " unrecognized GraphicBufferProducer"); -+ } -+ } -+ // We don't trigger a traversal here because if no other state is -+ // changed, we don't want this to cause any more work -+ } -+ if (what & layer_state_t::eReparentChildren) { -+ if (layer->reparentChildren(s.reparentHandle)) { -+ flags |= eTransactionNeeded|eTraversalNeeded; -+ } -+ } -+ if (what & layer_state_t::eDetachChildren) { -+ layer->detachChildren(); -+ } -+ if (what & layer_state_t::eOverrideScalingModeChanged) { -+ layer->setOverrideScalingMode(s.overrideScalingMode); -+ // We don't trigger a traversal here because if no other state is -+ // changed, we don't want this to cause any more work -+ } -+ } -+ return flags; -+} -+ -+status_t SurfaceFlinger::createLayer( -+ const String8& name, -+ const sp& client, -+ uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, -+ uint32_t windowType, uint32_t ownerUid, sp* handle, -+ sp* gbp, sp* parent) -+{ -+ if (int32_t(w|h) < 0) { -+ ALOGE("createLayer() failed, w or h is negative (w=%d, h=%d)", -+ int(w), int(h)); -+ return BAD_VALUE; -+ } -+ -+ status_t result = NO_ERROR; -+ -+ sp layer; -+ -+ String8 uniqueName = getUniqueLayerName(name); -+ -+ switch (flags & ISurfaceComposerClient::eFXSurfaceMask) { -+ case ISurfaceComposerClient::eFXSurfaceNormal: -+ result = createNormalLayer(client, -+ uniqueName, w, h, flags, format, -+ handle, gbp, &layer); -+ break; -+ case ISurfaceComposerClient::eFXSurfaceDim: -+ result = createDimLayer(client, -+ uniqueName, w, h, flags, -+ handle, gbp, &layer); -+ break; -+ default: -+ result = BAD_VALUE; -+ break; -+ } -+ -+ if (result != NO_ERROR) { -+ return result; -+ } -+ -+ layer->setInfo(windowType, ownerUid); -+ -+ result = addClientLayer(client, *handle, *gbp, layer, *parent); -+ if (result != NO_ERROR) { -+ return result; -+ } -+ mInterceptor.saveSurfaceCreation(layer); -+ -+ setTransactionFlags(eTransactionNeeded); -+ return result; -+} -+ -+String8 SurfaceFlinger::getUniqueLayerName(const String8& name) -+{ -+ bool matchFound = true; -+ uint32_t dupeCounter = 0; -+ -+ // Tack on our counter whether there is a hit or not, so everyone gets a tag -+ String8 uniqueName = name + "#" + String8(std::to_string(dupeCounter).c_str()); -+ -+ // Loop over layers until we're sure there is no matching name -+ while (matchFound) { -+ matchFound = false; -+ mDrawingState.traverseInZOrder([&](Layer* layer) { -+ if (layer->getName() == uniqueName) { -+ matchFound = true; -+ uniqueName = name + "#" + String8(std::to_string(++dupeCounter).c_str()); -+ } -+ }); -+ } -+ -+ ALOGD_IF(dupeCounter > 0, "duplicate layer name: changing %s to %s", name.c_str(), uniqueName.c_str()); -+ -+ return uniqueName; -+} -+ -+status_t SurfaceFlinger::createNormalLayer(const sp& client, -+ const String8& name, uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format, -+ sp* handle, sp* gbp, sp* outLayer) -+{ -+ // initialize the surfaces -+ switch (format) { -+ case PIXEL_FORMAT_TRANSPARENT: -+ case PIXEL_FORMAT_TRANSLUCENT: -+ format = PIXEL_FORMAT_RGBA_8888; -+ break; -+ case PIXEL_FORMAT_OPAQUE: -+ format = PIXEL_FORMAT_RGBX_8888; -+ break; -+ } -+ -+ *outLayer = new Layer(this, client, name, w, h, flags); -+ status_t err = (*outLayer)->setBuffers(w, h, format, flags); -+ if (err == NO_ERROR) { -+ *handle = (*outLayer)->getHandle(); -+ *gbp = (*outLayer)->getProducer(); -+ } -+ -+ ALOGE_IF(err, "createNormalLayer() failed (%s)", strerror(-err)); -+ return err; -+} -+ -+status_t SurfaceFlinger::createDimLayer(const sp& client, -+ const String8& name, uint32_t w, uint32_t h, uint32_t flags, -+ sp* handle, sp* gbp, sp* outLayer) -+{ -+ *outLayer = new LayerDim(this, client, name, w, h, flags); -+ *handle = (*outLayer)->getHandle(); -+ *gbp = (*outLayer)->getProducer(); -+ return NO_ERROR; -+} -+ -+status_t SurfaceFlinger::onLayerRemoved(const sp& client, const sp& handle) -+{ -+ // called by a client when it wants to remove a Layer -+ status_t err = NO_ERROR; -+ sp l(client->getLayerUser(handle)); -+ if (l != NULL) { -+ mInterceptor.saveSurfaceDeletion(l); -+ err = removeLayer(l); -+ ALOGE_IF(err<0 && err != NAME_NOT_FOUND, -+ "error removing layer=%p (%s)", l.get(), strerror(-err)); -+ } -+ return err; -+} -+ -+status_t SurfaceFlinger::onLayerDestroyed(const wp& layer) -+{ -+ // called by ~LayerCleaner() when all references to the IBinder (handle) -+ // are gone -+ sp l = layer.promote(); -+ if (l == nullptr) { -+ // The layer has already been removed, carry on -+ return NO_ERROR; -+ } -+ // If we have a parent, then we can continue to live as long as it does. -+ return removeLayer(l, true); -+} -+ -+// --------------------------------------------------------------------------- -+ -+void SurfaceFlinger::onInitializeDisplays() { -+ // reset screen orientation and use primary layer stack -+ Vector state; -+ Vector displays; -+ DisplayState d; -+ d.what = DisplayState::eDisplayProjectionChanged | -+ DisplayState::eLayerStackChanged; -+ d.token = mBuiltinDisplays[DisplayDevice::DISPLAY_PRIMARY]; -+ d.layerStack = 0; -+ d.orientation = DisplayState::eOrientationDefault; -+ d.frame.makeInvalid(); -+ d.viewport.makeInvalid(); -+ d.width = 0; -+ d.height = 0; -+ displays.add(d); -+ setTransactionState(state, displays, 0); -+ setPowerModeInternal(getDisplayDevice(d.token), HWC_POWER_MODE_NORMAL); -+ -+ const nsecs_t period = -+ getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY); -+ mAnimFrameTracker.setDisplayRefreshPeriod(period); -+ -+ // Use phase of 0 since phase is not known. -+ // Use latency of 0, which will snap to the ideal latency. -+ setCompositorTimingSnapped(0, period, 0); -+} -+ -+void SurfaceFlinger::initializeDisplays() { -+ class MessageScreenInitialized : public MessageBase { -+ SurfaceFlinger* flinger; -+ public: -+ explicit MessageScreenInitialized(SurfaceFlinger* flinger) : flinger(flinger) { } -+ virtual bool handler() { -+ flinger->onInitializeDisplays(); -+ return true; -+ } -+ }; -+ sp msg = new MessageScreenInitialized(this); -+ postMessageAsync(msg); // we may be called from main thread, use async message -+} -+ -+void SurfaceFlinger::setPowerModeInternal(const sp& hw, -+ int mode) { -+ ALOGD("Set power mode=%d, type=%d flinger=%p", mode, hw->getDisplayType(), -+ this); -+ int32_t type = hw->getDisplayType(); -+ int currentMode = hw->getPowerMode(); -+ -+ if (mode == currentMode) { -+ ALOGD("Screen type=%d is already mode=%d", hw->getDisplayType(), mode); -+ return; -+ } -+ -+ hw->setPowerMode(mode); -+ if (type >= DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) { -+ ALOGW("Trying to set power mode for virtual display"); -+ return; -+ } -+ -+ if (mInterceptor.isEnabled()) { -+ Mutex::Autolock _l(mStateLock); -+ ssize_t idx = mCurrentState.displays.indexOfKey(hw->getDisplayToken()); -+ if (idx < 0) { -+ ALOGW("Surface Interceptor SavePowerMode: invalid display token"); -+ return; -+ } -+ mInterceptor.savePowerModeUpdate(mCurrentState.displays.valueAt(idx).displayId, mode); -+ } -+ -+ if (currentMode == HWC_POWER_MODE_OFF) { -+ // Turn on the display -+ getHwComposer().setPowerMode(type, mode); -+ if (type == DisplayDevice::DISPLAY_PRIMARY && -+ mode != HWC_POWER_MODE_DOZE_SUSPEND) { -+ // FIXME: eventthread only knows about the main display right now -+ mEventThread->onScreenAcquired(); -+ resyncToHardwareVsync(true); -+ } -+ -+ mVisibleRegionsDirty = true; -+ mHasPoweredOff = true; -+ repaintEverything(); -+ -+ struct sched_param param = {0}; -+ param.sched_priority = 1; -+ if (sched_setscheduler(0, SCHED_FIFO, ¶m) != 0) { -+ ALOGW("Couldn't set SCHED_FIFO on display on"); -+ } -+ } else if (mode == HWC_POWER_MODE_OFF) { -+ // Turn off the display -+ struct sched_param param = {0}; -+ if (sched_setscheduler(0, SCHED_OTHER, ¶m) != 0) { -+ ALOGW("Couldn't set SCHED_OTHER on display off"); -+ } -+ -+ if (type == DisplayDevice::DISPLAY_PRIMARY) { -+ disableHardwareVsync(true); // also cancels any in-progress resync -+ -+ // FIXME: eventthread only knows about the main display right now -+ mEventThread->onScreenReleased(); -+ } -+ -+ getHwComposer().setPowerMode(type, mode); -+ mVisibleRegionsDirty = true; -+ // from this point on, SF will stop drawing on this display -+ } else if (mode == HWC_POWER_MODE_DOZE || -+ mode == HWC_POWER_MODE_NORMAL) { -+ // Update display while dozing -+ getHwComposer().setPowerMode(type, mode); -+ if (type == DisplayDevice::DISPLAY_PRIMARY) { -+ // FIXME: eventthread only knows about the main display right now -+ mEventThread->onScreenAcquired(); -+ resyncToHardwareVsync(true); -+ } -+ } else if (mode == HWC_POWER_MODE_DOZE_SUSPEND) { -+ // Leave display going to doze -+ if (type == DisplayDevice::DISPLAY_PRIMARY) { -+ disableHardwareVsync(true); // also cancels any in-progress resync -+ // FIXME: eventthread only knows about the main display right now -+ mEventThread->onScreenReleased(); -+ } -+ getHwComposer().setPowerMode(type, mode); -+ } else { -+ ALOGE("Attempting to set unknown power mode: %d\n", mode); -+ getHwComposer().setPowerMode(type, mode); -+ } -+} -+ -+void SurfaceFlinger::setPowerMode(const sp& display, int mode) { -+ class MessageSetPowerMode: public MessageBase { -+ SurfaceFlinger& mFlinger; -+ sp mDisplay; -+ int mMode; -+ public: -+ MessageSetPowerMode(SurfaceFlinger& flinger, -+ const sp& disp, int mode) : mFlinger(flinger), -+ mDisplay(disp) { mMode = mode; } -+ virtual bool handler() { -+ sp hw(mFlinger.getDisplayDevice(mDisplay)); -+ if (hw == NULL) { -+ ALOGE("Attempt to set power mode = %d for null display %p", -+ mMode, mDisplay.get()); -+ } else if (hw->getDisplayType() >= DisplayDevice::DISPLAY_VIRTUAL) { -+ ALOGW("Attempt to set power mode = %d for virtual display", -+ mMode); -+ } else { -+ mFlinger.setPowerModeInternal(hw, mMode); -+ } -+ return true; -+ } -+ }; -+ sp msg = new MessageSetPowerMode(*this, display, mode); -+ postMessageSync(msg); -+} -+ -+// --------------------------------------------------------------------------- -+ -+status_t SurfaceFlinger::dump(int fd, const Vector& args) -+{ -+ String8 result; -+ -+ IPCThreadState* ipc = IPCThreadState::self(); -+ const int pid = ipc->getCallingPid(); -+ const int uid = ipc->getCallingUid(); -+ if ((uid != AID_SHELL) && -+ !PermissionCache::checkPermission(sDump, pid, uid)) { -+ result.appendFormat("Permission Denial: " -+ "can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid); -+ } else { -+ // Try to get the main lock, but give up after one second -+ // (this would indicate SF is stuck, but we want to be able to -+ // print something in dumpsys). -+ status_t err = mStateLock.timedLock(s2ns(1)); -+ bool locked = (err == NO_ERROR); -+ if (!locked) { -+ result.appendFormat( -+ "SurfaceFlinger appears to be unresponsive (%s [%d]), " -+ "dumping anyways (no locks held)\n", strerror(-err), err); -+ } -+ -+ bool dumpAll = true; -+ size_t index = 0; -+ size_t numArgs = args.size(); -+ if (numArgs) { -+ if ((index < numArgs) && -+ (args[index] == String16("--list"))) { -+ index++; -+ listLayersLocked(args, index, result); -+ dumpAll = false; -+ } -+ -+ if ((index < numArgs) && -+ (args[index] == String16("--latency"))) { -+ index++; -+ dumpStatsLocked(args, index, result); -+ dumpAll = false; -+ } -+ -+ if ((index < numArgs) && -+ (args[index] == String16("--latency-clear"))) { -+ index++; -+ clearStatsLocked(args, index, result); -+ dumpAll = false; -+ } -+ -+ if ((index < numArgs) && -+ (args[index] == String16("--dispsync"))) { -+ index++; -+ mPrimaryDispSync.dump(result); -+ dumpAll = false; -+ } -+ -+ if ((index < numArgs) && -+ (args[index] == String16("--static-screen"))) { -+ index++; -+ dumpStaticScreenStats(result); -+ dumpAll = false; -+ } -+ -+ if ((index < numArgs) && -+ (args[index] == String16("--frame-events"))) { -+ index++; -+ dumpFrameEventsLocked(result); -+ dumpAll = false; -+ } -+ } -+ -+ if (dumpAll) { -+ dumpAllLocked(args, index, result); -+ } -+ -+ if (locked) { -+ mStateLock.unlock(); -+ } -+ } -+ write(fd, result.string(), result.size()); -+ return NO_ERROR; -+} -+ -+void SurfaceFlinger::listLayersLocked(const Vector& /* args */, -+ size_t& /* index */, String8& result) const -+{ -+ mCurrentState.traverseInZOrder([&](Layer* layer) { -+ result.appendFormat("%s\n", layer->getName().string()); -+ }); -+} -+ -+void SurfaceFlinger::dumpStatsLocked(const Vector& args, size_t& index, -+ String8& result) const -+{ -+ String8 name; -+ if (index < args.size()) { -+ name = String8(args[index]); -+ index++; -+ } -+ -+ const nsecs_t period = -+ getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY); -+ result.appendFormat("%" PRId64 "\n", period); -+ -+ if (name.isEmpty()) { -+ mAnimFrameTracker.dumpStats(result); -+ } else { -+ mCurrentState.traverseInZOrder([&](Layer* layer) { -+ if (name == layer->getName()) { -+ layer->dumpFrameStats(result); -+ } -+ }); -+ } -+} -+ -+void SurfaceFlinger::clearStatsLocked(const Vector& args, size_t& index, -+ String8& /* result */) -+{ -+ String8 name; -+ if (index < args.size()) { -+ name = String8(args[index]); -+ index++; -+ } -+ -+ mCurrentState.traverseInZOrder([&](Layer* layer) { -+ if (name.isEmpty() || (name == layer->getName())) { -+ layer->clearFrameStats(); -+ } -+ }); -+ -+ mAnimFrameTracker.clearStats(); -+} -+ -+// This should only be called from the main thread. Otherwise it would need -+// the lock and should use mCurrentState rather than mDrawingState. -+void SurfaceFlinger::logFrameStats() { -+ mDrawingState.traverseInZOrder([&](Layer* layer) { -+ layer->logFrameStats(); -+ }); -+ -+ mAnimFrameTracker.logAndResetStats(String8("")); -+} -+ -+void SurfaceFlinger::appendSfConfigString(String8& result) const -+{ -+ result.append(" [sf"); -+ result.appendFormat(" HAS_CONTEXT_PRIORITY=%d", useContextPriority); -+ -+ if (isLayerTripleBufferingDisabled()) -+ result.append(" DISABLE_TRIPLE_BUFFERING"); -+ -+ result.appendFormat(" PRESENT_TIME_OFFSET=%" PRId64, dispSyncPresentTimeOffset); -+ result.appendFormat(" FORCE_HWC_FOR_RBG_TO_YUV=%d", useHwcForRgbToYuv); -+ result.appendFormat(" MAX_VIRT_DISPLAY_DIM=%" PRIu64, maxVirtualDisplaySize); -+ result.appendFormat(" RUNNING_WITHOUT_SYNC_FRAMEWORK=%d", !hasSyncFramework); -+ result.appendFormat(" NUM_FRAMEBUFFER_SURFACE_BUFFERS=%" PRId64, -+ maxFrameBufferAcquiredBuffers); -+ result.append("]"); -+} -+ -+void SurfaceFlinger::dumpStaticScreenStats(String8& result) const -+{ -+ result.appendFormat("Static screen stats:\n"); -+ for (size_t b = 0; b < NUM_BUCKETS - 1; ++b) { -+ float bucketTimeSec = mFrameBuckets[b] / 1e9; -+ float percent = 100.0f * -+ static_cast(mFrameBuckets[b]) / mTotalTime; -+ result.appendFormat(" < %zd frames: %.3f s (%.1f%%)\n", -+ b + 1, bucketTimeSec, percent); -+ } -+ float bucketTimeSec = mFrameBuckets[NUM_BUCKETS - 1] / 1e9; -+ float percent = 100.0f * -+ static_cast(mFrameBuckets[NUM_BUCKETS - 1]) / mTotalTime; -+ result.appendFormat(" %zd+ frames: %.3f s (%.1f%%)\n", -+ NUM_BUCKETS - 1, bucketTimeSec, percent); -+} -+ -+void SurfaceFlinger::dumpFrameEventsLocked(String8& result) { -+ result.appendFormat("Layer frame timestamps:\n"); -+ -+ const LayerVector& currentLayers = mCurrentState.layersSortedByZ; -+ const size_t count = currentLayers.size(); -+ for (size_t i=0 ; idumpFrameEvents(result); -+ } -+} -+ -+void SurfaceFlinger::recordBufferingStats(const char* layerName, -+ std::vector&& history) { -+ Mutex::Autolock lock(mBufferingStatsMutex); -+ auto& stats = mBufferingStats[layerName]; -+ for (const auto& segment : history) { -+ if (!segment.usedThirdBuffer) { -+ stats.twoBufferTime += segment.totalTime; -+ } -+ if (segment.occupancyAverage < 1.0f) { -+ stats.doubleBufferedTime += segment.totalTime; -+ } else if (segment.occupancyAverage < 2.0f) { -+ stats.tripleBufferedTime += segment.totalTime; -+ } -+ ++stats.numSegments; -+ stats.totalTime += segment.totalTime; -+ } -+} -+ -+void SurfaceFlinger::dumpBufferingStats(String8& result) const { -+ result.append("Buffering stats:\n"); -+ result.append(" [Layer name] " -+ " \n"); -+ Mutex::Autolock lock(mBufferingStatsMutex); -+ typedef std::tuple BufferTuple; -+ std::map> sorted; -+ for (const auto& statsPair : mBufferingStats) { -+ const char* name = statsPair.first.c_str(); -+ const BufferingStats& stats = statsPair.second; -+ if (stats.numSegments == 0) { -+ continue; -+ } -+ float activeTime = ns2ms(stats.totalTime) / 1000.0f; -+ float twoBufferRatio = static_cast(stats.twoBufferTime) / -+ stats.totalTime; -+ float doubleBufferRatio = static_cast( -+ stats.doubleBufferedTime) / stats.totalTime; -+ float tripleBufferRatio = static_cast( -+ stats.tripleBufferedTime) / stats.totalTime; -+ sorted.insert({activeTime, {name, twoBufferRatio, -+ doubleBufferRatio, tripleBufferRatio}}); -+ } -+ for (const auto& sortedPair : sorted) { -+ float activeTime = sortedPair.first; -+ const BufferTuple& values = sortedPair.second; -+ result.appendFormat(" [%s] %.2f %.3f %.3f %.3f\n", -+ std::get<0>(values).c_str(), activeTime, -+ std::get<1>(values), std::get<2>(values), -+ std::get<3>(values)); -+ } -+ result.append("\n"); -+} -+ -+void SurfaceFlinger::dumpAllLocked(const Vector& args, size_t& index, -+ String8& result) const -+{ -+ bool colorize = false; -+ if (index < args.size() -+ && (args[index] == String16("--color"))) { -+ colorize = true; -+ index++; -+ } -+ -+ Colorizer colorizer(colorize); -+ -+ // figure out if we're stuck somewhere -+ const nsecs_t now = systemTime(); -+ const nsecs_t inSwapBuffers(mDebugInSwapBuffers); -+ const nsecs_t inTransaction(mDebugInTransaction); -+ nsecs_t inSwapBuffersDuration = (inSwapBuffers) ? now-inSwapBuffers : 0; -+ nsecs_t inTransactionDuration = (inTransaction) ? now-inTransaction : 0; -+ -+ /* -+ * Dump library configuration. -+ */ -+ -+ colorizer.bold(result); -+ result.append("Build configuration:"); -+ colorizer.reset(result); -+ appendSfConfigString(result); -+ appendUiConfigString(result); -+ appendGuiConfigString(result); -+ result.append("\n"); -+ -+ colorizer.bold(result); -+ result.append("Sync configuration: "); -+ colorizer.reset(result); -+ result.append(SyncFeatures::getInstance().toString()); -+ result.append("\n"); -+ -+ colorizer.bold(result); -+ result.append("DispSync configuration: "); -+ colorizer.reset(result); -+ result.appendFormat("app phase %" PRId64 " ns, sf phase %" PRId64 " ns, " -+ "present offset %" PRId64 " ns (refresh %" PRId64 " ns)", -+ vsyncPhaseOffsetNs, sfVsyncPhaseOffsetNs, dispSyncPresentTimeOffset, -+ mHwc->getRefreshPeriod(HWC_DISPLAY_PRIMARY)); -+ result.append("\n"); -+ -+ // Dump static screen stats -+ result.append("\n"); -+ dumpStaticScreenStats(result); -+ result.append("\n"); -+ -+ dumpBufferingStats(result); -+ -+ /* -+ * Dump the visible layer list -+ */ -+ colorizer.bold(result); -+ result.appendFormat("Visible layers (count = %zu)\n", mNumLayers); -+ colorizer.reset(result); -+ mCurrentState.traverseInZOrder([&](Layer* layer) { -+ layer->dump(result, colorizer); -+ }); -+ -+ /* -+ * Dump Display state -+ */ -+ -+ colorizer.bold(result); -+ result.appendFormat("Displays (%zu entries)\n", mDisplays.size()); -+ colorizer.reset(result); -+ for (size_t dpy=0 ; dpy& hw(mDisplays[dpy]); -+ hw->dump(result); -+ } -+ -+ /* -+ * Dump SurfaceFlinger global state -+ */ -+ -+ colorizer.bold(result); -+ result.append("SurfaceFlinger global state:\n"); -+ colorizer.reset(result); -+ -+ HWComposer& hwc(getHwComposer()); -+ sp hw(getDefaultDisplayDeviceLocked()); -+ -+ colorizer.bold(result); -+ result.appendFormat("EGL implementation : %s\n", -+ eglQueryStringImplementationANDROID(mEGLDisplay, EGL_VERSION)); -+ colorizer.reset(result); -+ result.appendFormat("%s\n", -+ eglQueryStringImplementationANDROID(mEGLDisplay, EGL_EXTENSIONS)); -+ -+ mRenderEngine->dump(result); -+ -+ hw->undefinedRegion.dump(result, "undefinedRegion"); -+ result.appendFormat(" orientation=%d, isDisplayOn=%d\n", -+ hw->getOrientation(), hw->isDisplayOn()); -+ result.appendFormat( -+ " last eglSwapBuffers() time: %f us\n" -+ " last transaction time : %f us\n" -+ " transaction-flags : %08x\n" -+ " refresh-rate : %f fps\n" -+ " x-dpi : %f\n" -+ " y-dpi : %f\n" -+ " gpu_to_cpu_unsupported : %d\n" -+ , -+ mLastSwapBufferTime/1000.0, -+ mLastTransactionTime/1000.0, -+ mTransactionFlags, -+ 1e9 / hwc.getRefreshPeriod(HWC_DISPLAY_PRIMARY), -+ hwc.getDpiX(HWC_DISPLAY_PRIMARY), -+ hwc.getDpiY(HWC_DISPLAY_PRIMARY), -+ !mGpuToCpuSupported); -+ -+ result.appendFormat(" eglSwapBuffers time: %f us\n", -+ inSwapBuffersDuration/1000.0); -+ -+ result.appendFormat(" transaction time: %f us\n", -+ inTransactionDuration/1000.0); -+ -+ /* -+ * VSYNC state -+ */ -+ mEventThread->dump(result); -+ -+ /* -+ * Dump HWComposer state -+ */ -+ colorizer.bold(result); -+ result.append("h/w composer state:\n"); -+ colorizer.reset(result); -+ result.appendFormat(" h/w composer %s and %s\n", -+ hwc.initCheck()==NO_ERROR ? "present" : "not present", -+ (mDebugDisableHWC || mDebugRegion || mDaltonize -+ || mHasColorMatrix) ? "disabled" : "enabled"); -+ hwc.dump(result); -+ -+ /* -+ * Dump gralloc state -+ */ -+ const GraphicBufferAllocator& alloc(GraphicBufferAllocator::get()); -+ alloc.dump(result); -+} -+ -+const Vector< sp >& -+SurfaceFlinger::getLayerSortedByZForHwcDisplay(int id) { -+ // Note: mStateLock is held here -+ wp dpy; -+ for (size_t i=0 ; igetHwcDisplayId() == id) { -+ dpy = mDisplays.keyAt(i); -+ break; -+ } -+ } -+ if (dpy == NULL) { -+ ALOGE("getLayerSortedByZForHwcDisplay: invalid hwc display id %d", id); -+ // Just use the primary display so we have something to return -+ dpy = getBuiltInDisplay(DisplayDevice::DISPLAY_PRIMARY); -+ } -+ return getDisplayDeviceLocked(dpy)->getVisibleLayersSortedByZ(); -+} -+ -+bool SurfaceFlinger::startDdmConnection() -+{ -+ void* libddmconnection_dso = -+ dlopen("libsurfaceflinger_ddmconnection.so", RTLD_NOW); -+ if (!libddmconnection_dso) { -+ return false; -+ } -+ void (*DdmConnection_start)(const char* name); -+ DdmConnection_start = -+ (decltype(DdmConnection_start))dlsym(libddmconnection_dso, "DdmConnection_start"); -+ if (!DdmConnection_start) { -+ dlclose(libddmconnection_dso); -+ return false; -+ } -+ (*DdmConnection_start)(getServiceName()); -+ return true; -+} -+ -+status_t SurfaceFlinger::onTransact( -+ uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) -+{ -+ switch (code) { -+ case CREATE_CONNECTION: -+ case CREATE_DISPLAY: -+ case BOOT_FINISHED: -+ case CLEAR_ANIMATION_FRAME_STATS: -+ case GET_ANIMATION_FRAME_STATS: -+ case SET_POWER_MODE: -+ case GET_HDR_CAPABILITIES: -+ { -+ // codes that require permission check -+ IPCThreadState* ipc = IPCThreadState::self(); -+ const int pid = ipc->getCallingPid(); -+ const int uid = ipc->getCallingUid(); -+ if ((uid != AID_GRAPHICS && uid != AID_SYSTEM && uid != 100000) && -+ !PermissionCache::checkPermission(sAccessSurfaceFlinger, pid, uid)) { -+ ALOGE("Permission Denial: " -+ "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid); -+ return PERMISSION_DENIED; -+ } -+ break; -+ } -+ /* -+ * Calling setTransactionState is safe, because you need to have been -+ * granted a reference to Client* and Handle* to do anything with it. -+ * -+ * Creating a scoped connection is safe, as per discussion in ISurfaceComposer.h -+ */ -+ case SET_TRANSACTION_STATE: -+ case CREATE_SCOPED_CONNECTION: -+ { -+ break; -+ } -+ case CAPTURE_SCREEN: -+ { -+ // codes that require permission check -+ IPCThreadState* ipc = IPCThreadState::self(); -+ const int pid = ipc->getCallingPid(); -+ const int uid = ipc->getCallingUid(); -+ if ((uid != AID_GRAPHICS && uid != 100000) && -+ !PermissionCache::checkPermission(sReadFramebuffer, pid, uid)) { -+ ALOGE("Permission Denial: " -+ "can't read framebuffer pid=%d, uid=%d", pid, uid); -+ return PERMISSION_DENIED; -+ } -+ break; -+ } -+ } -+ -+ status_t err = BnSurfaceComposer::onTransact(code, data, reply, flags); -+ if (err == UNKNOWN_TRANSACTION || err == PERMISSION_DENIED) { -+ CHECK_INTERFACE(ISurfaceComposer, data, reply); -+ if (CC_UNLIKELY(!PermissionCache::checkCallingPermission(sHardwareTest))) { -+ IPCThreadState* ipc = IPCThreadState::self(); -+ const int pid = ipc->getCallingPid(); -+ const int uid = ipc->getCallingUid(); -+ ALOGE("Permission Denial: " -+ "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid); -+ return PERMISSION_DENIED; -+ } -+ int n; -+ switch (code) { -+ case 1000: // SHOW_CPU, NOT SUPPORTED ANYMORE -+ case 1001: // SHOW_FPS, NOT SUPPORTED ANYMORE -+ return NO_ERROR; -+ case 1002: // SHOW_UPDATES -+ n = data.readInt32(); -+ mDebugRegion = n ? n : (mDebugRegion ? 0 : 1); -+ invalidateHwcGeometry(); -+ repaintEverything(); -+ return NO_ERROR; -+ case 1004:{ // repaint everything -+ repaintEverything(); -+ return NO_ERROR; -+ } -+ case 1005:{ // force transaction -+ setTransactionFlags( -+ eTransactionNeeded| -+ eDisplayTransactionNeeded| -+ eTraversalNeeded); -+ return NO_ERROR; -+ } -+ case 1006:{ // send empty update -+ signalRefresh(); -+ return NO_ERROR; -+ } -+ case 1008: // toggle use of hw composer -+ n = data.readInt32(); -+ mDebugDisableHWC = n ? 1 : 0; -+ invalidateHwcGeometry(); -+ repaintEverything(); -+ return NO_ERROR; -+ case 1009: // toggle use of transform hint -+ n = data.readInt32(); -+ mDebugDisableTransformHint = n ? 1 : 0; -+ invalidateHwcGeometry(); -+ repaintEverything(); -+ return NO_ERROR; -+ case 1010: // interrogate. -+ reply->writeInt32(0); -+ reply->writeInt32(0); -+ reply->writeInt32(mDebugRegion); -+ reply->writeInt32(0); -+ reply->writeInt32(mDebugDisableHWC); -+ return NO_ERROR; -+ case 1013: { -+ Mutex::Autolock _l(mStateLock); -+ sp hw(getDefaultDisplayDevice()); -+ reply->writeInt32(hw->getPageFlipCount()); -+ return NO_ERROR; -+ } -+ case 1014: { -+ // daltonize -+ n = data.readInt32(); -+ switch (n % 10) { -+ case 1: -+ mDaltonizer.setType(ColorBlindnessType::Protanomaly); -+ break; -+ case 2: -+ mDaltonizer.setType(ColorBlindnessType::Deuteranomaly); -+ break; -+ case 3: -+ mDaltonizer.setType(ColorBlindnessType::Tritanomaly); -+ break; -+ } -+ if (n >= 10) { -+ mDaltonizer.setMode(ColorBlindnessMode::Correction); -+ } else { -+ mDaltonizer.setMode(ColorBlindnessMode::Simulation); -+ } -+ mDaltonize = n > 0; -+ invalidateHwcGeometry(); -+ repaintEverything(); -+ return NO_ERROR; -+ } -+ case 1015: { -+ // apply a color matrix -+ n = data.readInt32(); -+ mHasColorMatrix = n ? 1 : 0; -+ if (n) { -+ // color matrix is sent as mat3 matrix followed by vec3 -+ // offset, then packed into a mat4 where the last row is -+ // the offset and extra values are 0 -+ for (size_t i = 0 ; i < 4; i++) { -+ for (size_t j = 0; j < 4; j++) { -+ mColorMatrix[i][j] = data.readFloat(); -+ } -+ } -+ } else { -+ mColorMatrix = mat4(); -+ } -+ invalidateHwcGeometry(); -+ repaintEverything(); -+ return NO_ERROR; -+ } -+ // This is an experimental interface -+ // Needs to be shifted to proper binder interface when we productize -+ case 1016: { -+ n = data.readInt32(); -+ mPrimaryDispSync.setRefreshSkipCount(n); -+ return NO_ERROR; -+ } -+ case 1017: { -+ n = data.readInt32(); -+ mForceFullDamage = static_cast(n); -+ return NO_ERROR; -+ } -+ case 1018: { // Modify Choreographer's phase offset -+ n = data.readInt32(); -+ mEventThread->setPhaseOffset(static_cast(n)); -+ return NO_ERROR; -+ } -+ case 1019: { // Modify SurfaceFlinger's phase offset -+ n = data.readInt32(); -+ mSFEventThread->setPhaseOffset(static_cast(n)); -+ return NO_ERROR; -+ } -+ case 1020: { // Layer updates interceptor -+ n = data.readInt32(); -+ if (n) { -+ ALOGV("Interceptor enabled"); -+ mInterceptor.enable(mDrawingState.layersSortedByZ, mDrawingState.displays); -+ } -+ else{ -+ ALOGV("Interceptor disabled"); -+ mInterceptor.disable(); -+ } -+ return NO_ERROR; -+ } -+ case 1021: { // Disable HWC virtual displays -+ n = data.readInt32(); -+ mUseHwcVirtualDisplays = !n; -+ return NO_ERROR; -+ } -+ } -+ } -+ return err; -+} -+ -+void SurfaceFlinger::repaintEverything() { -+ android_atomic_or(1, &mRepaintEverything); -+ signalTransaction(); -+} -+ -+// --------------------------------------------------------------------------- -+// Capture screen into an IGraphiBufferProducer -+// --------------------------------------------------------------------------- -+ -+/* The code below is here to handle b/8734824 -+ * -+ * We create a IGraphicBufferProducer wrapper that forwards all calls -+ * from the surfaceflinger thread to the calling binder thread, where they -+ * are executed. This allows the calling thread in the calling process to be -+ * reused and not depend on having "enough" binder threads to handle the -+ * requests. -+ */ -+class GraphicProducerWrapper : public BBinder, public MessageHandler { -+ /* Parts of GraphicProducerWrapper are run on two different threads, -+ * communicating by sending messages via Looper but also by shared member -+ * data. Coherence maintenance is subtle and in places implicit (ugh). -+ * -+ * Don't rely on Looper's sendMessage/handleMessage providing -+ * release/acquire semantics for any data not actually in the Message. -+ * Data going from surfaceflinger to binder threads needs to be -+ * synchronized explicitly. -+ * -+ * Barrier open/wait do provide release/acquire semantics. This provides -+ * implicit synchronization for data coming back from binder to -+ * surfaceflinger threads. -+ */ -+ -+ sp impl; -+ sp looper; -+ status_t result; -+ bool exitPending; -+ bool exitRequested; -+ Barrier barrier; -+ uint32_t code; -+ Parcel const* data; -+ Parcel* reply; -+ -+ enum { -+ MSG_API_CALL, -+ MSG_EXIT -+ }; -+ -+ /* -+ * Called on surfaceflinger thread. This is called by our "fake" -+ * BpGraphicBufferProducer. We package the data and reply Parcel and -+ * forward them to the binder thread. -+ */ -+ virtual status_t transact(uint32_t code, -+ const Parcel& data, Parcel* reply, uint32_t /* flags */) { -+ this->code = code; -+ this->data = &data; -+ this->reply = reply; -+ if (exitPending) { -+ // if we've exited, we run the message synchronously right here. -+ // note (JH): as far as I can tell from looking at the code, this -+ // never actually happens. if it does, i'm not sure if it happens -+ // on the surfaceflinger or binder thread. -+ handleMessage(Message(MSG_API_CALL)); -+ } else { -+ barrier.close(); -+ // Prevent stores to this->{code, data, reply} from being -+ // reordered later than the construction of Message. -+ atomic_thread_fence(memory_order_release); -+ looper->sendMessage(this, Message(MSG_API_CALL)); -+ barrier.wait(); -+ } -+ return result; -+ } -+ -+ /* -+ * here we run on the binder thread. All we've got to do is -+ * call the real BpGraphicBufferProducer. -+ */ -+ virtual void handleMessage(const Message& message) { -+ int what = message.what; -+ // Prevent reads below from happening before the read from Message -+ atomic_thread_fence(memory_order_acquire); -+ if (what == MSG_API_CALL) { -+ result = IInterface::asBinder(impl)->transact(code, data[0], reply); -+ barrier.open(); -+ } else if (what == MSG_EXIT) { -+ exitRequested = true; -+ } -+ } -+ -+public: -+ explicit GraphicProducerWrapper(const sp& impl) -+ : impl(impl), -+ looper(new Looper(true)), -+ result(NO_ERROR), -+ exitPending(false), -+ exitRequested(false), -+ code(0), -+ data(NULL), -+ reply(NULL) -+ {} -+ -+ // Binder thread -+ status_t waitForResponse() { -+ do { -+ looper->pollOnce(-1); -+ } while (!exitRequested); -+ return result; -+ } -+ -+ // Client thread -+ void exit(status_t result) { -+ this->result = result; -+ exitPending = true; -+ // Ensure this->result is visible to the binder thread before it -+ // handles the message. -+ atomic_thread_fence(memory_order_release); -+ looper->sendMessage(this, Message(MSG_EXIT)); -+ } -+}; -+ -+ -+status_t SurfaceFlinger::captureScreen(const sp& display, -+ const sp& producer, -+ Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, -+ int32_t minLayerZ, int32_t maxLayerZ, -+ bool useIdentityTransform, ISurfaceComposer::Rotation rotation) { -+ -+ if (CC_UNLIKELY(display == 0)) -+ return BAD_VALUE; -+ -+ if (CC_UNLIKELY(producer == 0)) -+ return BAD_VALUE; -+ -+ // if we have secure windows on this display, never allow the screen capture -+ // unless the producer interface is local (i.e.: we can take a screenshot for -+ // ourselves). -+ bool isLocalScreenshot = IInterface::asBinder(producer)->localBinder(); -+ -+ // Convert to surfaceflinger's internal rotation type. -+ Transform::orientation_flags rotationFlags; -+ switch (rotation) { -+ case ISurfaceComposer::eRotateNone: -+ rotationFlags = Transform::ROT_0; -+ break; -+ case ISurfaceComposer::eRotate90: -+ rotationFlags = Transform::ROT_90; -+ break; -+ case ISurfaceComposer::eRotate180: -+ rotationFlags = Transform::ROT_180; -+ break; -+ case ISurfaceComposer::eRotate270: -+ rotationFlags = Transform::ROT_270; -+ break; -+ default: -+ rotationFlags = Transform::ROT_0; -+ ALOGE("Invalid rotation passed to captureScreen(): %d\n", rotation); -+ break; -+ } -+ -+ class MessageCaptureScreen : public MessageBase { -+ SurfaceFlinger* flinger; -+ sp display; -+ sp producer; -+ Rect sourceCrop; -+ uint32_t reqWidth, reqHeight; -+ int32_t minLayerZ,maxLayerZ; -+ bool useIdentityTransform; -+ Transform::orientation_flags rotation; -+ status_t result; -+ bool isLocalScreenshot; -+ public: -+ MessageCaptureScreen(SurfaceFlinger* flinger, -+ const sp& display, -+ const sp& producer, -+ Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, -+ int32_t minLayerZ, int32_t maxLayerZ, -+ bool useIdentityTransform, -+ Transform::orientation_flags rotation, -+ bool isLocalScreenshot) -+ : flinger(flinger), display(display), producer(producer), -+ sourceCrop(sourceCrop), reqWidth(reqWidth), reqHeight(reqHeight), -+ minLayerZ(minLayerZ), maxLayerZ(maxLayerZ), -+ useIdentityTransform(useIdentityTransform), -+ rotation(rotation), result(PERMISSION_DENIED), -+ isLocalScreenshot(isLocalScreenshot) -+ { -+ } -+ status_t getResult() const { -+ return result; -+ } -+ virtual bool handler() { -+ Mutex::Autolock _l(flinger->mStateLock); -+ sp hw(flinger->getDisplayDeviceLocked(display)); -+ result = flinger->captureScreenImplLocked(hw, producer, -+ sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, -+ useIdentityTransform, rotation, isLocalScreenshot); -+ static_cast(IInterface::asBinder(producer).get())->exit(result); -+ return true; -+ } -+ }; -+ -+ // this creates a "fake" BBinder which will serve as a "fake" remote -+ // binder to receive the marshaled calls and forward them to the -+ // real remote (a BpGraphicBufferProducer) -+ sp wrapper = new GraphicProducerWrapper(producer); -+ -+ // the asInterface() call below creates our "fake" BpGraphicBufferProducer -+ // which does the marshaling work forwards to our "fake remote" above. -+ sp msg = new MessageCaptureScreen(this, -+ display, IGraphicBufferProducer::asInterface( wrapper ), -+ sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, -+ useIdentityTransform, rotationFlags, isLocalScreenshot); -+ -+ status_t res = postMessageAsync(msg); -+ if (res == NO_ERROR) { -+ res = wrapper->waitForResponse(); -+ } -+ return res; -+} -+ -+ -+void SurfaceFlinger::renderScreenImplLocked( -+ const sp& hw, -+ Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, -+ int32_t minLayerZ, int32_t maxLayerZ, -+ bool yswap, bool useIdentityTransform, Transform::orientation_flags rotation) -+{ -+ ATRACE_CALL(); -+ RenderEngine& engine(getRenderEngine()); -+ -+ // get screen geometry -+ const int32_t hw_w = hw->getWidth(); -+ const int32_t hw_h = hw->getHeight(); -+ const bool filtering = static_cast(reqWidth) != hw_w || -+ static_cast(reqHeight) != hw_h; -+ -+ // if a default or invalid sourceCrop is passed in, set reasonable values -+ if (sourceCrop.width() == 0 || sourceCrop.height() == 0 || -+ !sourceCrop.isValid()) { -+ sourceCrop.setLeftTop(Point(0, 0)); -+ sourceCrop.setRightBottom(Point(hw_w, hw_h)); -+ } -+ -+ // ensure that sourceCrop is inside screen -+ if (sourceCrop.left < 0) { -+ ALOGE("Invalid crop rect: l = %d (< 0)", sourceCrop.left); -+ } -+ if (sourceCrop.right > hw_w) { -+ ALOGE("Invalid crop rect: r = %d (> %d)", sourceCrop.right, hw_w); -+ } -+ if (sourceCrop.top < 0) { -+ ALOGE("Invalid crop rect: t = %d (< 0)", sourceCrop.top); -+ } -+ if (sourceCrop.bottom > hw_h) { -+ ALOGE("Invalid crop rect: b = %d (> %d)", sourceCrop.bottom, hw_h); -+ } -+ -+ // make sure to clear all GL error flags -+ engine.checkErrors(); -+ -+ // set-up our viewport -+ engine.setViewportAndProjection( -+ reqWidth, reqHeight, sourceCrop, hw_h, yswap, rotation); -+ engine.disableTexturing(); -+ -+ // redraw the screen entirely... -+ engine.clearWithColor(0, 0, 0, 1); -+ -+ // We loop through the first level of layers without traversing, -+ // as we need to interpret min/max layer Z in the top level Z space. -+ for (const auto& layer : mDrawingState.layersSortedByZ) { -+ if (layer->getLayerStack() != hw->getLayerStack()) { -+ continue; -+ } -+ const Layer::State& state(layer->getDrawingState()); -+ if (state.z < minLayerZ || state.z > maxLayerZ) { -+ continue; -+ } -+ layer->traverseInZOrder(LayerVector::StateSet::Drawing, [&](Layer* layer) { -+ if (!layer->isVisible()) { -+ return; -+ } -+ if (filtering) layer->setFiltering(true); -+ layer->draw(hw, useIdentityTransform); -+ if (filtering) layer->setFiltering(false); -+ }); -+ } -+ -+ // compositionComplete is needed for older driver -+ hw->compositionComplete(); -+ hw->setViewportAndProjection(); -+} -+ -+ -+status_t SurfaceFlinger::captureScreenImplLocked( -+ const sp& hw, -+ const sp& producer, -+ Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, -+ int32_t minLayerZ, int32_t maxLayerZ, -+ bool useIdentityTransform, Transform::orientation_flags rotation, -+ bool isLocalScreenshot) -+{ -+ ATRACE_CALL(); -+ -+ // get screen geometry -+ uint32_t hw_w = hw->getWidth(); -+ uint32_t hw_h = hw->getHeight(); -+ -+ if (rotation & Transform::ROT_90) { -+ std::swap(hw_w, hw_h); -+ } -+ -+ if ((reqWidth > hw_w) || (reqHeight > hw_h)) { -+ ALOGE("size mismatch (%d, %d) > (%d, %d)", -+ reqWidth, reqHeight, hw_w, hw_h); -+ return BAD_VALUE; -+ } -+ -+ reqWidth = (!reqWidth) ? hw_w : reqWidth; -+ reqHeight = (!reqHeight) ? hw_h : reqHeight; -+ -+ bool secureLayerIsVisible = false; -+ for (const auto& layer : mDrawingState.layersSortedByZ) { -+ const Layer::State& state(layer->getDrawingState()); -+ if ((layer->getLayerStack() != hw->getLayerStack()) || -+ (state.z < minLayerZ || state.z > maxLayerZ)) { -+ continue; -+ } -+ layer->traverseInZOrder(LayerVector::StateSet::Drawing, [&](Layer *layer) { -+ secureLayerIsVisible = secureLayerIsVisible || (layer->isVisible() && -+ layer->isSecure()); -+ }); -+ } -+ -+ if (!isLocalScreenshot && secureLayerIsVisible) { -+ ALOGW("FB is protected: PERMISSION_DENIED"); -+ return PERMISSION_DENIED; -+ } -+ -+ // create a surface (because we're a producer, and we need to -+ // dequeue/queue a buffer) -+ sp sur = new Surface(producer, false); -+ ANativeWindow* window = sur.get(); -+ -+ status_t result = native_window_api_connect(window, NATIVE_WINDOW_API_EGL); -+ if (result == NO_ERROR) { -+ uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | -+ GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE; -+ -+ int err = 0; -+ err = native_window_set_buffers_dimensions(window, reqWidth, reqHeight); -+ err |= native_window_set_scaling_mode(window, NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW); -+ err |= native_window_set_buffers_format(window, HAL_PIXEL_FORMAT_RGBA_8888); -+ err |= native_window_set_usage(window, usage); -+ -+ if (err == NO_ERROR) { -+ ANativeWindowBuffer* buffer; -+ /* TODO: Once we have the sync framework everywhere this can use -+ * server-side waits on the fence that dequeueBuffer returns. -+ */ -+ result = native_window_dequeue_buffer_and_wait(window, &buffer); -+ if (result == NO_ERROR) { -+ int syncFd = -1; -+ // create an EGLImage from the buffer so we can later -+ // turn it into a texture -+ EGLImageKHR image = eglCreateImageKHR(mEGLDisplay, EGL_NO_CONTEXT, -+ EGL_NATIVE_BUFFER_ANDROID, buffer, NULL); -+ if (image != EGL_NO_IMAGE_KHR) { -+ // this binds the given EGLImage as a framebuffer for the -+ // duration of this scope. -+ RenderEngine::BindImageAsFramebuffer imageBond(getRenderEngine(), image); -+ if (imageBond.getStatus() == NO_ERROR) { -+ // this will in fact render into our dequeued buffer -+ // via an FBO, which means we didn't have to create -+ // an EGLSurface and therefore we're not -+ // dependent on the context's EGLConfig. -+ renderScreenImplLocked( -+ hw, sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ, true, -+ useIdentityTransform, rotation); -+ -+ // Attempt to create a sync khr object that can produce a sync point. If that -+ // isn't available, create a non-dupable sync object in the fallback path and -+ // wait on it directly. -+ EGLSyncKHR sync; -+ if (!DEBUG_SCREENSHOTS) { -+ sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL); -+ // native fence fd will not be populated until flush() is done. -+ getRenderEngine().flush(); -+ } else { -+ sync = EGL_NO_SYNC_KHR; -+ } -+ if (sync != EGL_NO_SYNC_KHR) { -+ // get the sync fd -+ syncFd = eglDupNativeFenceFDANDROID(mEGLDisplay, sync); -+ if (syncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) { -+ ALOGW("captureScreen: failed to dup sync khr object"); -+ syncFd = -1; -+ } -+ eglDestroySyncKHR(mEGLDisplay, sync); -+ } else { -+ // fallback path -+ sync = eglCreateSyncKHR(mEGLDisplay, EGL_SYNC_FENCE_KHR, NULL); -+ if (sync != EGL_NO_SYNC_KHR) { -+ EGLint result = eglClientWaitSyncKHR(mEGLDisplay, sync, -+ EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, 2000000000 /*2 sec*/); -+ EGLint eglErr = eglGetError(); -+ if (result == EGL_TIMEOUT_EXPIRED_KHR) { -+ ALOGW("captureScreen: fence wait timed out"); -+ } else { -+ ALOGW_IF(eglErr != EGL_SUCCESS, -+ "captureScreen: error waiting on EGL fence: %#x", eglErr); -+ } -+ eglDestroySyncKHR(mEGLDisplay, sync); -+ } else { -+ ALOGW("captureScreen: error creating EGL fence: %#x", eglGetError()); -+ } -+ } -+ if (DEBUG_SCREENSHOTS) { -+ uint32_t* pixels = new uint32_t[reqWidth*reqHeight]; -+ getRenderEngine().readPixels(0, 0, reqWidth, reqHeight, pixels); -+ checkScreenshot(reqWidth, reqHeight, reqWidth, pixels, -+ hw, minLayerZ, maxLayerZ); -+ delete [] pixels; -+ } -+ -+ } else { -+ ALOGE("got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot"); -+ result = INVALID_OPERATION; -+ window->cancelBuffer(window, buffer, syncFd); -+ buffer = NULL; -+ } -+ // destroy our image -+ eglDestroyImageKHR(mEGLDisplay, image); -+ } else { -+ result = BAD_VALUE; -+ } -+ if (buffer) { -+ // queueBuffer takes ownership of syncFd -+ result = window->queueBuffer(window, buffer, syncFd); -+ } -+ } -+ } else { -+ result = BAD_VALUE; -+ } -+ native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL); -+ } -+ -+ return result; -+} -+ -+void SurfaceFlinger::checkScreenshot(size_t w, size_t s, size_t h, void const* vaddr, -+ const sp& hw, int32_t minLayerZ, int32_t maxLayerZ) { -+ if (DEBUG_SCREENSHOTS) { -+ for (size_t y=0 ; ygetLayerStack()); -+ size_t i = 0; -+ for (const auto& layer : mDrawingState.layersSortedByZ) { -+ const Layer::State& state(layer->getDrawingState()); -+ if (layer->getLayerStack() == hw->getLayerStack() && state.z >= minLayerZ && -+ state.z <= maxLayerZ) { -+ layer->traverseInZOrder(LayerVector::StateSet::Drawing, [&](Layer* layer) { -+ ALOGE("%c index=%zu, name=%s, layerStack=%d, z=%d, visible=%d, flags=%x, alpha=%x", -+ layer->isVisible() ? '+' : '-', -+ i, layer->getName().string(), layer->getLayerStack(), state.z, -+ layer->isVisible(), state.flags, state.alpha); -+ i++; -+ }); -+ } -+ } -+ } -+} -+ -+// --------------------------------------------------------------------------- -+ -+void SurfaceFlinger::State::traverseInZOrder(const LayerVector::Visitor& visitor) const { -+ layersSortedByZ.traverseInZOrder(stateSet, visitor); -+} -+ -+void SurfaceFlinger::State::traverseInReverseZOrder(const LayerVector::Visitor& visitor) const { -+ layersSortedByZ.traverseInReverseZOrder(stateSet, visitor); -+} -+ -+}; // namespace android -+ -+ -+#if defined(__gl_h_) -+#error "don't include gl/gl.h in this file" -+#endif -+ -+#if defined(__gl2_h_) -+#error "don't include gl2/gl2.h in this file" -+#endif +@@ -5189,7 +5189,7 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r + IPCThreadState* ipc = IPCThreadState::self(); + const int uid = ipc->getCallingUid(); + if (CC_UNLIKELY(uid != AID_SYSTEM +- && !PermissionCache::checkCallingPermission(sHardwareTest))) { ++ && !PermissionCache::checkCallingPermission(sHardwareTest) && uid != 0 && uid != 10000)) { + const int pid = ipc->getCallingPid(); + ALOGE("Permission Denial: " + "can't access SurfaceFlinger pid=%d, uid=%d", pid, uid); diff --git a/services/surfaceflinger/surfaceflinger.rc b/services/surfaceflinger/surfaceflinger.rc -index aea602b..12482c7 100644 +index aea602bba..a48041daf 100644 --- a/services/surfaceflinger/surfaceflinger.rc +++ b/services/surfaceflinger/surfaceflinger.rc @@ -7,3 +7,4 @@ service surfaceflinger /system/bin/surfaceflinger @@ -4170,6 +70,7 @@ index aea602b..12482c7 100644 socket pdx/system/vr/display/manager stream 0666 system graphics u:object_r:pdx_display_manager_endpoint_socket:s0 socket pdx/system/vr/display/vsync stream 0666 system graphics u:object_r:pdx_display_vsync_endpoint_socket:s0 + setenv LD_PRELOAD /usr/libexec/droid-hybris/system/lib64/libsurfaceflinger.so +\ No newline at end of file -- -2.7.4 +2.23.0 diff --git a/frameworks/native/0005-hybris-Create-the-somehow-missing-settingsd-socket-f.patch b/frameworks/native/0005-hybris-Create-the-somehow-missing-settingsd-socket-f.patch index 6a5d1c1..1a9793f 100644 --- a/frameworks/native/0005-hybris-Create-the-somehow-missing-settingsd-socket-f.patch +++ b/frameworks/native/0005-hybris-Create-the-somehow-missing-settingsd-socket-f.patch @@ -1,4 +1,4 @@ -From 36bf4036b08f84e9756346c9c278ff87f191cc99 Mon Sep 17 00:00:00 2001 +From e8a88f226a0548dcdd2f4ea6f278ccd210b62582 Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Sun, 16 Jun 2019 13:14:30 +0200 Subject: [PATCH 5/5] (hybris) Create the (somehow) missing settingsd socket @@ -10,10 +10,10 @@ Change-Id: Ic7415aab65788f37ee5c5a67be1916319e484f77 1 file changed, 7 insertions(+) diff --git a/cmds/servicemanager/servicemanager.rc b/cmds/servicemanager/servicemanager.rc -index 1930612..03803d1 100644 +index 1f447f9b0..3211e23f1 100644 --- a/cmds/servicemanager/servicemanager.rc +++ b/cmds/servicemanager/servicemanager.rc -@@ -34,3 +34,10 @@ service miniaf /usr/libexec/droid-hybris/system/bin/miniafservice +@@ -32,3 +32,10 @@ service miniaf /usr/libexec/droid-hybris/system/bin/miniafservice class main user system group audio @@ -25,5 +25,5 @@ index 1930612..03803d1 100644 + class early_hal + oneshot -- -2.7.4 +2.23.0 diff --git a/hardware/libhardware/0001-hybris-Add-aapcs-float-handling-to-audio-api-headers.patch b/hardware/libhardware/0001-hybris-Add-aapcs-float-handling-to-audio-api-headers.patch index 448726c..ea18cde 100644 --- a/hardware/libhardware/0001-hybris-Add-aapcs-float-handling-to-audio-api-headers.patch +++ b/hardware/libhardware/0001-hybris-Add-aapcs-float-handling-to-audio-api-headers.patch @@ -1,4 +1,4 @@ -From d6d20d56e45a3799c9edf386b73b0a450c2b20f0 Mon Sep 17 00:00:00 2001 +From d90de882771f1a2b1c4730a668f00a6897b11f1f Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Wed, 21 May 2014 01:23:45 +0530 Subject: [PATCH 1/3] (hybris) Add aapcs float handling to audio api headers @@ -9,7 +9,7 @@ Change-Id: I2b0015aa75e1afa849a5563fa92d041c37f88780 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/hardware/audio.h b/include/hardware/audio.h -index 10a8789..9034816 100644 +index feebd23e..c0f56c5d 100644 --- a/include/hardware/audio.h +++ b/include/hardware/audio.h @@ -30,6 +30,12 @@ @@ -43,7 +43,7 @@ index 10a8789..9034816 100644 /** Read audio buffer in from audio driver. Returns number of bytes read, or a * negative status_t. If at least one frame was read prior to the error, -@@ -649,14 +655,14 @@ struct audio_hw_device { +@@ -679,14 +685,14 @@ struct audio_hw_device { int (*init_check)(const struct audio_hw_device *dev); /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */ @@ -60,7 +60,7 @@ index 10a8789..9034816 100644 /** * Get the current master volume value for the HAL, if the HAL supports -@@ -665,7 +671,7 @@ struct audio_hw_device { +@@ -695,7 +701,7 @@ struct audio_hw_device { * the initial master volume across all HALs. HALs which do not support * this method may leave it set to NULL. */ @@ -70,5 +70,5 @@ index 10a8789..9034816 100644 /** * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode -- -2.7.4 +2.23.0 diff --git a/hardware/libhardware/0002-hybris-Search-for-libraries-first-from-usr-libexec-d.patch b/hardware/libhardware/0002-hybris-Search-for-libraries-first-from-usr-libexec-d.patch index 1f1c355..d2ac6e5 100644 --- a/hardware/libhardware/0002-hybris-Search-for-libraries-first-from-usr-libexec-d.patch +++ b/hardware/libhardware/0002-hybris-Search-for-libraries-first-from-usr-libexec-d.patch @@ -1,4 +1,4 @@ -From c4497049d7c4e5fc9084aec50469137c8bc8ef9f Mon Sep 17 00:00:00 2001 +From 926be8f94140a3f2b966c1d5a3465729c0065982 Mon Sep 17 00:00:00 2001 From: Matti Lehtimaki Date: Wed, 5 Aug 2015 14:31:01 +0200 Subject: [PATCH 2/3] (hybris) Search for libraries first from @@ -10,10 +10,10 @@ Change-Id: I7496d961f8218b6077b9d628dd350ac20550b5d2 1 file changed, 7 insertions(+) diff --git a/hardware.c b/hardware.c -index 77cfd8d..1a811fe 100644 +index 6e72ce9f..ecdcf879 100644 --- a/hardware.c +++ b/hardware.c -@@ -36,10 +36,12 @@ +@@ -39,10 +39,12 @@ #define HAL_LIBRARY_PATH1 "/system/lib64/hw" #define HAL_LIBRARY_PATH2 "/vendor/lib64/hw" #define HAL_LIBRARY_PATH3 "/odm/lib64/hw" @@ -26,18 +26,18 @@ index 77cfd8d..1a811fe 100644 #endif /** -@@ -149,6 +151,11 @@ static int hw_module_exists(char *path, size_t path_len, const char *name, +@@ -174,6 +176,11 @@ static bool path_in_path(const char *path, const char *in_path) { + static int hw_module_exists(char *path, size_t path_len, const char *name, const char *subname) { - snprintf(path, path_len, "%s/%s.%s.so", -+ HAL_LIBRARY_PATH4, name, subname); -+ if (access(path, R_OK) == 0) ++ snprintf(path, path_len, "%s/%s.%s.so", ++ HAL_LIBRARY_PATH3, name, subname); ++ if (path_in_path(path, HAL_LIBRARY_PATH4) && access(path, R_OK) == 0) + return 0; + -+ snprintf(path, path_len, "%s/%s.%s.so", + snprintf(path, path_len, "%s/%s.%s.so", HAL_LIBRARY_PATH3, name, subname); - if (access(path, R_OK) == 0) - return 0; + if (path_in_path(path, HAL_LIBRARY_PATH3) && access(path, R_OK) == 0) -- -2.7.4 +2.23.0 diff --git a/hardware/libhardware/0003-hybris-gps.h-Use-proper-aapcs-attribute-with-functio.patch b/hardware/libhardware/0003-hybris-gps.h-Use-proper-aapcs-attribute-with-functio.patch index ba07222..ec1ede1 100644 --- a/hardware/libhardware/0003-hybris-gps.h-Use-proper-aapcs-attribute-with-functio.patch +++ b/hardware/libhardware/0003-hybris-gps.h-Use-proper-aapcs-attribute-with-functio.patch @@ -1,4 +1,4 @@ -From 05c96a503f8559cb86bd82a0dce8bc6c55a02ea8 Mon Sep 17 00:00:00 2001 +From d08e91a3fa638fb67e1cac715583dac1d8d67f4e Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Tue, 30 Jan 2018 14:55:33 +0200 Subject: [PATCH 3/3] (hybris) gps.h Use proper aapcs attribute with functions @@ -9,7 +9,7 @@ Subject: [PATCH 3/3] (hybris) gps.h Use proper aapcs attribute with functions 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/hardware/gps.h b/include/hardware/gps.h -index 4e108b3..e461aa1 100644 +index 4e108b3f..e461aa1d 100644 --- a/include/hardware/gps.h +++ b/include/hardware/gps.h @@ -28,6 +28,12 @@ @@ -44,5 +44,5 @@ index 4e108b3..e461aa1 100644 /** * Pause monitoring a particular geofence. -- -2.7.4 +2.23.0 diff --git a/system/core/0001-hybris-Add-usr-libexec-droid-hybris-lib-dev-alog-to-.patch b/system/core/0001-hybris-Add-usr-libexec-droid-hybris-lib-dev-alog-to-.patch index 31f1d8b..b66b764 100644 --- a/system/core/0001-hybris-Add-usr-libexec-droid-hybris-lib-dev-alog-to-.patch +++ b/system/core/0001-hybris-Add-usr-libexec-droid-hybris-lib-dev-alog-to-.patch @@ -1,23 +1,22 @@ -From 3f10a48c586a2e21b2967ffdb6233475eefef726 Mon Sep 17 00:00:00 2001 +From 9699aa77cb111d33e9cba291851fd9cdc1ed5c75 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Wed, 6 Nov 2013 21:09:30 +0000 -Subject: [PATCH 01/39] (hybris) Add /usr/libexec/droid-hybris/lib-dev-alog/ to +Subject: [PATCH 01/40] (hybris) Add /usr/libexec/droid-hybris/lib-dev-alog/ to the LD_LIBRARY_PATH for all init'ed binaries to support the /dev/alog used in Mer Change-Id: If58b8bd7c52b71e6e1f86f714142890dc8c73fd8 --- - rootdir/init.environ.rc.in | 4 ++++ - 1 file changed, 4 insertions(+) + rootdir/init.environ.rc.in | 3 +++ + 1 file changed, 3 insertions(+) diff --git a/rootdir/init.environ.rc.in b/rootdir/init.environ.rc.in -index 2e2ab7465..deefac4e0 100644 +index 455c9a8e3..0abd169df 100644 --- a/rootdir/init.environ.rc.in +++ b/rootdir/init.environ.rc.in -@@ -1,5 +1,9 @@ +@@ -1,5 +1,8 @@ # set up the global environment - on init -+ + on early-init + export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin + # This is not 64-bit safe -stskeeps + export LD_LIBRARY_PATH /usr/libexec/droid-hybris/lib-dev-alog:/vendor/lib:/system/lib @@ -25,5 +24,5 @@ index 2e2ab7465..deefac4e0 100644 export ANDROID_ROOT /system export ANDROID_ASSETS /system/app -- -2.17.1 +2.23.0 diff --git a/system/core/0002-hybris-Don-t-create-mount-dev-proc-sys.-when-booting.patch b/system/core/0002-hybris-Don-t-create-mount-dev-proc-sys.-when-booting.patch index 090290e..685359c 100644 --- a/system/core/0002-hybris-Don-t-create-mount-dev-proc-sys.-when-booting.patch +++ b/system/core/0002-hybris-Don-t-create-mount-dev-proc-sys.-when-booting.patch @@ -1,41 +1,42 @@ -From 1653fc62093ef821c1d949b14d6d9e6e303f0734 Mon Sep 17 00:00:00 2001 +From eb2713ced66ee6af6b490a303519317edb65bb18 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 8 Oct 2013 16:59:30 +0100 -Subject: [PATCH 02/39] (hybris) Don't create/mount dev/proc/sys... when +Subject: [PATCH 02/40] (hybris) Don't create/mount dev/proc/sys... when booting with Mer Change-Id: I16afd5bf56ee3e36f09b3496b80e356ce9269a64 --- - init/init.cpp | 10 +++++----- + init/first_stage_init.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -diff --git a/init/init.cpp b/init/init.cpp -index fc58eeabb..527d275c7 100644 ---- a/init/init.cpp -+++ b/init/init.cpp -@@ -574,17 +574,17 @@ int main(int argc, char** argv) { - setenv("PATH", _PATH_DEFPATH, 1); - // Get the basic filesystem setup we need put together in the initramdisk - // on / and then we'll let the rc file figure out the rest. -- mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755"); -- mkdir("/dev/pts", 0755); -+ //mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755"); -+ //mkdir("/dev/pts", 0755); - mkdir("/dev/socket", 0755); -- mount("devpts", "/dev/pts", "devpts", 0, NULL); -+ //mount("devpts", "/dev/pts", "devpts", 0, NULL); - #define MAKE_STR(x) __STRING(x) -- mount("proc", "/proc", "proc", 0, "hidepid=2,gid=" MAKE_STR(AID_READPROC)); -+ //mount("proc", "/proc", "proc", 0, "hidepid=2,gid=" MAKE_STR(AID_READPROC)); - // Don't expose the raw commandline to unprivileged processes. - chmod("/proc/cmdline", 0440); - gid_t groups[] = { AID_READPROC }; - setgroups(arraysize(groups), groups); -- mount("sysfs", "/sys", "sysfs", 0, NULL); -+ //mount("sysfs", "/sys", "sysfs", 0, NULL); - mount("selinuxfs", "/sys/fs/selinux", "selinuxfs", 0, NULL); +diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp +index 2b899408a..998374a84 100644 +--- a/init/first_stage_init.cpp ++++ b/init/first_stage_init.cpp +@@ -117,18 +117,18 @@ int FirstStageMain(int argc, char** argv) { + CHECKCALL(setenv("PATH", _PATH_DEFPATH, 1)); + // Get the basic filesystem setup we need put together in the initramdisk + // on / and then we'll let the rc file figure out the rest. +- CHECKCALL(mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755")); +- CHECKCALL(mkdir("/dev/pts", 0755)); ++ //CHECKCALL(mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755")); ++ //CHECKCALL(mkdir("/dev/pts", 0755)); + CHECKCALL(mkdir("/dev/socket", 0755)); +- CHECKCALL(mount("devpts", "/dev/pts", "devpts", 0, NULL)); ++ //CHECKCALL(mount("devpts", "/dev/pts", "devpts", 0, NULL)); + #define MAKE_STR(x) __STRING(x) + CHECKCALL(mount("proc", "/proc", "proc", 0, "hidepid=2,gid=" MAKE_STR(AID_READPROC))); + #undef MAKE_STR + // Don't expose the raw commandline to unprivileged processes. +- CHECKCALL(chmod("/proc/cmdline", 0440)); ++ //CHECKCALL(chmod("/proc/cmdline", 0440)); + gid_t groups[] = {AID_READPROC}; + CHECKCALL(setgroups(arraysize(groups), groups)); +- CHECKCALL(mount("sysfs", "/sys", "sysfs", 0, NULL)); ++ //CHECKCALL(mount("sysfs", "/sys", "sysfs", 0, NULL)); + CHECKCALL(mount("selinuxfs", "/sys/fs/selinux", "selinuxfs", 0, NULL)); - mknod("/dev/kmsg", S_IFCHR | 0600, makedev(1, 11)); + CHECKCALL(mknod("/dev/kmsg", S_IFCHR | 0600, makedev(1, 11))); -- -2.17.1 +2.23.0 diff --git a/system/core/0003-hybris-Mer-can-specify-mis-alignment-handling-this-i.patch b/system/core/0003-hybris-Mer-can-specify-mis-alignment-handling-this-i.patch index 44f2127..82d1324 100644 --- a/system/core/0003-hybris-Mer-can-specify-mis-alignment-handling-this-i.patch +++ b/system/core/0003-hybris-Mer-can-specify-mis-alignment-handling-this-i.patch @@ -1,7 +1,7 @@ -From 1fb89692cc9d2dbb4ae1e9b861efd7ca9f3141c9 Mon Sep 17 00:00:00 2001 +From 7d692d25bfd04a767110d208769158f569034c27 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 22 Oct 2013 17:07:56 +0100 -Subject: [PATCH 03/39] (hybris) Mer can specify mis-alignment handling - this +Subject: [PATCH 03/40] (hybris) Mer can specify mis-alignment handling - this is the wrong place to set it Change-Id: Ib46c0a0b6d285dbcd05736e7ba9e9fd0a0480984 @@ -10,10 +10,10 @@ Change-Id: Ib46c0a0b6d285dbcd05736e7ba9e9fd0a0480984 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 13c5a07fd..007239393 100644 +index 893998cee..1d7b87ca9 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -109,13 +109,15 @@ on init +@@ -129,13 +129,15 @@ on init write /proc/sys/kernel/panic_on_oops 1 write /proc/sys/kernel/hung_task_timeout_secs 0 @@ -31,5 +31,5 @@ index 13c5a07fd..007239393 100644 write /proc/sys/kernel/sched_wakeup_granularity_ns 2000000 write /proc/sys/kernel/sched_child_runs_first 0 -- -2.17.1 +2.23.0 diff --git a/system/core/0004-hybris-Mount-points-are-handled-by-Mer.patch b/system/core/0004-hybris-Mount-points-are-handled-by-Mer.patch index c8735cd..3fc5b74 100644 --- a/system/core/0004-hybris-Mount-points-are-handled-by-Mer.patch +++ b/system/core/0004-hybris-Mount-points-are-handled-by-Mer.patch @@ -1,39 +1,34 @@ -From c8da084003e5d6b3f22ab9811f3d1b5c3d9f6a59 Mon Sep 17 00:00:00 2001 +From 10c2144b808ec5ede091ea3ecbd4dc505016ee09 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 22 Oct 2013 17:09:20 +0100 -Subject: [PATCH 04/39] (hybris) Mount points are handled by Mer +Subject: [PATCH 04/40] (hybris) Mount points are handled by Mer Change-Id: I295b30a47b6e147b037275032a00b304085fe711 --- - rootdir/init.rc | 14 ++++++++------ - 1 file changed, 8 insertions(+), 6 deletions(-) + rootdir/init.rc | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 007239393..513d32e24 100644 +index 1d7b87ca9..1a5a5537d 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -45,8 +45,10 @@ on init - copy /proc/cmdline /dev/urandom - copy /default.prop /dev/urandom +@@ -50,8 +50,8 @@ on init + symlink /proc/self/fd/1 /dev/stdout + symlink /proc/self/fd/2 /dev/stderr - symlink /system/bin /bin - symlink /system/etc /etc -+# symlink /system/bin /bin -+# symlink /system/etc /etc -+ -+ loglevel 64 ++ #symlink /system/bin /bin ++ #symlink /system/etc /etc # Backward compatibility. symlink /sys/kernel/debug /d -@@ -325,12 +327,12 @@ on post-fs +@@ -356,10 +356,10 @@ on post-fs # Once everything is setup, no need to modify /. - # The bind+ro combination avoids modifying any other mount flags. -- mount rootfs rootfs / remount bind ro -+ # mount rootfs rootfs / remount bind ro - # Mount shared so changes propagate into child namespaces -- mount rootfs rootfs / shared rec -+ # mount rootfs rootfs / shared rec + # The bind+remount combination allows this to work in containers. +- mount rootfs rootfs / remount bind ro nodev ++ # mount rootfs rootfs / remount bind ro nodev # Mount default storage into root namespace - mount none /mnt/runtime/default /storage bind rec - mount none none /storage slave rec @@ -43,5 +38,5 @@ index 007239393..513d32e24 100644 # Make sure /sys/kernel/debug (if present) is labeled properly # Note that tracefs may be mounted under debug, so we need to cross filesystems -- -2.17.1 +2.23.0 diff --git a/system/core/0005-hybris-Systemd-handles-control-groups.patch b/system/core/0005-hybris-Systemd-handles-control-groups.patch index f4e2aaf..c2a97d3 100644 --- a/system/core/0005-hybris-Systemd-handles-control-groups.patch +++ b/system/core/0005-hybris-Systemd-handles-control-groups.patch @@ -1,7 +1,7 @@ -From 0e7d0f8148750dc788a62f85496d32f2b384594d Mon Sep 17 00:00:00 2001 +From c5502ca02f088068ea04f5fd3e18878828e8a78a Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 22 Oct 2013 17:10:16 +0100 -Subject: [PATCH 05/39] (hybris) Systemd handles control groups +Subject: [PATCH 05/40] (hybris) Systemd handles control groups Change-Id: I92ef4b2389544906be32169c57176575eb1719ec --- @@ -9,16 +9,16 @@ Change-Id: I92ef4b2389544906be32169c57176575eb1719ec 1 file changed, 8 deletions(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 513d32e24..c882e4c3a 100644 +index 1a5a5537d..19847001f 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -28,14 +28,6 @@ on early-init - mount cgroup none /acct nodev noexec nosuid cpuacct +@@ -24,14 +24,6 @@ on early-init + mkdir /acct/uid -- # root memory control cgroup, used by lmkd -- mkdir /dev/memcg 0700 root system -- mount cgroup none /dev/memcg nodev noexec nosuid memory +- # memory.pressure_level used by lmkd +- chown root system /dev/memcg/memory.pressure_level +- chmod 0040 /dev/memcg/memory.pressure_level - # app mem cgroups, used by activity manager, lmkd and zygote - mkdir /dev/memcg/apps/ 0755 system system - # cgroup for system_server and surfaceflinger @@ -26,7 +26,7 @@ index 513d32e24..c882e4c3a 100644 - start ueventd - on init + # Run apexd-bootstrap so that APEXes that provide critical libraries -- -2.17.1 +2.23.0 diff --git a/system/core/0006-hybris-Mer-uses-udev.patch b/system/core/0006-hybris-Mer-uses-udev.patch index 808f11b..a1d5fc5 100644 --- a/system/core/0006-hybris-Mer-uses-udev.patch +++ b/system/core/0006-hybris-Mer-uses-udev.patch @@ -1,7 +1,7 @@ -From 61feac7fde3426622401f5454413245217049e4c Mon Sep 17 00:00:00 2001 +From a8c1f04597a77afae9d43a61f7bf355d1b58b52e Mon Sep 17 00:00:00 2001 From: David Greaves Date: Tue, 22 Oct 2013 17:12:18 +0100 -Subject: [PATCH 06/39] (hybris) Mer uses udev +Subject: [PATCH 06/40] (hybris) Mer uses udev Change-Id: I7588a80db2c77879fb56d5decfd055224f20ab54 --- @@ -9,18 +9,18 @@ Change-Id: I7588a80db2c77879fb56d5decfd055224f20ab54 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index c882e4c3a..2c45bb7e7 100644 +index 19847001f..9f17717b1 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -28,7 +28,7 @@ on early-init - mount cgroup none /acct nodev noexec nosuid cpuacct +@@ -24,7 +24,7 @@ on early-init + mkdir /acct/uid - start ueventd + #start ueventd - on init - sysclktz 0 + # Run apexd-bootstrap so that APEXes that provide critical libraries + # become available. Note that this is executed as exec_start to ensure that -- -2.17.1 +2.23.0 diff --git a/system/core/0007-hybris-Add-a-ready-trigger-to-init-to-run-post-boot.patch b/system/core/0007-hybris-Add-a-ready-trigger-to-init-to-run-post-boot.patch index ad70052..d6cce75 100644 --- a/system/core/0007-hybris-Add-a-ready-trigger-to-init-to-run-post-boot.patch +++ b/system/core/0007-hybris-Add-a-ready-trigger-to-init-to-run-post-boot.patch @@ -1,7 +1,7 @@ -From 6586a8c81cfc326f1cc7e3bbed8e1bc3a5247806 Mon Sep 17 00:00:00 2001 +From 74de00f618ff6fdd1a5f5f4ef6c403083037a777 Mon Sep 17 00:00:00 2001 From: David Greaves Date: Wed, 20 Nov 2013 19:18:51 +0000 -Subject: [PATCH 07/39] (hybris) Add a ready trigger to init to run post boot +Subject: [PATCH 07/40] (hybris) Add a ready trigger to init to run post boot Change-Id: I9c828463424c0e82c3de0159db08299e7ce6fe06 --- @@ -9,10 +9,10 @@ Change-Id: I9c828463424c0e82c3de0159db08299e7ce6fe06 1 file changed, 6 insertions(+) diff --git a/init/init.cpp b/init/init.cpp -index 527d275c7..9a451877a 100644 +index 6b03bc94d..c3a634bc8 100644 --- a/init/init.cpp +++ b/init/init.cpp -@@ -750,6 +750,12 @@ int main(int argc, char** argv) { +@@ -762,6 +762,12 @@ int SecondStageMain(int argc, char** argv) { // Run all property triggers based on current state of the properties. am.QueueBuiltinAction(queue_property_triggers_action, "queue_property_triggers"); @@ -24,7 +24,7 @@ index 527d275c7..9a451877a 100644 + while (true) { // By default, sleep until something happens. - int epoll_timeout_ms = -1; + auto epoll_timeout = std::optional{}; -- -2.17.1 +2.23.0 diff --git a/system/core/0008-hybris-Notify-Mer-s-systemd-that-we-re-done.patch b/system/core/0008-hybris-Notify-Mer-s-systemd-that-we-re-done.patch index 9c0dcf0..5ff9c7a 100644 --- a/system/core/0008-hybris-Notify-Mer-s-systemd-that-we-re-done.patch +++ b/system/core/0008-hybris-Notify-Mer-s-systemd-that-we-re-done.patch @@ -1,7 +1,7 @@ -From e59568278cf4a68586c426bdd2e5e5463255fce4 Mon Sep 17 00:00:00 2001 +From 3ed0e0d5da9ccea17dc64e31aedb4f5eff3dd85a Mon Sep 17 00:00:00 2001 From: David Greaves Date: Wed, 20 Nov 2013 19:24:31 +0000 -Subject: [PATCH 08/39] (hybris) Notify Mer's systemd that we're done +Subject: [PATCH 08/40] (hybris) Notify Mer's systemd that we're done Change-Id: If6a16f43397f00c8e579af79ae6cf8459786e7b3 Signed-off-by: David Greaves @@ -10,10 +10,10 @@ Signed-off-by: David Greaves 1 file changed, 16 insertions(+) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 2c45bb7e7..fbab513e5 100644 +index 9f17717b1..93dc5e13e 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -763,3 +763,19 @@ on property:ro.debuggable=1 +@@ -842,3 +842,19 @@ on property:ro.debuggable=1 service flash_recovery /system/bin/install-recovery.sh class main oneshot @@ -34,5 +34,5 @@ index 2c45bb7e7..fbab513e5 100644 + start flash_recovery + -- -2.17.1 +2.23.0 diff --git a/system/core/0009-hybris-Disable-usb-import.patch b/system/core/0009-hybris-Disable-usb-import.patch index 464b682..20ac1ff 100644 --- a/system/core/0009-hybris-Disable-usb-import.patch +++ b/system/core/0009-hybris-Disable-usb-import.patch @@ -1,7 +1,7 @@ -From ac150f4c0fe71d9535c4e79a3b5de0563ba1f1c6 Mon Sep 17 00:00:00 2001 +From 376f432dc2193cb6b55ac7e51e9ed3205e6b8f8e Mon Sep 17 00:00:00 2001 From: David Greaves Date: Wed, 19 Feb 2014 19:02:32 +0000 -Subject: [PATCH 09/39] (hybris) Disable usb import +Subject: [PATCH 09/40] (hybris) Disable usb import Change-Id: I8aba60bc79fb4aab3854f0569b325ad69c5126d4 Signed-off-by: David Greaves @@ -10,7 +10,7 @@ Signed-off-by: David Greaves 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index fbab513e5..2049b6029 100644 +index 93dc5e13e..3f4dbe678 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -5,7 +5,8 @@ @@ -24,5 +24,5 @@ index fbab513e5..2049b6029 100644 import /vendor/etc/init/hw/init.${ro.hardware}.rc import /init.usb.configfs.rc -- -2.17.1 +2.23.0 diff --git a/system/core/0010-hybris-allow-system-group-to-trigger-haptics.patch b/system/core/0010-hybris-allow-system-group-to-trigger-haptics.patch index 1d80b55..ef19a64 100644 --- a/system/core/0010-hybris-allow-system-group-to-trigger-haptics.patch +++ b/system/core/0010-hybris-allow-system-group-to-trigger-haptics.patch @@ -1,7 +1,7 @@ -From db649dd9c1c1a4608a9d6c3daefbdd168795effc Mon Sep 17 00:00:00 2001 +From 09f754eabf39dfbdcdbec23e4ad6b5fb797ca37f Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Thu, 13 Mar 2014 08:51:53 +0000 -Subject: [PATCH 10/39] (hybris) allow system group to trigger haptics +Subject: [PATCH 10/40] (hybris) allow system group to trigger haptics Signed-off-by: Simonas Leleiva @@ -14,10 +14,10 @@ Change-Id: I9f1af094fa8a4ef48f4c3ea0ec35cb66d3c083d8 1 file changed, 3 insertions(+) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 2049b6029..bed210a7d 100644 +index 3f4dbe678..0f3b85b7d 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -669,6 +669,9 @@ on boot +@@ -744,6 +744,9 @@ on boot # Define default initial receive window size in segments. setprop net.tcp.default_init_rwnd 60 @@ -28,5 +28,5 @@ index 2049b6029..bed210a7d 100644 class_start hal -- -2.17.1 +2.23.0 diff --git a/system/core/0011-hybris-trigger-late_start-on-property-change.patch b/system/core/0011-hybris-trigger-late_start-on-property-change.patch index 12bef06..32e6bd8 100644 --- a/system/core/0011-hybris-trigger-late_start-on-property-change.patch +++ b/system/core/0011-hybris-trigger-late_start-on-property-change.patch @@ -1,7 +1,7 @@ -From df2bf62529358098e1bf7402094c302765a8155c Mon Sep 17 00:00:00 2001 +From b112eb2e0639e0312fab137ff3b023bd66c8c89a Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Tue, 18 Mar 2014 14:07:11 +0000 -Subject: [PATCH 11/39] (hybris) trigger late_start on property change +Subject: [PATCH 11/40] (hybris) trigger late_start on property change Android's late_start is triggered by mount_all, which also determines whether the /data partition is encrypted. @@ -20,10 +20,10 @@ Conflicts: 1 file changed, 5 insertions(+) diff --git a/rootdir/init.rc b/rootdir/init.rc -index bed210a7d..34d46f6d2 100644 +index 0f3b85b7d..70284ead7 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -677,6 +677,7 @@ on boot +@@ -752,6 +752,7 @@ on boot class_start core @@ -31,7 +31,7 @@ index bed210a7d..34d46f6d2 100644 on nonencrypted class_start main class_start late_start -@@ -684,6 +685,10 @@ on nonencrypted +@@ -759,6 +760,10 @@ on nonencrypted on property:sys.init_log_level=* loglevel ${sys.init_log_level} @@ -43,5 +43,5 @@ index bed210a7d..34d46f6d2 100644 class_start charger -- -2.17.1 +2.23.0 diff --git a/system/core/0012-hybris-property_service.c-adding-support-for-getprop.patch b/system/core/0012-hybris-property_service.c-adding-support-for-getprop.patch index 7d13d25..4288cca 100644 --- a/system/core/0012-hybris-property_service.c-adding-support-for-getprop.patch +++ b/system/core/0012-hybris-property_service.c-adding-support-for-getprop.patch @@ -1,12 +1,16 @@ -From 6cf9230f3f32233b6ad101f244a1ed4b914c1355 Mon Sep 17 00:00:00 2001 +From 7c88d33ebd233c5f1225b7c4b43ed09b877f058f Mon Sep 17 00:00:00 2001 From: Ricardo Salveti de Araujo Date: Thu, 31 Oct 2013 12:19:19 +0200 -Subject: [PATCH 12/39] (hybris) property_service.c: adding support for getprop +Subject: [PATCH 12/40] (hybris) property_service.c: adding support for getprop and listprop +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit Change-Id: Ie5fbdb55c48038ce8250f27500623b3b81cc5cd1 Signed-off-by: Jani Monoses Signed-off-by: Ricardo Salveti de Araujo +Signed-off-by: Björn Bidar Conflicts: init/property_service.c @@ -14,36 +18,28 @@ Conflicts: Conflicts: init/property_service.cpp --- - init/init.cpp | 3 ++- - init/property_service.cpp | 36 ++++++++++++++++++++++++++++++++++++ - 2 files changed, 38 insertions(+), 1 deletion(-) + init/init.cpp | 2 +- + init/property_service.cpp | 35 +++++++++++++++++++++++++++++++++++ + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/init/init.cpp b/init/init.cpp -index 9a451877a..49f646797 100644 +index c3a634bc8..c11cdf987 100644 --- a/init/init.cpp +++ b/init/init.cpp -@@ -699,6 +699,7 @@ int main(int argc, char** argv) { - InstallSigtermHandler(); - } - -+ - property_load_boot_defaults(); - export_oem_lock_status(); - start_property_service(); -@@ -751,7 +752,7 @@ int main(int argc, char** argv) { +@@ -763,7 +763,7 @@ int SecondStageMain(int argc, char** argv) { am.QueueBuiltinAction(queue_property_triggers_action, "queue_property_triggers"); /* run all device triggers based on current state of device nodes in /dev */ - am.QueueBuiltinAction(queue_device_triggers_action, "queue_device_triggers"); -+ //am.QueueBuiltinAction(queue_device_triggers_action, "queue_device_triggers"); ++ //m.QueueBuiltinAction(queue_device_triggers_action, "queue_device_triggers"); /* Run actions when all boot up is done and init is ready */ am.QueueEventTrigger("ready"); diff --git a/init/property_service.cpp b/init/property_service.cpp -index 4172ba754..f0975313b 100644 +index f2c7462ab..9821a506c 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp -@@ -481,6 +481,9 @@ uint32_t HandlePropertySet(const std::string& name, const std::string& value, +@@ -516,6 +516,9 @@ uint32_t HandlePropertySet(const std::string& name, const std::string& value, static void handle_property_set_fd() { static constexpr uint32_t kDefaultSocketTimeout = 2000; /* ms */ @@ -53,7 +49,7 @@ index 4172ba754..f0975313b 100644 int s = accept4(property_set_fd, nullptr, nullptr, SOCK_CLOEXEC); if (s == -1) { return; -@@ -552,7 +555,40 @@ static void handle_property_set_fd() { +@@ -587,7 +590,39 @@ static void handle_property_set_fd() { socket.SendUint32(result); break; } @@ -81,10 +77,9 @@ index 4172ba754..f0975313b 100644 + break; + } + case PROP_MSG_LISTPROP: { -+ int n; + char prop_name[PROP_NAME_MAX]; + char prop_value[PROP_VALUE_MAX]; -+ for(n = 0; (pi = __system_property_find_nth(n)); n++) { ++ for(int n = 0; (pi = __system_property_find_nth(n)); n++) { + prop_name[0] = prop_value[0] = 0; + __system_property_read(pi, prop_name, prop_value); + //TEMP_FAILURE_RETRY(send(s, &msg, sizeof(msg), 0)); @@ -95,5 +90,5 @@ index 4172ba754..f0975313b 100644 LOG(ERROR) << "sys_prop: invalid command " << cmd; socket.SendUint32(PROP_ERROR_INVALID_CMD); -- -2.17.1 +2.23.0 diff --git a/system/core/0013-hybris-reach-main-init-state.patch b/system/core/0013-hybris-reach-main-init-state.patch index 472b61c..9486d9c 100644 --- a/system/core/0013-hybris-reach-main-init-state.patch +++ b/system/core/0013-hybris-reach-main-init-state.patch @@ -1,28 +1,44 @@ -From 31251fc4ee21ac0248be27efeb933dbd415e7cba Mon Sep 17 00:00:00 2001 +From ce33e4c319ab68a3d19b8f0705ee843be6abb6fa Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Sat, 22 Aug 2015 12:03:42 +0100 -Subject: [PATCH 13/39] (hybris) reach main init state +Subject: [PATCH 13/40] (hybris) reach main init state Change-Id: I471f48afaebf91c92f0d2a7bd3a24c5d1fa58ecd --- - rootdir/init.rc | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) + rootdir/init.rc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 34d46f6d2..cfebb021e 100644 +index 70284ead7..f44b75501 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -386,7 +386,9 @@ on post-fs-data - restorecon /data +@@ -342,7 +342,7 @@ on late-init - # Make sure we have the device encryption key. + on early-fs + # Once metadata has been mounted, we'll need vold to deal with userdata checkpointing +- start vold ++ #start vold + + on post-fs + exec - system system -- /system/bin/vdc checkpoint markBootAttempt +@@ -412,7 +412,7 @@ on post-fs-data + mark_post_data + + # Start checkpoint before we touch data - start vold + #start vold + exec - system system -- /system/bin/vdc checkpoint prepareCheckpoint + + # We chown/chmod /data again so because mount is run as root + defaults +@@ -422,6 +422,8 @@ on post-fs-data + restorecon /data + + # Make sure we have the device encryption key. + # hybris continue bootup properly + setprop vold.decrypt trigger_restart_min_framework installkey /data # Start bootcharting as soon as possible after the data partition is -- -2.17.1 +2.23.0 diff --git a/system/core/0014-hybris-Disable-setting-hostname-and-domainname-in-in.patch b/system/core/0014-hybris-Disable-setting-hostname-and-domainname-in-in.patch index 323ed74..60b6386 100644 --- a/system/core/0014-hybris-Disable-setting-hostname-and-domainname-in-in.patch +++ b/system/core/0014-hybris-Disable-setting-hostname-and-domainname-in-in.patch @@ -1,7 +1,7 @@ -From e24b889037c7d50de1a0bde386fc7023fa8607c0 Mon Sep 17 00:00:00 2001 +From 2907bd88ef1288c189e6c4e0599157cd097f35dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Sat, 6 Aug 2016 11:37:38 +0300 -Subject: [PATCH 14/39] (hybris) Disable setting hostname and domainname in +Subject: [PATCH 14/40] (hybris) Disable setting hostname and domainname in init.rc. Change-Id: I5b9f59e80760e53636763c89f8f76f350c17b3ec @@ -10,10 +10,10 @@ Change-Id: I5b9f59e80760e53636763c89f8f76f350c17b3ec 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index cfebb021e..876955018 100644 +index f44b75501..041e1e5df 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -580,8 +580,9 @@ on zygote-start && property:ro.crypto.state=encrypted && property:ro.crypto.type +@@ -646,8 +646,9 @@ on zygote-start && property:ro.crypto.state=encrypted && property:ro.crypto.type on boot # basic network init ifup lo @@ -26,5 +26,5 @@ index cfebb021e..876955018 100644 # IPsec SA default expiration length write /proc/sys/net/core/xfrm_acq_expires 3600 -- -2.17.1 +2.23.0 diff --git a/system/core/0015-hybris-Update-rootdir-for-64bit-libs.patch b/system/core/0015-hybris-Update-rootdir-for-64bit-libs.patch index ee59387..0939fce 100644 --- a/system/core/0015-hybris-Update-rootdir-for-64bit-libs.patch +++ b/system/core/0015-hybris-Update-rootdir-for-64bit-libs.patch @@ -1,21 +1,22 @@ -From f407437fd7b447f4b8f5262299c16fe0e33514e4 Mon Sep 17 00:00:00 2001 +From 08365a541664a8545cd71e1e0f9afa64647c2fd5 Mon Sep 17 00:00:00 2001 From: Martin Ghosal Date: Sat, 15 Oct 2016 15:38:47 +0100 -Subject: [PATCH 15/39] (hybris) Update rootdir for 64bit libs +Subject: [PATCH 15/40] (hybris) Update rootdir for 64bit libs Change-Id: I593ae40da755c116bb28c96dcace863e6b30b4cc --- - rootdir/init.environ.rc.in | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) + rootdir/init.environ.rc.in | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootdir/init.environ.rc.in b/rootdir/init.environ.rc.in -index deefac4e0..144f3d396 100644 +index 0abd169df..2194fea86 100644 --- a/rootdir/init.environ.rc.in +++ b/rootdir/init.environ.rc.in -@@ -3,7 +3,8 @@ on init - +@@ -1,8 +1,8 @@ + # set up the global environment + on early-init export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin - # This is not 64-bit safe -stskeeps +- # This is not 64-bit safe -stskeeps - export LD_LIBRARY_PATH /usr/libexec/droid-hybris/lib-dev-alog:/vendor/lib:/system/lib + # Hopefully now it is - ghosalmartin + export LD_LIBRARY_PATH /usr/libexec/droid-hybris/lib64-dev-alog:/vendor/lib64:/system/lib64:/usr/libexec/droid-hybris/lib-dev-alog:/vendor/lib:/system/lib @@ -23,5 +24,5 @@ index deefac4e0..144f3d396 100644 export ANDROID_ROOT /system export ANDROID_ASSETS /system/app -- -2.17.1 +2.23.0 diff --git a/system/core/0016-hybris-Disable-all-zygote-variations.patch b/system/core/0016-hybris-Disable-all-zygote-variations.patch index ac27a9a..0307ca2 100644 --- a/system/core/0016-hybris-Disable-all-zygote-variations.patch +++ b/system/core/0016-hybris-Disable-all-zygote-variations.patch @@ -1,7 +1,7 @@ -From a2fbf62f4b43e628a1146a1714ba64c233b8a60d Mon Sep 17 00:00:00 2001 +From 0b06b24ac5054ab07794465ed25b23069216f97b Mon Sep 17 00:00:00 2001 From: Martin Ghosal Date: Sun, 8 Jan 2017 16:34:54 +0000 -Subject: [PATCH 16/39] (hybris) Disable all zygote variations +Subject: [PATCH 16/40] (hybris) Disable all zygote variations Change-Id: Ie1ad26486f47b3bf67134db917b3c9e51536904c --- @@ -12,19 +12,20 @@ Change-Id: Ie1ad26486f47b3bf67134db917b3c9e51536904c 4 files changed, 6 insertions(+) diff --git a/rootdir/init.zygote32.rc b/rootdir/init.zygote32.rc -index ac87979ec..b24f7b5b9 100644 +index bf3fb4217..1e2062bec 100644 --- a/rootdir/init.zygote32.rc +++ b/rootdir/init.zygote32.rc -@@ -12,3 +12,4 @@ service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-sys +@@ -13,3 +13,4 @@ service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-sys onrestart restart netd onrestart restart wificond writepid /dev/cpuset/foreground/tasks + disabled +\ No newline at end of file diff --git a/rootdir/init.zygote32_64.rc b/rootdir/init.zygote32_64.rc -index a535846de..62b92363c 100644 +index 1bab588c4..108524425 100644 --- a/rootdir/init.zygote32_64.rc +++ b/rootdir/init.zygote32_64.rc -@@ -12,6 +12,7 @@ service zygote /system/bin/app_process32 -Xzygote /system/bin --zygote --start-s +@@ -13,6 +13,7 @@ service zygote /system/bin/app_process32 -Xzygote /system/bin --zygote --start-s onrestart restart netd onrestart restart wificond writepid /dev/cpuset/foreground/tasks @@ -32,25 +33,25 @@ index a535846de..62b92363c 100644 service zygote_secondary /system/bin/app_process64 -Xzygote /system/bin --zygote --socket-name=zygote_secondary class main -@@ -21,3 +22,4 @@ service zygote_secondary /system/bin/app_process64 -Xzygote /system/bin --zygote - socket zygote_secondary stream 660 root system +@@ -23,3 +24,4 @@ service zygote_secondary /system/bin/app_process64 -Xzygote /system/bin --zygote + socket usap_pool_secondary stream 660 root system onrestart restart zygote writepid /dev/cpuset/foreground/tasks + disabled diff --git a/rootdir/init.zygote64.rc b/rootdir/init.zygote64.rc -index 6fc810bfa..edf82ce4b 100644 +index 6fa210a7b..c7c5b196f 100644 --- a/rootdir/init.zygote64.rc +++ b/rootdir/init.zygote64.rc -@@ -12,3 +12,4 @@ service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-s +@@ -13,3 +13,4 @@ service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-s onrestart restart netd onrestart restart wificond writepid /dev/cpuset/foreground/tasks + disabled diff --git a/rootdir/init.zygote64_32.rc b/rootdir/init.zygote64_32.rc -index 7ddd52ee5..e74202a7e 100644 +index 48461ecd3..7a8e6ea5d 100644 --- a/rootdir/init.zygote64_32.rc +++ b/rootdir/init.zygote64_32.rc -@@ -12,6 +12,7 @@ service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-s +@@ -13,6 +13,7 @@ service zygote /system/bin/app_process64 -Xzygote /system/bin --zygote --start-s onrestart restart netd onrestart restart wificond writepid /dev/cpuset/foreground/tasks @@ -58,11 +59,11 @@ index 7ddd52ee5..e74202a7e 100644 service zygote_secondary /system/bin/app_process32 -Xzygote /system/bin --zygote --socket-name=zygote_secondary --enable-lazy-preload class main -@@ -21,3 +22,4 @@ service zygote_secondary /system/bin/app_process32 -Xzygote /system/bin --zygote - socket zygote_secondary stream 660 root system +@@ -23,3 +24,4 @@ service zygote_secondary /system/bin/app_process32 -Xzygote /system/bin --zygote + socket usap_pool_secondary stream 660 root system onrestart restart zygote writepid /dev/cpuset/foreground/tasks + disabled -- -2.17.1 +2.23.0 diff --git a/system/core/0017-hybris-Disable-ueventd-service.patch b/system/core/0017-hybris-Disable-ueventd-service.patch index 5d46132..7e59915 100644 --- a/system/core/0017-hybris-Disable-ueventd-service.patch +++ b/system/core/0017-hybris-Disable-ueventd-service.patch @@ -1,7 +1,7 @@ -From c4ad75533aa1bf52cf88d0c7245236a05d229d77 Mon Sep 17 00:00:00 2001 +From f6b43a3b1114018c3011a12722062ceb8593d0fa Mon Sep 17 00:00:00 2001 From: Martin Ghosal Date: Sun, 8 Jan 2017 17:16:08 +0000 -Subject: [PATCH 17/39] (hybris) Disable ueventd service +Subject: [PATCH 17/40] (hybris) Disable ueventd service Change-Id: I8ee7b863a533f4a6ef7658ef1c1ef4bdb95d5d65 --- @@ -9,10 +9,10 @@ Change-Id: I8ee7b863a533f4a6ef7658ef1c1ef4bdb95d5d65 1 file changed, 2 insertions(+) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 876955018..3176fe17b 100644 +index 041e1e5df..38b09a397 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -754,6 +754,8 @@ service ueventd /sbin/ueventd +@@ -833,6 +833,8 @@ service ueventd /system/bin/ueventd critical seclabel u:r:ueventd:s0 shutdown critical @@ -22,5 +22,5 @@ index 876955018..3176fe17b 100644 service console /system/bin/sh class core -- -2.17.1 +2.23.0 diff --git a/system/core/0018-hybris-Disable-SELinux.patch b/system/core/0018-hybris-Disable-SELinux.patch index 623dd0b..d3e2ae5 100644 --- a/system/core/0018-hybris-Disable-SELinux.patch +++ b/system/core/0018-hybris-Disable-SELinux.patch @@ -1,21 +1,21 @@ -From 2073c43d7f5cff33f20dc1437f68e78b37ae2c6f Mon Sep 17 00:00:00 2001 +From 9105a073c94fee5a2758b2c8bb24e3c987c712ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Thu, 9 Feb 2017 21:48:19 +0200 -Subject: [PATCH 18/39] (hybris) Disable SELinux +Subject: [PATCH 18/40] (hybris) Disable SELinux Change-Id: I0511b2a0de1b20996f4fb8e9f3569acb41e2cf0f --- init/property_service.cpp | 2 ++ init/selinux.cpp | 3 +++ - init/service.cpp | 10 +++++++++- - 3 files changed, 14 insertions(+), 1 deletion(-) + init/service.cpp | 13 ++++++++++++- + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/init/property_service.cpp b/init/property_service.cpp -index f0975313b..3333eedb1 100644 +index 9821a506c..d13f3429c 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp -@@ -112,6 +112,8 @@ void property_init() { - } +@@ -128,6 +128,8 @@ bool CanReadProperty(const std::string& source_context, const std::string& name) + static bool CheckMacPerms(const std::string& name, const char* target_context, const char* source_context, const ucred& cr) { + // Disable permission check in Mer @@ -24,11 +24,11 @@ index f0975313b..3333eedb1 100644 return false; } diff --git a/init/selinux.cpp b/init/selinux.cpp -index 0ba5c4ae3..416c12789 100644 +index 86238b430..a47baebfe 100644 --- a/init/selinux.cpp +++ b/init/selinux.cpp -@@ -382,6 +382,9 @@ bool LoadPolicy() { - } // namespace +@@ -421,6 +421,9 @@ bool LoadPolicy() { + } void SelinuxInitialize() { + // Disable in Mer @@ -38,19 +38,20 @@ index 0ba5c4ae3..416c12789 100644 LOG(INFO) << "Loading SELinux policy"; diff --git a/init/service.cpp b/init/service.cpp -index 37d3a8807..9c294af15 100644 +index ccc37b70c..c17afb246 100644 --- a/init/service.cpp +++ b/init/service.cpp -@@ -66,6 +66,8 @@ using android::base::WriteStringToFile; +@@ -70,6 +70,9 @@ using android::base::WriteStringToFile; namespace android { namespace init { +// Disable SELinux +/* ++ static Result ComputeContextFromExecutable(const std::string& service_path) { std::string computed_context; -@@ -101,6 +103,7 @@ static Result ComputeContextFromExecutable(const std::string& servi +@@ -105,6 +108,7 @@ static Result ComputeContextFromExecutable(const std::string& servi } return computed_context; } @@ -58,12 +59,13 @@ index 37d3a8807..9c294af15 100644 Result Service::SetUpMountNamespace() const { constexpr unsigned int kSafeFlags = MS_NODEV | MS_NOEXEC | MS_NOSUID; -@@ -309,11 +312,14 @@ void Service::SetProcessAttributes() { +@@ -317,11 +321,15 @@ void Service::SetProcessAttributes() { PLOG(FATAL) << "setuid failed for " << name_; } } +// Disable SELinux +/* ++ if (!seclabel_.empty()) { if (setexeccon(seclabel_.c_str()) < 0) { PLOG(FATAL) << "cannot setexeccon('" << seclabel_ << "') for " << name_; @@ -73,24 +75,25 @@ index 37d3a8807..9c294af15 100644 if (priority_ != 0) { if (setpriority(PRIO_PROCESS, 0, priority_) != 0) { PLOG(FATAL) << "setpriority failed for " << name_; -@@ -824,6 +830,8 @@ Result Service::Start() { +@@ -933,6 +941,9 @@ Result Service::Start() { } std::string scon; +// Disable SELinux +/* ++ if (!seclabel_.empty()) { scon = seclabel_; } else { -@@ -833,7 +841,7 @@ Result Service::Start() { - } - scon = *result; +@@ -952,7 +963,7 @@ Result Service::Start() { } + + post_data_ = ServiceList::GetInstance().IsPostData(); - +*/ LOG(INFO) << "starting service '" << name_ << "'..."; pid_t pid = -1; -- -2.17.1 +2.23.0 diff --git a/system/core/0019-hybris-Properly-handle-shutdown-from-Mer.patch b/system/core/0019-hybris-Properly-handle-shutdown-from-Mer.patch index 1f433ae..5be9ce8 100644 --- a/system/core/0019-hybris-Properly-handle-shutdown-from-Mer.patch +++ b/system/core/0019-hybris-Properly-handle-shutdown-from-Mer.patch @@ -1,7 +1,7 @@ -From 35bbe378ee929986fb580324be7c8cc8f8cd76e9 Mon Sep 17 00:00:00 2001 +From 02af776981132783f359f88bfb6c321547714352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Sat, 8 Jul 2017 00:27:20 +0300 -Subject: [PATCH 19/39] (hybris) Properly handle shutdown from Mer. +Subject: [PATCH 19/40] (hybris) Properly handle shutdown from Mer. Change-Id: I89daebb9559d38f3c639f4634c417252c7a92fe0 --- @@ -9,10 +9,10 @@ Change-Id: I89daebb9559d38f3c639f4634c417252c7a92fe0 1 file changed, 9 insertions(+) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 3176fe17b..86f657be2 100644 +index 38b09a397..6f9037b7e 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -789,6 +789,15 @@ service droid_init_done /bin/sh /usr/bin/droid/droid-init-done.sh +@@ -868,6 +868,15 @@ service droid_init_done /bin/sh /usr/bin/droid/droid-init-done.sh class mer oneshot @@ -29,5 +29,5 @@ index 3176fe17b..86f657be2 100644 on property:persist.sys.recovery_update=true start flash_recovery -- -2.17.1 +2.23.0 diff --git a/system/core/0020-hybris-Use-services-from-usr-libexec-droid-hybris-sy.patch b/system/core/0020-hybris-Use-services-from-usr-libexec-droid-hybris-sy.patch index 76fc9dd..e7d5c6e 100644 --- a/system/core/0020-hybris-Use-services-from-usr-libexec-droid-hybris-sy.patch +++ b/system/core/0020-hybris-Use-services-from-usr-libexec-droid-hybris-sy.patch @@ -1,7 +1,7 @@ -From 56e074cab0466e0f6f00f983f870d39c892f205e Mon Sep 17 00:00:00 2001 +From cb3474915386a486a680d5110fb4005b573303e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Thu, 9 Feb 2017 21:57:47 +0200 -Subject: [PATCH 20/39] (hybris) Use services from +Subject: [PATCH 20/40] (hybris) Use services from /usr/libexec/droid-hybris/system/etc/init/. Change-Id: I6185781c2bd6a2db281201ad705394f4d6d24131 @@ -13,10 +13,10 @@ Change-Id: I6185781c2bd6a2db281201ad705394f4d6d24131 create mode 100644 init/init_parser.cpp diff --git a/init/init.cpp b/init/init.cpp -index 49f646797..8dc013d3e 100644 +index c11cdf987..74e1c3855 100644 --- a/init/init.cpp +++ b/init/init.cpp -@@ -114,8 +114,8 @@ static void LoadBootScripts(ActionManager& action_manager, ServiceList& service_ +@@ -130,8 +130,8 @@ static void LoadBootScripts(ActionManager& action_manager, ServiceList& service_ std::string bootscript = GetProperty("ro.boot.init_rc", ""); if (bootscript.empty()) { parser.ParseConfig("/init.rc"); @@ -203,10 +203,10 @@ index 000000000..c4b80636a +} // namespace init +} // namespace android diff --git a/init/util.cpp b/init/util.cpp -index 4455b2eb1..8eb184da9 100644 +index 63d2d4442..82dfa05f0 100644 --- a/init/util.cpp +++ b/init/util.cpp -@@ -162,7 +162,8 @@ out_unlink: +@@ -158,7 +158,8 @@ out_unlink: Result ReadFile(const std::string& path) { android::base::unique_fd fd( @@ -217,5 +217,5 @@ index 4455b2eb1..8eb184da9 100644 return ErrnoError() << "open() failed"; } -- -2.17.1 +2.23.0 diff --git a/system/core/0021-hybris-Remove-LD_LIBRARY_PATH-from-init.environ.rc.patch b/system/core/0021-hybris-Remove-LD_LIBRARY_PATH-from-init.environ.rc.patch index 6e74b61..2c0682f 100644 --- a/system/core/0021-hybris-Remove-LD_LIBRARY_PATH-from-init.environ.rc.patch +++ b/system/core/0021-hybris-Remove-LD_LIBRARY_PATH-from-init.environ.rc.patch @@ -1,21 +1,22 @@ -From 91eab95aa6c08d1d6b0a34396f3fdc82c94ad06e Mon Sep 17 00:00:00 2001 +From 5a20c1057d5bb8e284f85236c263365bf9920a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Tue, 17 Oct 2017 21:58:40 +0300 -Subject: [PATCH 21/39] (hybris) Remove LD_LIBRARY_PATH from init.environ.rc +Subject: [PATCH 21/40] (hybris) Remove LD_LIBRARY_PATH from init.environ.rc Change-Id: I52a2c733f609f90b6ac31be72a4f8fe7681beac0 --- - rootdir/init.environ.rc.in | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) + rootdir/init.environ.rc.in | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootdir/init.environ.rc.in b/rootdir/init.environ.rc.in -index 144f3d396..fcafbb113 100644 +index 2194fea86..8bcad40e2 100644 --- a/rootdir/init.environ.rc.in +++ b/rootdir/init.environ.rc.in -@@ -4,7 +4,8 @@ on init +@@ -1,8 +1,8 @@ + # set up the global environment + on early-init export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin - # This is not 64-bit safe -stskeeps - # Hopefully now it is - ghosalmartin +- # Hopefully now it is - ghosalmartin - export LD_LIBRARY_PATH /usr/libexec/droid-hybris/lib64-dev-alog:/vendor/lib64:/system/lib64:/usr/libexec/droid-hybris/lib-dev-alog:/vendor/lib:/system/lib + # this breaks mixed 32/64-bit devices -mal + # export LD_LIBRARY_PATH /usr/libexec/droid-hybris/lib64-dev-alog:/vendor/lib64:/system/lib64:/usr/libexec/droid-hybris/lib-dev-alog:/vendor/lib:/system/lib @@ -23,5 +24,5 @@ index 144f3d396..fcafbb113 100644 export ANDROID_ROOT /system export ANDROID_ASSETS /system/app -- -2.17.1 +2.23.0 diff --git a/system/core/0022-hybris-define-32-bit-LD_LIBRARY_PATH-for-32-bit-devi.patch b/system/core/0022-hybris-define-32-bit-LD_LIBRARY_PATH-for-32-bit-devi.patch index 58de5d3..5bdc26f 100644 --- a/system/core/0022-hybris-define-32-bit-LD_LIBRARY_PATH-for-32-bit-devi.patch +++ b/system/core/0022-hybris-define-32-bit-LD_LIBRARY_PATH-for-32-bit-devi.patch @@ -1,25 +1,26 @@ -From 8f109bc7e60a69df91ba0fd6d98b056e8f108f71 Mon Sep 17 00:00:00 2001 +From 988accccc17569f44945b4d89a7881240200e747 Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Wed, 25 Oct 2017 14:14:59 +0300 -Subject: [PATCH 22/39] (hybris) define 32-bit LD_LIBRARY_PATH for 32-bit +Subject: [PATCH 22/40] (hybris) define 32-bit LD_LIBRARY_PATH for 32-bit devices --- - rootdir/Android.mk | 12 ++++++++++++ + rootdir/Android.mk | 13 ++++++++++++- rootdir/init.environ.rc.in | 1 + rootdir/init.extraenv.armeabi-v7a.rc | 2 ++ - rootdir/init.rc | 5 +++++ - 4 files changed, 20 insertions(+) + rootdir/init.rc | 6 ++++++ + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 rootdir/init.extraenv.armeabi-v7a.rc diff --git a/rootdir/Android.mk b/rootdir/Android.mk -index 5f5c363a7..af5e68d3a 100644 +index 7ff1588b2..407550449 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk -@@ -8,6 +8,18 @@ LOCAL_MODULE := init.rc +@@ -8,7 +8,18 @@ LOCAL_MODULE := init.rc LOCAL_SRC_FILES := $(LOCAL_MODULE) LOCAL_MODULE_CLASS := ETC LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) +-LOCAL_REQUIRED_MODULES := fsverity_init +LOCAL_REQUIRED_MODULES := init.extraenv.armeabi-v7a.rc + +include $(BUILD_PREBUILT) @@ -33,15 +34,15 @@ index 5f5c363a7..af5e68d3a 100644 +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) - include $(BUILD_PREBUILT) - + # The init symlink must be a post install command of a file that is to TARGET_ROOT_OUT. + # Since init.rc is required for init and satisfies that requirement, we hijack it to create the symlink. diff --git a/rootdir/init.environ.rc.in b/rootdir/init.environ.rc.in -index fcafbb113..516dc82f6 100644 +index 8bcad40e2..73fbaa413 100644 --- a/rootdir/init.environ.rc.in +++ b/rootdir/init.environ.rc.in -@@ -5,6 +5,7 @@ on init - # This is not 64-bit safe -stskeeps - # Hopefully now it is - ghosalmartin +@@ -2,6 +2,7 @@ + on early-init + export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin # this breaks mixed 32/64-bit devices -mal + # for 32-bit devices with android kernel logger there is now a file called init.extraenv.armeabi-v7a.rc - krnlyng # export LD_LIBRARY_PATH /usr/libexec/droid-hybris/lib64-dev-alog:/vendor/lib64:/system/lib64:/usr/libexec/droid-hybris/lib-dev-alog:/vendor/lib:/system/lib @@ -56,10 +57,10 @@ index 000000000..c96e2c65d +on init + export LD_LIBRARY_PATH /usr/libexec/droid-hybris/lib-dev-alog:/vendor/lib:/system/lib diff --git a/rootdir/init.rc b/rootdir/init.rc -index 86f657be2..8afcfcc67 100644 +index 6f9037b7e..78c99eaaf 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -4,6 +4,11 @@ +@@ -4,6 +4,12 @@ # This is a common source of Android security bugs. # @@ -68,9 +69,10 @@ index 86f657be2..8afcfcc67 100644 +# LD_LIBRARY_PATH will break some binaries, since you cannot have both +# 32 bit libraries and 64 bit libraries in your LD_LIBRARY_PATH. +import /init.extraenv.${ro.product.cpu.abi}.rc ++ import /init.environ.rc # Mer handles usb stuff #import /init.usb.rc -- -2.17.1 +2.23.0 diff --git a/system/core/0023-hybris-Fix-list-and-get-properties.patch b/system/core/0023-hybris-Fix-list-and-get-properties.patch index 34671a1..3b96c98 100644 --- a/system/core/0023-hybris-Fix-list-and-get-properties.patch +++ b/system/core/0023-hybris-Fix-list-and-get-properties.patch @@ -1,32 +1,31 @@ -From 77ffc7ac438edf9827be45b1f4db0b732d2d3779 Mon Sep 17 00:00:00 2001 +From 3a1260bbc727738877c848f412655fbc315e1882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Tue, 16 Jan 2018 16:18:31 +0200 -Subject: [PATCH 23/39] (hybris) Fix list and get properties. +Subject: [PATCH 23/40] (hybris) Fix list and get properties. Change-Id: I9deb65f147e941fc5c9f91793f851440d02260e1 --- - init/property_service.cpp | 35 ++++++++++++++++++++++++++++++----- - 1 file changed, 30 insertions(+), 5 deletions(-) + init/property_service.cpp | 32 +++++++++++++++++++++++++++++--- + 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp -index 3333eedb1..5bead058c 100644 +index d13f3429c..b60d8d143 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp -@@ -269,6 +269,13 @@ uint32_t InitPropertySet(const std::string& name, const std::string& value) { +@@ -284,6 +284,12 @@ uint32_t InitPropertySet(const std::string& name, const std::string& value) { + return result; } - +// Legacy definition +typedef struct prop_msg_s { + unsigned cmd; + char name[PROP_NAME_MAX]; + char value[PROP_VALUE_MAX]; +} prop_msg_t; -+ + class SocketConnection { public: - SocketConnection(int socket, const ucred& cred) : socket_(socket), cred_(cred) {} -@@ -315,6 +322,17 @@ class SocketConnection { +@@ -331,6 +337,17 @@ class SocketConnection { return result == sizeof(value); } @@ -44,7 +43,7 @@ index 3333eedb1..5bead058c 100644 int socket() { return socket_; } const ucred& cred() { return cred_; } -@@ -559,14 +577,21 @@ static void handle_property_set_fd() { +@@ -594,14 +611,21 @@ static void handle_property_set_fd() { } case PROP_MSG_GETPROP: { int ret; @@ -55,8 +54,8 @@ index 3333eedb1..5bead058c 100644 + /* Need to receive both since libhybris sends prop_msg_t type package. */ + if (!socket.RecvChars(prop_name, PROP_NAME_MAX, &timeout_ms) || + !socket.RecvChars(prop_value, PROP_VALUE_MAX, &timeout_ms)) { -+ PLOG(ERROR) << "sys_prop(PROP_MSG_GETPROP): error while reading name from the socket"; -+ return; ++ PLOG(ERROR) << "sys_prop(PROP_MSG_GETPROP): error while reading name from the socket"; ++ return; + } + prop_name[PROP_NAME_MAX-1] = 0; @@ -69,24 +68,22 @@ index 3333eedb1..5bead058c 100644 return; } -@@ -577,7 +602,7 @@ static void handle_property_set_fd() { - } +@@ -613,6 +637,7 @@ static void handle_property_set_fd() { /* Send the property value back */ -- //TEMP_FAILURE_RETRY(send(s, &msg, sizeof(msg), 0)); + //TEMP_FAILURE_RETRY(send(s, &msg, sizeof(msg), 0)); + socket.SendLegacyPropMsg(prop_name, prop_value); break; } case PROP_MSG_LISTPROP: { -@@ -587,7 +612,7 @@ static void handle_property_set_fd() { - for(n = 0; (pi = __system_property_find_nth(n)); n++) { +@@ -622,6 +647,7 @@ static void handle_property_set_fd() { prop_name[0] = prop_value[0] = 0; __system_property_read(pi, prop_name, prop_value); -- //TEMP_FAILURE_RETRY(send(s, &msg, sizeof(msg), 0)); + //TEMP_FAILURE_RETRY(send(s, &msg, sizeof(msg), 0)); + socket.SendLegacyPropMsg(prop_name, prop_value); } break; } -- -2.17.1 +2.23.0 diff --git a/system/core/0024-hybris-more-SELinux-disablement.patch b/system/core/0024-hybris-more-SELinux-disablement.patch index 288b59d..c5cb7cd 100644 --- a/system/core/0024-hybris-more-SELinux-disablement.patch +++ b/system/core/0024-hybris-more-SELinux-disablement.patch @@ -1,20 +1,20 @@ -From 1ce5df555b3ba8f7995e1907d3616e7491d704a8 Mon Sep 17 00:00:00 2001 +From d809ec4dad4f78c4d916641192cdf4fbbb1d096f Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Wed, 18 Apr 2018 18:49:02 +0200 -Subject: [PATCH 24/39] (hybris) more SELinux disablement +Subject: [PATCH 24/40] (hybris) more SELinux disablement Change-Id: Ic1bc474e993f2b66ab9114e88d7ec4f718a99d5c Signed-off-by: Simonas Leleiva --- - init/init.cpp | 3 +++ - init/log.cpp | 3 +++ - 2 files changed, 6 insertions(+) + init/init.cpp | 3 +++ + init/selinux.cpp | 4 ++-- + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/init/init.cpp b/init/init.cpp -index 8dc013d3e..e397c4c58 100644 +index 74e1c3855..e90365a3a 100644 --- a/init/init.cpp +++ b/init/init.cpp -@@ -669,7 +669,10 @@ int main(int argc, char** argv) { +@@ -653,7 +653,10 @@ int SecondStageMain(int argc, char** argv) { // Make the time that init started available for bootstat to log. property_set("ro.boottime.init", getenv("INIT_STARTED_AT")); @@ -25,27 +25,28 @@ index 8dc013d3e..e397c4c58 100644 // Set libavb version for Framework-only OTA match in Treble build. const char* avb_version = getenv("INIT_AVB_VERSION"); -diff --git a/init/log.cpp b/init/log.cpp -index 6198fc25f..0c7c7b50d 100644 ---- a/init/log.cpp -+++ b/init/log.cpp -@@ -54,6 +54,8 @@ static void InitAborter(const char* abort_message) { +diff --git a/init/selinux.cpp b/init/selinux.cpp +index a47baebfe..2fc027ba2 100644 +--- a/init/selinux.cpp ++++ b/init/selinux.cpp +@@ -311,7 +311,7 @@ bool LoadSplitPolicy() { + } + } + // No suitable precompiled policy could be loaded +- ++/* + LOG(INFO) << "Compiling SELinux policy"; - void InitKernelLogging(char* argv[]) { - // Make stdin/stdout/stderr all point to /dev/null. -+ // Disable SELinux -+ /* - int fd = open("/sys/fs/selinux/null", O_RDWR); - if (fd == -1) { - int saved_errno = errno; -@@ -65,6 +67,7 @@ void InitKernelLogging(char* argv[]) { - dup2(fd, 1); - dup2(fd, 2); - if (fd > 2) close(fd); -+ */ - - android::base::InitLogging(argv, &android::base::KernelLogger, InitAborter); + // We store the output of the compilation on /dev because this is the most convenient tmpfs +@@ -403,7 +403,7 @@ bool LoadSplitPolicy() { + LOG(ERROR) << "Failed to load SELinux policy from " << compiled_sepolicy; + return false; + } +- ++*/ + return true; } + -- -2.17.1 +2.23.0 diff --git a/system/core/0025-hybris-don-t-try-to-mount-since-mer-handles-this.patch b/system/core/0025-hybris-don-t-try-to-mount-since-mer-handles-this.patch index 9af121a..a909c5a 100644 --- a/system/core/0025-hybris-don-t-try-to-mount-since-mer-handles-this.patch +++ b/system/core/0025-hybris-don-t-try-to-mount-since-mer-handles-this.patch @@ -1,18 +1,18 @@ -From 2b24443b29ef5118a4f919f6d4f9dee4aeaebfa7 Mon Sep 17 00:00:00 2001 +From c5a87a9c9600b792369a774709417ab6aa406fdd Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Mon, 4 Jun 2018 10:00:13 +0200 -Subject: [PATCH 25/39] (hybris) don't try to mount since mer handles this +Subject: [PATCH 25/40] (hybris) don't try to mount since mer handles this Change-Id: I305ac649fd199ef11a8d88d350f1fc06171bc0ba --- - init/init_first_stage.cpp | 3 +++ + init/first_stage_mount.cpp | 3 +++ 1 file changed, 3 insertions(+) -diff --git a/init/init_first_stage.cpp b/init/init_first_stage.cpp -index 033ce419a..5c9aa9306 100644 ---- a/init/init_first_stage.cpp -+++ b/init/init_first_stage.cpp -@@ -477,6 +477,7 @@ bool FirstStageMountVBootV2::InitAvbHandle() { +diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp +index 3e76556ff..e522f63a8 100644 +--- a/init/first_stage_mount.cpp ++++ b/init/first_stage_mount.cpp +@@ -841,6 +841,7 @@ bool FirstStageMountVBootV2::InitAvbHandle() { // ---------------- // Mounts partitions specified by fstab in device tree. bool DoFirstStageMount() { @@ -20,7 +20,7 @@ index 033ce419a..5c9aa9306 100644 // Skips first stage mount if we're in recovery mode. if (IsRecoveryMode()) { LOG(INFO) << "First stage mount skipped (recovery mode)"; -@@ -495,6 +496,8 @@ bool DoFirstStageMount() { +@@ -853,6 +854,8 @@ bool DoFirstStageMount() { return false; } return handle->DoFirstStageMount(); @@ -30,5 +30,5 @@ index 033ce419a..5c9aa9306 100644 void SetInitAvbVersionInRecovery() { -- -2.17.1 +2.23.0 diff --git a/system/core/0026-hybris-avoid-attempting-to-mount-partitions-mer-syst.patch b/system/core/0026-hybris-avoid-attempting-to-mount-partitions-mer-syst.patch index 21f7553..94e7823 100644 --- a/system/core/0026-hybris-avoid-attempting-to-mount-partitions-mer-syst.patch +++ b/system/core/0026-hybris-avoid-attempting-to-mount-partitions-mer-syst.patch @@ -1,7 +1,7 @@ -From 2e777b55382b5d5f4fdac35c6a0cac10c706f98c Mon Sep 17 00:00:00 2001 +From 0671793a09083e01156fa20c8a269aff697da52b Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Wed, 6 Jun 2018 09:28:27 +0200 -Subject: [PATCH 26/39] (hybris) avoid attempting to mount partitions, +Subject: [PATCH 26/40] (hybris) avoid attempting to mount partitions, mer/systemd handles this Even partitions weren't mounted by this previously it still would produce an @@ -9,54 +9,55 @@ error and further boot. Change-Id: Icaea2cd8d145d8205f4a130119aedbd2720c868d --- - init/builtins.cpp | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) + init/builtins.cpp | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/init/builtins.cpp b/init/builtins.cpp -index 8bd92ccdd..8bb7b0f0c 100644 +index 25f324ce5..f98f37ed5 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp -@@ -416,6 +416,7 @@ static void import_late(const std::vector& args, size_t start_index - if (false) DumpState(); +@@ -518,6 +518,7 @@ static Result handle_fstab(const std::string& fstabfile, std::function mount_fstab(const char* fstabfile, int mount_mode) { - return Error() << "fork() failed"; - } +@@ -531,6 +532,7 @@ static Result mount_fstab(const std::string& fstabfile, int mount_mode) { + return ret; + }); } +#endif - /* Queue event based on fs_mgr return code. + /* umount_fstab * -@@ -544,7 +546,7 @@ static Result do_mount_all(const BuiltinArguments& args) { +@@ -632,7 +634,7 @@ static Result do_mount_all(const BuiltinArguments& args) { bool import_rc = true; bool queue_event = true; int mount_mode = MOUNT_MODE_DEFAULT; -- const char* fstabfile = args[1].c_str(); -+ //const char* fstabfile = args[1].c_str(); +- const auto& fstabfile = args[1]; ++ //const auto& fstabfile = args[1]; std::size_t path_arg_end = args.size(); const char* prop_post_fix = "default"; -@@ -564,10 +566,14 @@ static Result do_mount_all(const BuiltinArguments& args) { +@@ -652,10 +654,15 @@ static Result do_mount_all(const BuiltinArguments& args) { std::string prop_name = "ro.boottime.init.mount_all."s + prop_post_fix; android::base::Timer t; + -+/* ++#if 0 auto mount_fstab_return_code = mount_fstab(fstabfile, mount_mode); if (!mount_fstab_return_code) { return Error() << "mount_fstab() failed " << mount_fstab_return_code.error(); } -+*/ ++#endif ++ + auto mount_fstab_return_code = WEXITSTATUS(0); property_set(prop_name, std::to_string(t.duration().count())); if (import_rc) { -@@ -575,6 +581,8 @@ static Result do_mount_all(const BuiltinArguments& args) { +@@ -663,6 +670,8 @@ static Result do_mount_all(const BuiltinArguments& args) { import_late(args.args, 2, path_arg_end); } @@ -66,5 +67,5 @@ index 8bd92ccdd..8bb7b0f0c 100644 /* queue_fs_event will queue event based on mount_fstab return code * and return processed return code*/ -- -2.17.1 +2.23.0 diff --git a/system/core/0027-hybris-load-services-from-droid-hybris-as-early-as-p.patch b/system/core/0027-hybris-load-services-from-droid-hybris-as-early-as-p.patch index a4cc9c6..699afc2 100644 --- a/system/core/0027-hybris-load-services-from-droid-hybris-as-early-as-p.patch +++ b/system/core/0027-hybris-load-services-from-droid-hybris-as-early-as-p.patch @@ -1,7 +1,7 @@ -From 6e89d8c8a8583630ad8743c043686c84ec936f27 Mon Sep 17 00:00:00 2001 +From b4962068222460a076c3a6a1b130a6ce8d10d57d Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Wed, 6 Jun 2018 09:30:01 +0200 -Subject: [PATCH 27/39] (hybris) load services from droid-hybris as early as +Subject: [PATCH 27/40] (hybris) load services from droid-hybris as early as possible This makes sure our service definitions are loaded first and can be used to @@ -14,10 +14,10 @@ Change-Id: I58e86f8b3c65f46c24fc3102a859867bccb6a713 1 file changed, 3 insertions(+) diff --git a/init/init.cpp b/init/init.cpp -index e397c4c58..214c62215 100644 +index e90365a3a..28a2d6661 100644 --- a/init/init.cpp +++ b/init/init.cpp -@@ -117,6 +117,9 @@ static void LoadBootScripts(ActionManager& action_manager, ServiceList& service_ +@@ -133,6 +133,9 @@ static void LoadBootScripts(ActionManager& action_manager, ServiceList& service_ if (!parser.ParseConfig("/usr/libexec/droid-hybris/system/etc/init")) { late_import_paths.emplace_back("/usr/libexec/droid-hybris/system/etc/init"); } @@ -28,5 +28,5 @@ index e397c4c58..214c62215 100644 late_import_paths.emplace_back("/product/etc/init"); } -- -2.17.1 +2.23.0 diff --git a/system/core/0028-hybris-disable-remnants-of-SELinux-which-currently-b.patch b/system/core/0028-hybris-disable-remnants-of-SELinux-which-currently-b.patch index e2c6711..95f3ccc 100644 --- a/system/core/0028-hybris-disable-remnants-of-SELinux-which-currently-b.patch +++ b/system/core/0028-hybris-disable-remnants-of-SELinux-which-currently-b.patch @@ -1,7 +1,7 @@ -From 6fec76342654b725c766601228326d06ea0186ee Mon Sep 17 00:00:00 2001 +From cc43550e4912973cfb2dbebdfb980f80fccc8e0d Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Wed, 6 Jun 2018 09:32:06 +0200 -Subject: [PATCH 28/39] (hybris) disable remnants of SELinux which currently +Subject: [PATCH 28/40] (hybris) disable remnants of SELinux which currently break Change-Id: I252a8399c9853d993fc17d769bfbb2e4c722cfe8 @@ -10,10 +10,10 @@ Change-Id: I252a8399c9853d993fc17d769bfbb2e4c722cfe8 1 file changed, 4 insertions(+) diff --git a/init/util.cpp b/init/util.cpp -index 8eb184da9..e27f4f88e 100644 +index 82dfa05f0..4948772d0 100644 --- a/init/util.cpp +++ b/init/util.cpp -@@ -87,12 +87,14 @@ Result DecodeUid(const std::string& name) { +@@ -83,12 +83,14 @@ Result DecodeUid(const std::string& name) { */ int CreateSocket(const char* name, int type, bool passcred, mode_t perm, uid_t uid, gid_t gid, const char* socketcon) { @@ -28,7 +28,7 @@ index 8eb184da9..e27f4f88e 100644 android::base::unique_fd fd(socket(PF_UNIX, type, 0)); if (fd < 0) { -@@ -100,7 +102,9 @@ int CreateSocket(const char* name, int type, bool passcred, mode_t perm, uid_t u +@@ -96,7 +98,9 @@ int CreateSocket(const char* name, int type, bool passcred, mode_t perm, uid_t u return -1; } @@ -39,5 +39,5 @@ index 8eb184da9..e27f4f88e 100644 struct sockaddr_un addr; memset(&addr, 0 , sizeof(addr)); -- -2.17.1 +2.23.0 diff --git a/system/core/0029-hybris-disable-the-usage-of-libprocessgroup-since-it.patch b/system/core/0029-hybris-disable-the-usage-of-libprocessgroup-since-it.patch index 8d410eb..b3a0d5f 100644 --- a/system/core/0029-hybris-disable-the-usage-of-libprocessgroup-since-it.patch +++ b/system/core/0029-hybris-disable-the-usage-of-libprocessgroup-since-it.patch @@ -1,29 +1,30 @@ -From d20f661f0ad17646fb740224a353848dd689ddc4 Mon Sep 17 00:00:00 2001 +From 6145125c01cb798a1a7cbea40239c71abb54603a Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Wed, 6 Jun 2018 09:33:03 +0200 -Subject: [PATCH 29/39] (hybris) disable the usage of libprocessgroup, since it +Subject: [PATCH 29/40] (hybris) disable the usage of libprocessgroup, since it is incompatible. Change-Id: Ie37ac0dcc5cabbf33de55c148009fdfff3e90c64 --- - init/Android.bp | 2 -- - init/Android.mk | 1 - - init/service.cpp | 15 +++++++++++---- - 3 files changed, 11 insertions(+), 7 deletions(-) + init/Android.bp | 3 --- + init/init.cpp | 2 -- + init/service.cpp | 19 ++++++++++++++++--- + 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/init/Android.bp b/init/Android.bp -index 63c8382a4..3b6f46f53 100644 +index 6be7290e3..0be06b5ad 100644 --- a/init/Android.bp +++ b/init/Android.bp -@@ -79,7 +79,6 @@ cc_defaults { - "libdl", - "libsparse", - "libz", +@@ -84,8 +84,6 @@ cc_defaults { + "liblog", + "liblogwrap", + "liblp", - "libprocessgroup", - "libavb", - "libkeyutils", - "libprotobuf-cpp-lite", -@@ -221,7 +220,6 @@ cc_binary { +- "libprocessgroup_setup", + "libselinux", + "libutils", + ], +@@ -239,7 +237,6 @@ cc_binary { shared_libs: [ "libprotobuf-cpp-lite", "libhidl-gen-utils", @@ -31,23 +32,24 @@ index 63c8382a4..3b6f46f53 100644 "liblog", "libcutils", ], -diff --git a/init/Android.mk b/init/Android.mk -index c4a6a50e5..d6fc5b5b9 100644 ---- a/init/Android.mk -+++ b/init/Android.mk -@@ -71,7 +71,6 @@ LOCAL_STATIC_LIBRARIES := \ - libdl \ - libsparse \ - libz \ -- libprocessgroup \ - libavb \ - libkeyutils \ - libprotobuf-cpp-lite \ +diff --git a/init/init.cpp b/init/init.cpp +index 28a2d6661..8ff468ea9 100644 +--- a/init/init.cpp ++++ b/init/init.cpp +@@ -43,8 +43,6 @@ + #include + #include + #include +-#include +-#include + #include + + #ifndef RECOVERY diff --git a/init/service.cpp b/init/service.cpp -index 9c294af15..c2d8a383a 100644 +index c17afb246..8f8f54230 100644 --- a/init/service.cpp +++ b/init/service.cpp -@@ -36,7 +36,6 @@ +@@ -38,7 +38,6 @@ #include #include #include @@ -55,7 +57,7 @@ index 9c294af15..c2d8a383a 100644 #include #include -@@ -263,15 +262,21 @@ void Service::KillProcessGroup(int signal) { +@@ -272,7 +271,13 @@ void Service::KillProcessGroup(int signal) { // These functions handle their own logging, so no additional logging is needed. if (!process_cgroup_empty_) { LOG(INFO) << "Sending signal " << signal << " to service '" << name_ << "' (pid " << pid_ @@ -64,38 +66,59 @@ index 9c294af15..c2d8a383a 100644 + + kill(pid_, signal); + -+ // hybris: TODO? ++// hybris: TODO? +#if DISABLED_FOR_HYBRIS_SUPPORT ++ int r; if (signal == SIGTERM) { r = killProcessGroupOnce(uid_, pid_, signal); - } else { - r = killProcessGroup(uid_, pid_, signal); +@@ -281,6 +286,8 @@ void Service::KillProcessGroup(int signal) { } -- -- if (r == 0) process_cgroup_empty_ = true; -+ if (r == 0) + + if (r == 0) process_cgroup_empty_ = true; +#endif + process_cgroup_empty_ = true; } } -@@ -954,6 +959,7 @@ Result Service::Start() { +@@ -1012,6 +1019,7 @@ Result Service::Start() { + std::for_each(descriptors_.begin(), descriptors_.end(), + std::bind(&DescriptorInfo::CreateAndPublish, std::placeholders::_1, scon)); + ++#if DISABLED_FOR_HYBRIS_SUPPORT + // See if there were "writepid" instructions to write to files under cpuset path. + std::string cpuset_path; + if (CgroupGetControllerPath("cpuset", &cpuset_path)) { +@@ -1069,6 +1077,7 @@ Result Service::Start() { + PLOG(ERROR) << "cannot execve('" << args_[0] << "')"; + } + ++#endif + _exit(127); + } + +@@ -1091,8 +1100,11 @@ Result Service::Start() { start_order_ = next_start_order_++; process_cgroup_empty_ = false; +#if DISABLED_FOR_HYBRIS_SUPPORT - errno = -createProcessGroup(uid_, pid_); + bool use_memcg = swappiness_ != -1 || soft_limit_in_bytes_ != -1 || limit_in_bytes_ != -1 || + limit_percent_ != -1 || !limit_property_.empty(); ++ ++ + errno = -createProcessGroup(uid_, pid_, use_memcg); if (errno != 0) { PLOG(ERROR) << "createProcessGroup(" << uid_ << ", " << pid_ << ") failed for service '" -@@ -977,6 +983,7 @@ Result Service::Start() { +@@ -1137,7 +1149,8 @@ Result Service::Start() { } } } +- +#endif - ++ NotifyStateChange("running"); return Success(); + } -- -2.17.1 +2.23.0 diff --git a/system/core/0030-hybris-disable-vendor-symlink.patch b/system/core/0030-hybris-disable-vendor-symlink.patch index 6073e8f..d545cec 100644 --- a/system/core/0030-hybris-disable-vendor-symlink.patch +++ b/system/core/0030-hybris-disable-vendor-symlink.patch @@ -1,7 +1,7 @@ -From 1ad8264c607093292b1a370e3dca4319d3edbb1e Mon Sep 17 00:00:00 2001 +From d9b76fd06ab672735202a270bfd9e770a781bb53 Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Thu, 7 Jun 2018 15:29:53 +0000 -Subject: [PATCH 30/39] (hybris) disable vendor symlink +Subject: [PATCH 30/40] (hybris) disable vendor symlink Change-Id: I26a32268e2f3af7ab0550397900f7a3ef0edfae5 --- @@ -9,10 +9,10 @@ Change-Id: I26a32268e2f3af7ab0550397900f7a3ef0edfae5 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 8afcfcc67..d684f6007 100644 +index 78c99eaaf..572b8c309 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -52,7 +52,9 @@ on init +@@ -56,7 +56,9 @@ on init symlink /sys/kernel/debug /d # Link /vendor to /system/vendor for devices without a vendor partition. @@ -22,7 +22,7 @@ index 8afcfcc67..d684f6007 100644 + # symlink /system/vendor /vendor # Create energy-aware scheduler tuning nodes - mkdir /dev/stune + mkdir /dev/stune/foreground -- -2.17.1 +2.23.0 diff --git a/system/core/0031-hybris-ignore-mount-and-mkdir-tmp-commands-entirely.patch b/system/core/0031-hybris-ignore-mount-and-mkdir-tmp-commands-entirely.patch index 9bbb0fb..b5b9207 100644 --- a/system/core/0031-hybris-ignore-mount-and-mkdir-tmp-commands-entirely.patch +++ b/system/core/0031-hybris-ignore-mount-and-mkdir-tmp-commands-entirely.patch @@ -1,7 +1,7 @@ -From 2c6d226202d00f493e5be3c945daaa02ca9be791 Mon Sep 17 00:00:00 2001 +From d169848a583bd6d281e96fca3affa225b7955c2b Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Mon, 27 Aug 2018 11:08:12 +0000 -Subject: [PATCH 31/39] (hybris) ignore "mount" and "mkdir /tmp" commands +Subject: [PATCH 31/40] (hybris) ignore "mount" and "mkdir /tmp" commands entirely. mount is usually removed during build, but if the *.rc files are on @@ -21,10 +21,10 @@ Change-Id: Iba637613c6a927098c947536e11348e269e1bef3 1 file changed, 16 insertions(+) diff --git a/init/builtins.cpp b/init/builtins.cpp -index 8bb7b0f0c..23efc95b0 100644 +index f98f37ed5..e4d5e48f8 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp -@@ -243,6 +243,13 @@ static Result do_insmod(const BuiltinArguments& args) { +@@ -301,6 +301,13 @@ static Result do_interface_stop(const BuiltinArguments& args) { // mkdir [mode] [owner] [group] static Result do_mkdir(const BuiltinArguments& args) { mode_t mode = 0755; @@ -38,7 +38,7 @@ index 8bb7b0f0c..23efc95b0 100644 if (args.size() >= 3) { mode = std::strtoul(args[2].c_str(), 0, 8); } -@@ -295,10 +302,13 @@ static Result do_mkdir(const BuiltinArguments& args) { +@@ -353,10 +360,13 @@ static Result do_mkdir(const BuiltinArguments& args) { /* umount */ static Result do_umount(const BuiltinArguments& args) { @@ -52,7 +52,7 @@ index 8bb7b0f0c..23efc95b0 100644 } static struct { -@@ -327,6 +337,11 @@ static struct { +@@ -385,6 +395,11 @@ static struct { /* mount */ static Result do_mount(const BuiltinArguments& args) { @@ -64,7 +64,7 @@ index 8bb7b0f0c..23efc95b0 100644 const char* options = nullptr; unsigned flags = 0; bool wait = false; -@@ -389,6 +404,7 @@ static Result do_mount(const BuiltinArguments& args) { +@@ -447,6 +462,7 @@ static Result do_mount(const BuiltinArguments& args) { } return Success(); @@ -73,5 +73,5 @@ index 8bb7b0f0c..23efc95b0 100644 /* Imports .rc files from the specified paths. Default ones are applied if none is given. -- -2.17.1 +2.23.0 diff --git a/system/core/0032-hybris-Fix-actdead-charging-animation.-MER-1949.patch b/system/core/0032-hybris-Fix-actdead-charging-animation.-MER-1949.patch index d37717e..14d8dc3 100644 --- a/system/core/0032-hybris-Fix-actdead-charging-animation.-MER-1949.patch +++ b/system/core/0032-hybris-Fix-actdead-charging-animation.-MER-1949.patch @@ -1,25 +1,25 @@ -From 80c4085b93c882819850fe06c6d9722cb3fef48a Mon Sep 17 00:00:00 2001 +From 1045d181b582bdfe1654a9e0b88f9937afeccd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Thu, 30 Aug 2018 19:54:16 +0300 -Subject: [PATCH 32/39] (hybris) Fix actdead charging animation. MER#1949 +Subject: [PATCH 32/40] (hybris) Fix actdead charging animation. MER#1949 --- rootdir/init.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index d684f6007..8556f9acd 100644 +index 572b8c309..235d5deea 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -700,7 +700,7 @@ on property:droid.late_start=trigger_late_start +@@ -776,7 +776,7 @@ on property:droid.late_start=trigger_late_start class_start late_start on charger - class_start charger + trigger late-init - on property:vold.decrypt=trigger_reset_main - class_reset main + on property:vold.decrypt=trigger_load_persist_props + load_persist_props -- -2.17.1 +2.23.0 diff --git a/system/core/0033-hybris-system-core-Disable-usb-config.patch b/system/core/0033-hybris-system-core-Disable-usb-config.patch index c6170f2..0c83508 100644 --- a/system/core/0033-hybris-system-core-Disable-usb-config.patch +++ b/system/core/0033-hybris-system-core-Disable-usb-config.patch @@ -1,25 +1,26 @@ -From e9ff4372646599d677d9fd0f127fc5047880d4f2 Mon Sep 17 00:00:00 2001 +From db01ff150d9109bb408b55c0b1f7ee5af4dc39cc Mon Sep 17 00:00:00 2001 From: Matti Kosola Date: Tue, 21 Feb 2017 13:13:26 +0100 -Subject: [PATCH 33/39] (hybris)[system/core] Disable usb config. +Subject: [PATCH 33/40] (hybris)[system/core] Disable usb config. Signed-off-by: Matti Kosola --- - rootdir/init.rc | 1 - - 1 file changed, 1 deletion(-) + rootdir/init.rc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 8556f9acd..0acebed78 100644 +index 235d5deea..b241ba33b 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -14,7 +14,6 @@ import /init.environ.rc +@@ -15,7 +15,7 @@ import /init.environ.rc #import /init.usb.rc import /init.${ro.hardware}.rc import /vendor/etc/init/hw/init.${ro.hardware}.rc -import /init.usb.configfs.rc ++#import /init.usb.configfs.rc import /init.${ro.zygote}.rc - on early-init + # Cgroups are mounted right before early-init using list from /etc/cgroups.json -- -2.17.1 +2.23.0 diff --git a/system/core/0034-hybris-Remove-sbin-from-droid-PATH.patch b/system/core/0034-hybris-Remove-sbin-from-droid-PATH.patch index fdcd489..a533898 100644 --- a/system/core/0034-hybris-Remove-sbin-from-droid-PATH.patch +++ b/system/core/0034-hybris-Remove-sbin-from-droid-PATH.patch @@ -1,25 +1,24 @@ -From f8a08335fe5d042424a848f562066f084257c107 Mon Sep 17 00:00:00 2001 +From 92d86677baf15c7cd45f1440097ffed3d5238afc Mon Sep 17 00:00:00 2001 From: Jussi Laakkonen Date: Wed, 31 Jan 2018 17:12:14 +0200 -Subject: [PATCH 34/39] (hybris) Remove /sbin from droid PATH. +Subject: [PATCH 34/40] (hybris) Remove /sbin from droid PATH. --- rootdir/init.environ.rc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/init.environ.rc.in b/rootdir/init.environ.rc.in -index 516dc82f6..90c2b64d6 100644 +index 73fbaa413..8f95df9c6 100644 --- a/rootdir/init.environ.rc.in +++ b/rootdir/init.environ.rc.in -@@ -1,7 +1,7 @@ +@@ -1,6 +1,6 @@ # set up the global environment - on init - + on early-init - export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin + export PATH /vendor/bin:/system/sbin:/system/bin:/system/xbin - # This is not 64-bit safe -stskeeps - # Hopefully now it is - ghosalmartin # this breaks mixed 32/64-bit devices -mal + # for 32-bit devices with android kernel logger there is now a file called init.extraenv.armeabi-v7a.rc - krnlyng + # export LD_LIBRARY_PATH /usr/libexec/droid-hybris/lib64-dev-alog:/vendor/lib64:/system/lib64:/usr/libexec/droid-hybris/lib-dev-alog:/vendor/lib:/system/lib -- -2.17.1 +2.23.0 diff --git a/system/core/0035-hybris-Fix-return-value-type-of-mount-command.patch b/system/core/0035-hybris-Fix-return-value-type-of-mount-command.patch index 48b8ab7..5f98ef5 100644 --- a/system/core/0035-hybris-Fix-return-value-type-of-mount-command.patch +++ b/system/core/0035-hybris-Fix-return-value-type-of-mount-command.patch @@ -1,7 +1,7 @@ -From eb37a14cdac5c6d8bc42ace39dc6e6273af99360 Mon Sep 17 00:00:00 2001 +From 8a98d93214bbde8f350780b5c0fbd41f0160a30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Sun, 18 Nov 2018 18:51:22 +0200 -Subject: [PATCH 35/39] (hybris) Fix return value type of mount command. +Subject: [PATCH 35/40] (hybris) Fix return value type of mount command. Change-Id: Ib759e1be92d110863e43f13f7317372c6182a02d --- @@ -9,18 +9,18 @@ Change-Id: Ib759e1be92d110863e43f13f7317372c6182a02d 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/builtins.cpp b/init/builtins.cpp -index 23efc95b0..4e2bce361 100644 +index e4d5e48f8..c5b5d6d0f 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp -@@ -589,7 +589,7 @@ static Result do_mount_all(const BuiltinArguments& args) { - return Error() << "mount_fstab() failed " << mount_fstab_return_code.error(); +@@ -678,7 +678,7 @@ static Result do_mount_all(const BuiltinArguments& args) { } - */ + #endif + - auto mount_fstab_return_code = WEXITSTATUS(0); + Result mount_fstab_return_code = WEXITSTATUS(0); property_set(prop_name, std::to_string(t.duration().count())); if (import_rc) { -- -2.17.1 +2.23.0 diff --git a/system/core/0036-hybris-disable-some-more-selinux-functionality.patch b/system/core/0036-hybris-disable-some-more-selinux-functionality.patch index b2b6f40..1b22194 100644 --- a/system/core/0036-hybris-disable-some-more-selinux-functionality.patch +++ b/system/core/0036-hybris-disable-some-more-selinux-functionality.patch @@ -1,7 +1,7 @@ -From d7bfc109f9a23d89e476011c63bde3fe50682d72 Mon Sep 17 00:00:00 2001 +From cbefe01dd0c205002462256ecc33d6a54efdbce7 Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Thu, 28 Mar 2019 12:46:12 -0400 -Subject: [PATCH 36/39] (hybris) disable some more selinux functionality. +Subject: [PATCH 36/40] (hybris) disable some more selinux functionality. Change-Id: Ie63eb13b73d626668b32041fec4400cf2edd2fe5 --- @@ -11,10 +11,10 @@ Change-Id: Ie63eb13b73d626668b32041fec4400cf2edd2fe5 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp -index 5bead058c..f0d345326 100644 +index b60d8d143..620507789 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp -@@ -338,11 +338,14 @@ class SocketConnection { +@@ -353,11 +353,14 @@ class SocketConnection { const ucred& cred() { return cred_; } std::string source_context() const { @@ -30,10 +30,10 @@ index 5bead058c..f0d345326 100644 private: diff --git a/init/subcontext.cpp b/init/subcontext.cpp -index fdb46415d..5fbe8fc40 100644 +index 092c51ceb..f0ea236d2 100644 --- a/init/subcontext.cpp +++ b/init/subcontext.cpp -@@ -243,11 +243,11 @@ void Subcontext::Fork() { +@@ -249,11 +249,11 @@ void Subcontext::Fork() { if (child_fd < 0) { PLOG(FATAL) << "Could not dup child_fd"; } @@ -48,10 +48,10 @@ index fdb46415d..5fbe8fc40 100644 auto child_fd_string = std::to_string(child_fd); const char* args[] = {init_path.c_str(), "subcontext", context_.c_str(), diff --git a/init/util.cpp b/init/util.cpp -index e27f4f88e..a5c95df5b 100644 +index 4948772d0..c225d0643 100644 --- a/init/util.cpp +++ b/init/util.cpp -@@ -117,10 +117,12 @@ int CreateSocket(const char* name, int type, bool passcred, mode_t perm, uid_t u +@@ -113,10 +113,12 @@ int CreateSocket(const char* name, int type, bool passcred, mode_t perm, uid_t u return -1; } @@ -64,7 +64,7 @@ index e27f4f88e..a5c95df5b 100644 if (passcred) { int on = 1; -@@ -133,9 +135,11 @@ int CreateSocket(const char* name, int type, bool passcred, mode_t perm, uid_t u +@@ -129,9 +131,11 @@ int CreateSocket(const char* name, int type, bool passcred, mode_t perm, uid_t u int ret = bind(fd, (struct sockaddr *) &addr, sizeof (addr)); int savederrno = errno; @@ -77,5 +77,5 @@ index e27f4f88e..a5c95df5b 100644 if (ret) { errno = savederrno; -- -2.17.1 +2.23.0 diff --git a/system/core/0037-hybris-Disable-mnt-tmpfs-creation.patch b/system/core/0037-hybris-Disable-mnt-tmpfs-creation.patch index 424ff1c..d957785 100644 --- a/system/core/0037-hybris-Disable-mnt-tmpfs-creation.patch +++ b/system/core/0037-hybris-Disable-mnt-tmpfs-creation.patch @@ -1,28 +1,28 @@ -From b7333f2978cb4031d4366da49413bd347dcda922 Mon Sep 17 00:00:00 2001 +From 0feaaaf0e71e35a94faf3ab76707d52e0cf8dbfe Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Mon, 3 Jun 2019 13:46:44 +0200 -Subject: [PATCH 37/39] (hybris) Disable /mnt tmpfs creation +Subject: [PATCH 37/40] (hybris) Disable /mnt tmpfs creation Change-Id: I7c4fb119475adc345104f6ac5a68b578b6b2d433 --- - init/init.cpp | 4 ++-- + init/first_stage_init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -diff --git a/init/init.cpp b/init/init.cpp -index 214c62215..7fe36d504 100644 ---- a/init/init.cpp -+++ b/init/init.cpp -@@ -601,8 +601,8 @@ int main(int argc, char** argv) { - - // Mount staging areas for devices managed by vold - // See storage config details at http://source.android.com/devices/storage/ -- mount("tmpfs", "/mnt", "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, -- "mode=0755,uid=0,gid=1000"); -+ //mount("tmpfs", "/mnt", "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, -+ // "mode=0755,uid=0,gid=1000"); - // /mnt/vendor is used to mount vendor-specific partitions that can not be - // part of the vendor partition, e.g. because they are mounted read-write. - mkdir("/mnt/vendor", 0755); +diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp +index 998374a84..0e398b453 100644 +--- a/init/first_stage_init.cpp ++++ b/init/first_stage_init.cpp +@@ -149,8 +149,8 @@ int FirstStageMain(int argc, char** argv) { + // should be done in rc files. + // Mount staging areas for devices managed by vold + // See storage config details at http://source.android.com/devices/storage/ +- CHECKCALL(mount("tmpfs", "/mnt", "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, +- "mode=0755,uid=0,gid=1000")); ++ //CHECKCALL(mount("tmpfs", "/mnt", "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, ++ // "mode=0755,uid=0,gid=1000")); + // /mnt/vendor is used to mount vendor-specific partitions that can not be + // part of the vendor partition, e.g. because they are mounted read-write. + CHECKCALL(mkdir("/mnt/vendor", 0755)); -- -2.17.1 +2.23.0 diff --git a/system/core/0038-hybris-Disable-init_user0-which-is-not-needed-on-Mer.patch b/system/core/0038-hybris-Disable-init_user0-which-is-not-needed-on-Mer.patch index 5890752..b761e99 100644 --- a/system/core/0038-hybris-Disable-init_user0-which-is-not-needed-on-Mer.patch +++ b/system/core/0038-hybris-Disable-init_user0-which-is-not-needed-on-Mer.patch @@ -1,26 +1,25 @@ -From 75df6c383da1e1fc3875a2705aa51d58aa614b8a Mon Sep 17 00:00:00 2001 +From c6aa11add72792efa0dfe989703b27761ed650b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Mon, 10 Dec 2018 12:11:06 +0200 -Subject: [PATCH 38/39] (hybris) Disable init_user0 which is not needed on Mer. +Subject: [PATCH 38/40] (hybris) Disable init_user0 which is not needed on Mer. --- - rootdir/init.rc | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) + rootdir/init.rc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootdir/init.rc b/rootdir/init.rc -index 0acebed78..085ff1c8e 100644 +index b241ba33b..1236c6919 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc -@@ -546,7 +546,8 @@ on post-fs-data - mkdir /data/cache/backup_stage 0700 system system - mkdir /data/cache/backup 0700 system system +@@ -605,7 +605,7 @@ on post-fs-data + wait_for_prop apexd.status ready + parse_apex_configs - init_user0 -+ # Requires vold which is is not needed in Mer + #init_user0 # Set SELinux security contexts on upgrade or policy update. restorecon --recursive --skip-ce /data -- -2.17.1 +2.23.0 diff --git a/system/core/0039-hybris-Disable-SELinux-init.patch b/system/core/0039-hybris-Disable-SELinux-init.patch index 8a12ed3..37bfceb 100644 --- a/system/core/0039-hybris-Disable-SELinux-init.patch +++ b/system/core/0039-hybris-Disable-SELinux-init.patch @@ -1,7 +1,10 @@ -From 1a59756b52362c0dfc9eee2e8cf1728726d1f2f9 Mon Sep 17 00:00:00 2001 +From 9e404a42d8916112cdcc4f503b2004b09d424257 Mon Sep 17 00:00:00 2001 From: Matti Kosola Date: Wed, 4 Sep 2019 12:07:34 +0200 -Subject: [PATCH 39/39] (hybris) Disable SELinux init. +Subject: [PATCH 39/40] (hybris) Disable SELinux init. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit Sailfish OS SELinux initialization is done by systemd. Conflicting init has been resolved by disabling SELinux @@ -9,62 +12,165 @@ initialization from droid hal init. Change-Id: I8a2a729671d224c4cc266a8219bee357611ded51 Signed-off-by: Matti Kosola +Signed-off-by: Björn Bidar --- - init/init.cpp | 8 ++++++++ - 1 file changed, 8 insertions(+) + init/first_stage_init.cpp | 4 ++++ + init/init.cpp | 7 +++++++ + init/selinux.cpp | 15 +++++++++++++++ + 3 files changed, 26 insertions(+) +diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp +index 0e398b453..805bad2e5 100644 +--- a/init/first_stage_init.cpp ++++ b/init/first_stage_init.cpp +@@ -47,6 +47,8 @@ using namespace std::literals; + + namespace fs = std::filesystem; + ++#define SYSTEMD_SELINUX ++ + namespace android { + namespace init { + +@@ -129,7 +131,9 @@ int FirstStageMain(int argc, char** argv) { + gid_t groups[] = {AID_READPROC}; + CHECKCALL(setgroups(arraysize(groups), groups)); + //CHECKCALL(mount("sysfs", "/sys", "sysfs", 0, NULL)); ++#ifndef SYSTEMD_SELINUX + CHECKCALL(mount("selinuxfs", "/sys/fs/selinux", "selinuxfs", 0, NULL)); ++#endif + + CHECKCALL(mknod("/dev/kmsg", S_IFCHR | 0600, makedev(1, 11))); + diff --git a/init/init.cpp b/init/init.cpp -index 7fe36d504..ce2100c57 100644 +index 8ff468ea9..f2936d883 100644 --- a/init/init.cpp +++ b/init/init.cpp -@@ -70,6 +70,8 @@ using android::base::StringPrintf; - using android::base::Timer; +@@ -76,6 +76,8 @@ using android::base::Timer; using android::base::Trim; + using android::fs_mgr::AvbHandle; +#define SYSTEMD_SELINUX + namespace android { namespace init { -@@ -588,7 +590,9 @@ int main(int argc, char** argv) { - gid_t groups[] = { AID_READPROC }; - setgroups(arraysize(groups), groups); - //mount("sysfs", "/sys", "sysfs", 0, NULL); +@@ -358,11 +360,14 @@ static Result console_init_action(const BuiltinArguments& args) { + static Result SetupCgroupsAction(const BuiltinArguments&) { + // Have to create using make_dir function + // for appropriate sepolicy to be set for it ++ ++#if DISABLED_FOR_HYBRIS_SUPPORT + make_dir(android::base::Dirname(CGROUPS_RC_PATH), 0711); + if (!CgroupSetup()) { + return ErrnoError() << "Failed to setup cgroups"; + } + ++#endif + return Success(); + } + +@@ -675,10 +680,12 @@ int SecondStageMain(int argc, char** argv) { + unsetenv("INIT_AVB_VERSION"); + unsetenv("INIT_FORCE_DEBUGGABLE"); + +#ifndef SYSTEMD_SELINUX - mount("selinuxfs", "/sys/fs/selinux", "selinuxfs", 0, NULL); + // Now set up SELinux for second stage. + SelinuxSetupKernelLogging(); + SelabelInitialize(); + SelinuxRestoreContext(); +#endif - mknod("/dev/kmsg", S_IFCHR | 0600, makedev(1, 11)); + Epoll epoll; + if (auto result = epoll.Open(); !result) { +diff --git a/init/selinux.cpp b/init/selinux.cpp +index 2fc027ba2..ce506dd5e 100644 +--- a/init/selinux.cpp ++++ b/init/selinux.cpp +@@ -74,6 +74,8 @@ using android::base::Timer; + using android::base::unique_fd; + using android::fs_mgr::AvbHandle; -@@ -622,6 +626,7 @@ int main(int argc, char** argv) { - // Enable seccomp if global boot option was passed (otherwise it is enabled in zygote). - global_seccomp(); ++#define SYSTEMD_SELINUX ++ + namespace android { + namespace init { -+#ifndef SYSTEMD_SELINUX - // Set up SELinux, loading the SELinux policy. - SelinuxSetupKernelLogging(); - SelinuxInitialize(); -@@ -631,6 +636,7 @@ int main(int argc, char** argv) { - if (selinux_android_restorecon("/init", 0) == -1) { - PLOG(FATAL) << "restorecon failed of /init failed"; - } +@@ -83,6 +85,8 @@ selabel_handle* sehandle = nullptr; + + enum EnforcingStatus { SELINUX_PERMISSIVE, SELINUX_ENFORCING }; + ++#if DISABLED_FOR_HYBRIS_SUPPORT ++ + EnforcingStatus StatusFromCmdline() { + EnforcingStatus status = SELINUX_ENFORCING; + +@@ -193,6 +197,7 @@ bool ForkExecveAndWaitForCompletion(const char* filename, char* const argv[]) { + return false; + } + } +#endif - setenv("INIT_SECOND_STAGE", "true", 1); + bool ReadFirstLine(const char* file, std::string* line) { + line->clear(); +@@ -206,6 +211,8 @@ bool ReadFirstLine(const char* file, std::string* line) { + return true; + } -@@ -687,10 +693,12 @@ int main(int argc, char** argv) { - unsetenv("INIT_SELINUX_TOOK"); - unsetenv("INIT_AVB_VERSION"); ++#if DISABLED_FOR_HYBRIS_SUPPORT ++ + bool FindPrecompiledSplitPolicy(std::string* file) { + file->clear(); + // If there is an odm partition, precompiled_sepolicy will be in +@@ -258,6 +265,8 @@ bool FindPrecompiledSplitPolicy(std::string* file) { + return true; + } + ++#endif ++ + bool GetVendorMappingVersion(std::string* plat_vers) { + if (!ReadFirstLine("/vendor/etc/selinux/plat_sepolicy_vers.txt", plat_vers)) { + PLOG(ERROR) << "Failed to read /vendor/etc/selinux/plat_sepolicy_vers.txt"; +@@ -276,6 +285,8 @@ bool IsSplitPolicyDevice() { + return access(plat_policy_cil_file, R_OK) != -1; + } ++#if DISABLED_FOR_HYBRIS_SUPPORT ++ + bool LoadSplitPolicy() { + // IMPLEMENTATION NOTE: Split policy consists of three CIL files: + // * platform -- policy needed due to logic contained in the system image, +@@ -446,6 +457,7 @@ void SelinuxInitialize() { + // init's first stage can't set properties, so pass the time to the second stage. + setenv("INIT_SELINUX_TOOK", std::to_string(t.duration().count()).c_str(), 1); + } ++#endif + + } // namespace + +@@ -520,12 +532,14 @@ int SelinuxGetVendorAndroidVersion() { + + // This function initializes SELinux then execs init to run in the init SELinux context. + int SetupSelinux(char** argv) { +#ifndef SYSTEMD_SELINUX - // Now set up SELinux for second stage. + InitKernelLogging(argv); + + if (REBOOT_BOOTLOADER_ON_PANIC) { + InstallRebootSignalHandlers(); + } + ++ + // Set up SELinux, loading the SELinux policy. SelinuxSetupKernelLogging(); - SelabelInitialize(); - SelinuxRestoreContext(); + SelinuxInitialize(); +@@ -546,6 +560,7 @@ int SetupSelinux(char** argv) { + // panic and never return from this function. + PLOG(FATAL) << "execv(\"" << path << "\") failed"; + +#endif + return 1; + } - epoll_fd = epoll_create1(EPOLL_CLOEXEC); - if (epoll_fd == -1) { -- -2.17.1 +2.23.0 diff --git a/system/core/0040-hybris-Disable-unused-code-that-was-disabled-by-priv.patch b/system/core/0040-hybris-Disable-unused-code-that-was-disabled-by-priv.patch new file mode 100644 index 0000000..9e07c8e --- /dev/null +++ b/system/core/0040-hybris-Disable-unused-code-that-was-disabled-by-priv.patch @@ -0,0 +1,43 @@ +From fc94f8187298d3deaa1e7ad836abe91558840192 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= +Date: Sun, 20 Oct 2019 15:19:55 +0200 +Subject: [PATCH 40/40] (hybris) Disable unused code that was disabled by + privous patches. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change-Id: I2a78d91094495fad7b3cf514dd437d72a0718706 +Signed-off-by: Björn Bidar +--- + init/service.cpp | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/init/service.cpp b/init/service.cpp +index 8f8f54230..30f2508a4 100644 +--- a/init/service.cpp ++++ b/init/service.cpp +@@ -190,6 +190,7 @@ Result Service::EnterNamespaces() const { + return Success(); + } + ++/* + static bool ExpandArgsAndExecv(const std::vector& args, bool sigstop) { + std::vector expanded_args; + std::vector c_strings; +@@ -211,10 +212,12 @@ static bool ExpandArgsAndExecv(const std::vector& args, bool sigsto + return execv(c_strings[0], c_strings.data()) == 0; + } + ++ + static bool IsRuntimeApexReady() { + struct stat buf; + return stat("/apex/com.android.runtime/", &buf) == 0; + } ++*/ + + unsigned long Service::next_start_order_ = 1; + bool Service::is_exec_service_running_ = false; +-- +2.23.0 + From 6b33481a4169500a33cfe6e1b78d565049e06831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Fri, 3 Jul 2020 20:56:37 +0200 Subject: [PATCH 2/2] hybris-patches: rebase on top of android-10.0.0_r37 [hybris-patches] rebase on top of android-10.0.0_r37 --- ...ome-build-errors-to-let-the-systemim.patch | 12 +++++------ ..._tls-and-related-functions-Android-8.patch | 8 +++---- ...pport-for-get-and-list-of-properties.patch | 4 ++-- ...s.h-shifting-TLS-slots-to-avoid-conf.patch | 4 ++-- ...ls-usage-in-locale.cpp-to-avoid-prob.patch | 4 ++-- ...lots-for-x86-Aligns-with-this-libhyb.patch | 4 ++-- ...bris-don-t-fail-because-of-fsetxattr.patch | 4 ++-- ...hybris-Reduce-vendorimage-build-size.patch | 6 +++--- ...imization-might-be-improveable-but-t.patch | 21 +++++++++++-------- ...le-APEX-check-we-don-t-care-about-it.patch | 8 +++---- 10 files changed, 39 insertions(+), 36 deletions(-) diff --git a/art/0001-hybris-Silence-some-build-errors-to-let-the-systemim.patch b/art/0001-hybris-Silence-some-build-errors-to-let-the-systemim.patch index c494307..6ba3380 100644 --- a/art/0001-hybris-Silence-some-build-errors-to-let-the-systemim.patch +++ b/art/0001-hybris-Silence-some-build-errors-to-let-the-systemim.patch @@ -1,6 +1,6 @@ -From 3754ab27492f5bdb443429db9af3fc8205caeed7 Mon Sep 17 00:00:00 2001 +From af58fcbb7a0c501a5cd06ae6c5eaed17204b065c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= -Date: Mon, 21 Oct 2019 07:19:31 +0200 +Date: Fri, 3 Jul 2020 22:15:49 +0200 Subject: [PATCH] (hybris) Silence some build errors to let the systemimage build MIME-Version: 1.0 @@ -11,8 +11,8 @@ Previous changes to bionic and the build system removed things that art depends on. Either remove the parts that create errors or replace them and insert dummy data to allow the building of the systemimage. -Change-Id: I5f12c9dd80886896885b0a84667812d966054114 Signed-off-by: Björn Bidar +Change-Id: Ide41188b6263a22c371ec28786bbc1ef1ee62df7 --- build/Android.gtest.mk | 20 ++++++++++---------- runtime/thread-current-inl.h | 2 +- @@ -77,7 +77,7 @@ index 9241b1f875..904a62ccff 100644 void* thread = pthread_getspecific(Thread::pthread_key_self_); #endif diff --git a/runtime/thread.cc b/runtime/thread.cc -index 70ed7c8038..dcfbb7926d 100644 +index be0e30ad11..dd3d07d920 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -933,7 +933,7 @@ bool Thread::Init(ThreadList* thread_list, JavaVMExt* java_vm, JNIEnvExt* jni_en @@ -89,7 +89,7 @@ index 70ed7c8038..dcfbb7926d 100644 #else CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, this), "attach self"); #endif -@@ -2196,7 +2196,7 @@ void Thread::ThreadExitCallback(void* arg) { +@@ -2199,7 +2199,7 @@ void Thread::ThreadExitCallback(void* arg) { "going to use a pthread_key_create destructor?): " << *self; CHECK(is_started_); #ifdef ART_TARGET_ANDROID @@ -112,5 +112,5 @@ index ed6b2c91e5..06e6f6585b 100644 CHECK_PTHREAD_CALL(pthread_setspecific, (Thread::pthread_key_self_, nullptr), "detach self"); #endif -- -2.23.0 +2.27.0 diff --git a/bionic/0001-hybris-Fix-__get_tls-and-related-functions-Android-8.patch b/bionic/0001-hybris-Fix-__get_tls-and-related-functions-Android-8.patch index 847631b..1e2285b 100644 --- a/bionic/0001-hybris-Fix-__get_tls-and-related-functions-Android-8.patch +++ b/bionic/0001-hybris-Fix-__get_tls-and-related-functions-Android-8.patch @@ -1,4 +1,4 @@ -From fc8a37731d84333173eebf09ec54bcbc86904d3f Mon Sep 17 00:00:00 2001 +From d638f78bbaf290a38680261876fa456bff349fdc Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Thu, 1 Feb 2018 00:57:52 +0000 Subject: [PATCH 1/6] (hybris) Fix __get_tls and related functions (>=Android @@ -51,14 +51,14 @@ index 2c3299f7b..637e3dfa1 100644 void memswap(void* m1, void* m2, size_t n) { char* p = reinterpret_cast(m1); diff --git a/libc/libc.map.txt b/libc/libc.map.txt -index 88192239a..060f28387 100644 +index 88192239a..1bf0e307d 100644 --- a/libc/libc.map.txt +++ b/libc/libc.map.txt @@ -1593,6 +1593,7 @@ LIBC_PRIVATE { __gesf2; # arm __get_thread; # arm x86 mips __get_tls; # arm x86 mips -+ __get_tls_hooks; # hybris ++ __get_tls_hooks; # # arm x86 mips hybris __getdents64; # arm x86 mips __gnu_ldivmod_helper; # arm __gnu_uldivmod_helper; # arm @@ -165,5 +165,5 @@ index 000000000..4a8fa5fc2 +#endif /* __BIONIC_PRIVATE_GET_TLS_INTERNAL_H_ */ + -- -2.23.0 +2.27.0 diff --git a/bionic/0002-hybris-Add-support-for-get-and-list-of-properties.patch b/bionic/0002-hybris-Add-support-for-get-and-list-of-properties.patch index 43f09f4..4668923 100644 --- a/bionic/0002-hybris-Add-support-for-get-and-list-of-properties.patch +++ b/bionic/0002-hybris-Add-support-for-get-and-list-of-properties.patch @@ -1,4 +1,4 @@ -From e710725eb69970ed73c47e2e037908f179a15a57 Mon Sep 17 00:00:00 2001 +From 3c74a5052ea7eb73290fe34de4a8a05a2e0c9f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Sun, 17 Dec 2017 00:16:16 +0200 Subject: [PATCH 2/6] (hybris) Add support for get and list of properties. @@ -22,5 +22,5 @@ index 744a45b71..2f32bc28f 100644 #define PROP_SUCCESS 0 -- -2.23.0 +2.27.0 diff --git a/bionic/0003-hybris-bionic_tls.h-shifting-TLS-slots-to-avoid-conf.patch b/bionic/0003-hybris-bionic_tls.h-shifting-TLS-slots-to-avoid-conf.patch index a10706b..60fb112 100644 --- a/bionic/0003-hybris-bionic_tls.h-shifting-TLS-slots-to-avoid-conf.patch +++ b/bionic/0003-hybris-bionic_tls.h-shifting-TLS-slots-to-avoid-conf.patch @@ -1,4 +1,4 @@ -From 265be0718cd40ec8edd3e014b3a7501174bafbb4 Mon Sep 17 00:00:00 2001 +From 90df3815d26d79b32d6a9cb05f6ded82054744e0 Mon Sep 17 00:00:00 2001 From: Ricardo Salveti de Araujo Date: Thu, 9 Jan 2014 00:57:01 -0200 Subject: [PATCH 3/6] (hybris) bionic_tls.h: shifting TLS slots to avoid @@ -37,5 +37,5 @@ index 92f707aad..40e6a5394 100644 // The maximum slot is fixed by the minimum TLS alignment in Bionic executables. #define MAX_TLS_SLOT 7 -- -2.23.0 +2.27.0 diff --git a/bionic/0004-hybris-disable-tls-usage-in-locale.cpp-to-avoid-prob.patch b/bionic/0004-hybris-disable-tls-usage-in-locale.cpp-to-avoid-prob.patch index d7fc14d..c4e577f 100644 --- a/bionic/0004-hybris-disable-tls-usage-in-locale.cpp-to-avoid-prob.patch +++ b/bionic/0004-hybris-disable-tls-usage-in-locale.cpp-to-avoid-prob.patch @@ -1,4 +1,4 @@ -From 48e009cf11f2041d662ad597b3c73a044188fdc4 Mon Sep 17 00:00:00 2001 +From c2db77fdc026934f0c8198eab45608146dfb28dc Mon Sep 17 00:00:00 2001 From: Simonas Leleiva Date: Wed, 18 Apr 2018 18:37:09 +0200 Subject: [PATCH 4/6] (hybris) disable tls usage in locale.cpp, to avoid @@ -31,5 +31,5 @@ index 8358fb0ab..8def0e164 100644 #if USE_TLS_SLOT #include "bionic/pthread_internal.h" -- -2.23.0 +2.27.0 diff --git a/bionic/0005-hybris-Fix-TLS-slots-for-x86-Aligns-with-this-libhyb.patch b/bionic/0005-hybris-Fix-TLS-slots-for-x86-Aligns-with-this-libhyb.patch index eeefc92..ad73bc4 100644 --- a/bionic/0005-hybris-Fix-TLS-slots-for-x86-Aligns-with-this-libhyb.patch +++ b/bionic/0005-hybris-Fix-TLS-slots-for-x86-Aligns-with-this-libhyb.patch @@ -1,4 +1,4 @@ -From 8e7d6a5468060dd647fec9b52dfb4f19dbdc39ba Mon Sep 17 00:00:00 2001 +From dcdf30cb95462a99f22a6b711dd193888809262d Mon Sep 17 00:00:00 2001 From: Ilya Bizyaev Date: Sat, 20 Jan 2018 17:48:27 +0300 Subject: [PATCH 5/6] (hybris) Fix TLS slots for x86 Aligns with this libhybris @@ -33,5 +33,5 @@ index 40e6a5394..07ded2005 100644 #define TLS_SLOT_BIONIC_TLS 9 #define MAX_TLS_SLOT 9 // update this value when reserving a slot -- -2.23.0 +2.27.0 diff --git a/bionic/0006-hybris-don-t-fail-because-of-fsetxattr.patch b/bionic/0006-hybris-don-t-fail-because-of-fsetxattr.patch index e59dcfc..a8f7000 100644 --- a/bionic/0006-hybris-don-t-fail-because-of-fsetxattr.patch +++ b/bionic/0006-hybris-don-t-fail-because-of-fsetxattr.patch @@ -1,4 +1,4 @@ -From ed1d2fb125692caeddf8dda361350d72ca043bbf Mon Sep 17 00:00:00 2001 +From f6251489321b5e8b23f43a5c568c1a6a37aced92 Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Thu, 28 Mar 2019 13:10:48 -0400 Subject: [PATCH 6/6] (hybris) don't fail because of fsetxattr @@ -22,5 +22,5 @@ index 42bee9f3e..04be16230 100644 } } -- -2.23.0 +2.27.0 diff --git a/build/make/0001-hybris-Reduce-vendorimage-build-size.patch b/build/make/0001-hybris-Reduce-vendorimage-build-size.patch index 93c5695..9de1600 100644 --- a/build/make/0001-hybris-Reduce-vendorimage-build-size.patch +++ b/build/make/0001-hybris-Reduce-vendorimage-build-size.patch @@ -1,4 +1,4 @@ -From e29b091d694c1dc30915455dddcd8d4fdb106b41 Mon Sep 17 00:00:00 2001 +From cba9bc8e5c67b75f2332412c6382e4feef79808e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Fri, 22 Mar 2019 18:36:56 +0200 Subject: [PATCH 1/3] (hybris) Reduce vendorimage build size. @@ -9,7 +9,7 @@ Change-Id: Id025a7d7c81cb19c2881ff6619084b638ce983fb 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/Makefile b/core/Makefile -index 4611fb388..c0cc99793 100644 +index df3a161c1..feb17c37b 100644 --- a/core/Makefile +++ b/core/Makefile @@ -19,6 +19,7 @@ $(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \ @@ -52,5 +52,5 @@ index 4611fb388..c0cc99793 100644 .PHONY: vendorimage-nodeps vnod vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS) $(DEPMOD) -- -2.23.0 +2.27.0 diff --git a/build/make/0002-hybris-build-minimization-might-be-improveable-but-t.patch b/build/make/0002-hybris-build-minimization-might-be-improveable-but-t.patch index 842c4f9..d5df488 100644 --- a/build/make/0002-hybris-build-minimization-might-be-improveable-but-t.patch +++ b/build/make/0002-hybris-build-minimization-might-be-improveable-but-t.patch @@ -1,4 +1,4 @@ -From 0135270cfe3fb8d78f5807ac5afd0b746186a99c Mon Sep 17 00:00:00 2001 +From a81cf1a739d91dd23fe91984b8c170265a14d5df Mon Sep 17 00:00:00 2001 From: Franz-Josef Haider Date: Thu, 7 Jun 2018 15:32:40 +0000 Subject: [PATCH 2/3] (hybris) build minimization (might be improveable, but @@ -558,10 +558,10 @@ index c706cea72..e69de29bb 100644 -endif # LOCAL_DEX_PREOPT -endif # !LOCAL_IS_STATIC_JAVA_LIBRARY diff --git a/core/main.mk b/core/main.mk -index df5c13cc2..db5a177d6 100644 +index a13404a99..86193c909 100644 --- a/core/main.mk +++ b/core/main.mk -@@ -179,8 +179,6 @@ endif +@@ -181,8 +181,6 @@ endif # Bring in standard build system definitions. include $(BUILD_SYSTEM)/definitions.mk @@ -570,7 +570,7 @@ index df5c13cc2..db5a177d6 100644 ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),) $(info ***************************************************************) -@@ -478,6 +476,9 @@ subdir_makefiles_total := $(words int $(subdir_makefiles) post finish) +@@ -489,6 +487,9 @@ subdir_makefiles_total := $(words int $(subdir_makefiles) post finish) $(foreach mk,$(subdir_makefiles),$(info [$(call inc_and_print,subdir_makefiles_inc)/$(subdir_makefiles_total)] including $(mk) ...)$(eval include $(mk))) @@ -672,10 +672,10 @@ index 854e0093c..e69de29bb 100644 - -my_module_arch_supported := diff --git a/core/soong_droiddoc_prebuilt.mk b/core/soong_droiddoc_prebuilt.mk -index bf1f10bd9..e69de29bb 100644 +index c0467df2b..496929963 100644 --- a/core/soong_droiddoc_prebuilt.mk +++ b/core/soong_droiddoc_prebuilt.mk -@@ -1,40 +0,0 @@ +@@ -1,43 +1,3 @@ -# Droiddoc prebuilt coming from Soong. - -ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) @@ -716,6 +716,9 @@ index bf1f10bd9..e69de29bb 100644 -.PHONY: $(LOCAL_MODULE) $(LOCAL_MODULE)-jdiff -$(LOCAL_MODULE) $(LOCAL_MODULE)-jdiff : $(OUT_DOCS)/$(LOCAL_MODULE)-jdiff-docs.zip -endif + + ifdef LOCAL_DROIDDOC_METADATA_ZIP + $(eval $(call copy-one-file,$(LOCAL_DROIDDOC_METADATA_ZIP),$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(LOCAL_MODULE)-metadata.zip)) diff --git a/core/static_java_library.mk b/core/static_java_library.mk index ee759b9d8..e69de29bb 100644 --- a/core/static_java_library.mk @@ -969,10 +972,10 @@ index ee759b9d8..e69de29bb 100644 -all_res_assets := -LOCAL_IS_STATIC_JAVA_LIBRARY := diff --git a/target/product/base_system.mk b/target/product/base_system.mk -index 822d2ead8..9cb6a21ef 100644 +index 2f8a63472..4fede2c5a 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk -@@ -309,9 +309,9 @@ PRODUCT_HOST_PACKAGES += \ +@@ -307,9 +307,9 @@ PRODUCT_HOST_PACKAGES += \ tz_version_host \ tz_version_host_runtime_apex \ @@ -1003,5 +1006,5 @@ index a88ba3c8d..4ab27994b 100644 # Minimal boot classpath. This should be a subset of PRODUCT_BOOT_JARS, and equivalent to # TARGET_CORE_JARS. -- -2.23.0 +2.27.0 diff --git a/build/make/0003-hybris-Disable-APEX-check-we-don-t-care-about-it.patch b/build/make/0003-hybris-Disable-APEX-check-we-don-t-care-about-it.patch index 93b57e5..f1191b0 100644 --- a/build/make/0003-hybris-Disable-APEX-check-we-don-t-care-about-it.patch +++ b/build/make/0003-hybris-Disable-APEX-check-we-don-t-care-about-it.patch @@ -1,4 +1,4 @@ -From ac37739a9491b65bb26517af54c56c7375cc274e Mon Sep 17 00:00:00 2001 +From 3043dd6090c1c0aa822251f258b734b85daac18a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Fri, 18 Oct 2019 11:43:31 +0200 Subject: [PATCH 3/3] (hybris) Disable APEX check, we don't care about it. @@ -9,10 +9,10 @@ Change-Id: I1099755d6ec01f10b70c78ca68af822ccafb2b6f 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/main.mk b/core/main.mk -index db5a177d6..09a8f3f63 100644 +index 86193c909..71d828352 100644 --- a/core/main.mk +++ b/core/main.mk -@@ -1247,7 +1247,7 @@ APEX_MODULE_LIBS += \ +@@ -1259,7 +1259,7 @@ APEX_MODULE_LIBS += \ # An option to disable the check below, for local use since some build targets # still may create these libraries in /system (b/129006418). @@ -22,5 +22,5 @@ index db5a177d6..09a8f3f63 100644 # Bionic should not be in /system, except for the bootstrap instance. APEX_LIBS_ABSENCE_CHECK_EXCLUDE := lib/bootstrap lib64/bootstrap -- -2.23.0 +2.27.0