Compare commits

..

No commits in common. "lineage-21-light" and "lineage-18.1-old" have entirely different histories.

277 changed files with 8780 additions and 17660 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
/patches_treble_personal/vendor_hardware_overlay

View File

@ -0,0 +1,36 @@
From e3c7e720c893a6ecef90b4b950787ed820792581 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 12:54:23 +0200
Subject: [PATCH 1/2] Use vndk_lite ld.config only on same-version vendor
When running Q over P lite, there is currently absolutely no chance the
device boots, because it will be using Q vndk.
Thus using ld.config.28.txt when running Q over P lite gives a little more
chance for the device to boot, than when using vndk_lite ld.config.
Also, once this patch is applied, the required effort to boot
Q over P lite is exclusively in vndk, which is manageable.
Change-Id: I55257cd7c738b1d20582e198e1d5621e1c87a03e
---
linker/linker.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index f24167722..a82d7c430 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3372,7 +3372,10 @@ static std::string get_ld_config_file_apex_path(const char* executable_path) {
}
static std::string get_ld_config_file_vndk_path() {
- if (android::base::GetBoolProperty("ro.vndk.lite", false)) {
+ bool same_version_system_vendor = false;
+ if(std::to_string(__ANDROID_API__) == Config::get_vndk_version_string('.'))
+ same_version_system_vendor = true;
+ if (android::base::GetBoolProperty("ro.vndk.lite", false) && same_version_system_vendor) {
return kLdConfigVndkLiteFilePath;
}
--
2.17.1

View File

@ -0,0 +1,39 @@
From 709393961b2c65d2e9c50fdb5c2db3370811da5c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 26 Oct 2020 23:23:24 +0100
Subject: [PATCH 3/3] Ignore vndk lite when looking for ld.config
Change-Id: I6927ba11dcb8435fab1866985c177a1852488414
---
linker/linker.cpp | 8 --------
1 file changed, 8 deletions(-)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index ae2c00c21..ea504c91e 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -93,7 +93,6 @@ static uint64_t g_module_unload_counter = 0;
static const char* const kLdConfigArchFilePath = "/system/etc/ld.config." ABI_STRING ".txt";
static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt";
-static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt";
static const char* const kLdGeneratedConfigFilePath = "/linkerconfig/ld.config.txt";
@@ -3372,13 +3371,6 @@ static std::string get_ld_config_file_apex_path(const char* executable_path) {
}
static std::string get_ld_config_file_vndk_path() {
- bool same_version_system_vendor = false;
- if(std::to_string(__ANDROID_API__) == Config::get_vndk_version_string('.'))
- same_version_system_vendor = true;
- if (android::base::GetBoolProperty("ro.vndk.lite", false) && same_version_system_vendor) {
- return kLdConfigVndkLiteFilePath;
- }
-
std::string ld_config_file_vndk = kLdConfigFilePath;
size_t insert_pos = ld_config_file_vndk.find_last_of('.');
if (insert_pos == std::string::npos) {
--
2.17.1

View File

@ -0,0 +1,26 @@
From a1336cadfe7ff1afa46e87ba11849ebef622183e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 20:31:07 +0200
Subject: [PATCH] Don't reboot if we couldn't get bootctrl
Change-Id: Id1793660bd1c97ab369607f58a772ca3512ec1af
---
update_verifier/update_verifier.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/update_verifier/update_verifier.cpp b/update_verifier/update_verifier.cpp
index a042f900..ea3645af 100644
--- a/update_verifier/update_verifier.cpp
+++ b/update_verifier/update_verifier.cpp
@@ -310,7 +310,7 @@ int update_verifier(int argc, char** argv) {
sp<IBootControl> module = IBootControl::getService();
if (module == nullptr) {
LOG(ERROR) << "Error getting bootctrl module.";
- return reboot_device();
+ return 0;
}
uint32_t current_slot = module->getCurrentSlot();
--
2.17.1

View File

@ -0,0 +1,27 @@
From ddbe45ddd09f30beab8980d14c506f48ca1f8399 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 2 Mar 2018 22:49:55 +0100
Subject: [PATCH 01/10] Enable multipl_decls by default. This is needed because
8.0 init doesn't add -m
Change-Id: I43dc661d519f7b8576d72a828d8cbd444592bf5e
---
secilc/secilc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index 186c5a73..b422175e 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -91,7 +91,7 @@ int main(int argc, char *argv[])
int target = SEPOL_TARGET_SELINUX;
int mls = -1;
int disable_dontaudit = 0;
- int multiple_decls = 0;
+ int multiple_decls = 1;
int disable_neverallow = 0;
int preserve_tunables = 0;
int handle_unknown = -1;
--
2.17.1

View File

@ -0,0 +1,26 @@
From ff296de7912209e6fa20e1b28db93c395cc0bb75 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 9 Apr 2018 00:19:49 +0200
Subject: [PATCH 02/10] Increase default log_level to get actual selinux error
in kmsg
---
secilc/secilc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index b422175e..1e550ab4 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
int opt_index = 0;
char *fc_buf = NULL;
size_t fc_size;
- enum cil_log_level log_level = CIL_ERR;
+ enum cil_log_level log_level = CIL_WARN;
static struct option long_opts[] = {
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, 'v'},
--
2.17.1

View File

@ -0,0 +1,40 @@
From ecb4746fb8ba4e97cc53e6290dfa7a75495d19a8 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 3 Dec 2018 20:54:54 +0100
Subject: [PATCH 03/10] ::Kirin:: Workaround some conflicting Kirin tether
SELinux context
Some Kirin devices declared some android.hardware.tetheroffload HALs,
but they didn't use AOSP contexts.
This leads to libselinux aborting when loading hwservice_contexts.
Workaround it the ugly way, by making them match.
This most likely kills tetheroffload for those devices.
---
libselinux/src/label_backends_android.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libselinux/src/label_backends_android.c b/libselinux/src/label_backends_android.c
index eaca5947..ab92985b 100644
--- a/libselinux/src/label_backends_android.c
+++ b/libselinux/src/label_backends_android.c
@@ -62,6 +62,16 @@ static int nodups_specs(struct saved_data *data)
curr_spec->property_key)) {
if (strcmp(spec_arr[jj].lr.ctx_raw,
curr_spec->lr.ctx_raw)) {
+ if(strcmp(spec_arr[jj].lr.ctx_raw, "u:object_r:hal_ipacm_hwservice:s0") == 0) {
+ free(spec_arr[jj].lr.ctx_raw);
+ spec_arr[jj].lr.ctx_raw = strdup("u:object_r:hal_tetheroffload_hwservice:s0");
+ continue;
+ }
+ if(strcmp(curr_spec->lr.ctx_raw, "u:object_r:hal_ipacm_hwservice:s0") == 0) {
+ free(curr_spec->lr.ctx_raw);
+ curr_spec->lr.ctx_raw = strdup("u:object_r:hal_tetheroffload_hwservice:s0");
+ continue;
+ }
rc = -1;
errno = EINVAL;
selinux_log
--
2.17.1

View File

@ -0,0 +1,43 @@
From f014cf6460159f820fc0d72c6d0bece2851f9873 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 6 Sep 2019 15:07:25 +0200
Subject: [PATCH 04/10] Allow /devices/virtual/block/ genfscon conflict (seen
on Xiaomi Mi 9)
Change-Id: I06e4e9d5b82d61a8aeab595b47e2589249675895
---
libsepol/cil/src/cil_post.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
index a0cadfde..68c0318e 100644
--- a/libsepol/cil/src/cil_post.c
+++ b/libsepol/cil/src/cil_post.c
@@ -477,7 +477,23 @@ int cil_post_genfscon_context_compare(const void *a, const void *b)
{
struct cil_genfscon *a_genfscon = *(struct cil_genfscon**)a;
struct cil_genfscon *b_genfscon = *(struct cil_genfscon**)b;
- return context_compare(a_genfscon->context, b_genfscon->context);
+ int rc = context_compare(a_genfscon->context, b_genfscon->context);
+ if(rc) {
+ fprintf(stderr, "hello %s\n", a_genfscon->fs_str);
+ int bypass = 0;
+ /*
+ * This conflict has been seen on Xiaomi Mi 9:
+ * - AOSP Q says (genfscon sysfs /devices/virtual/block/ (u object_r sysfs_devices_block ((s0) (s0))))
+ * - stock rom says (genfscon sysfs /devices/virtual/block/ (u object_r sysfs_ufs_target ((s0) (s0))))
+ */
+ if(strcmp(a_genfscon->path_str, "/devices/virtual/block/") == 0)
+ bypass = 1;
+ if(bypass == 1) {
+ fprintf(stderr, "Received conflicting %s vs %s but ignore\n", a_genfscon->path_str, b_genfscon->path_str);
+ return 0;
+ }
+ }
+ return rc;
}
int cil_post_netifcon_context_compare(const void *a, const void *b)
--
2.17.1

View File

@ -0,0 +1,44 @@
From 37d5e860031c84803c2533d940847dc214cb2597 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 20:34:28 +0200
Subject: [PATCH 05/10] Most horrific: Remove ramdisk's zygote init scripts
This is needed because:
- only secilc is run soon enough in /system to
remove it
- placing an init.zygote in system won't have init replace it, it's the
first that appears that wins
Change-Id: I8be31ceb9ef2124d04994d9fb08fc8012a2f819e
---
secilc/secilc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index 1e550ab4..375320e6 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -34,6 +34,8 @@
#include <getopt.h>
#include <sys/stat.h>
+#include <unistd.h>
+
#ifdef ANDROID
#include <cil/cil.h>
#else
@@ -124,6 +126,11 @@ int main(int argc, char *argv[])
};
int i;
+ unlink("/init.zygote32.rc");
+ unlink("/init.zygote64_32.rc");
+ unlink("/init.zygote64.rc");
+ unlink("/init.zygote32_64.rc");
+
while (1) {
opt_char = getopt_long(argc, argv, "o:f:U:hvt:M:PDmNOc:GX:n", long_opts, &opt_index);
if (opt_char == -1) {
--
2.17.1

View File

@ -0,0 +1,44 @@
From 04fdf9096557accdea52b8b66665717f6c8a454a Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 12 Sep 2019 20:37:04 +0200
Subject: [PATCH 06/10] if service is "rcs", accept conflict. Seen on Moto E5
Change-Id: I0cc2d0fad83f403f2b5d7458039b1564ce5ed9dd
---
libselinux/src/label_backends_android.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libselinux/src/label_backends_android.c b/libselinux/src/label_backends_android.c
index ab92985b..ca16327c 100644
--- a/libselinux/src/label_backends_android.c
+++ b/libselinux/src/label_backends_android.c
@@ -72,14 +72,24 @@ static int nodups_specs(struct saved_data *data)
curr_spec->lr.ctx_raw = strdup("u:object_r:hal_tetheroffload_hwservice:s0");
continue;
}
- rc = -1;
- errno = EINVAL;
selinux_log
(SELINUX_ERROR,
"Multiple different specifications for %s (%s and %s).\n",
curr_spec->property_key,
spec_arr[jj].lr.ctx_raw,
curr_spec->lr.ctx_raw);
+ int ignore = 0;
+ /*
+ * This issue has been found on Moto E5
+ * E SELinux : Multiple different specifications for rcs (u:object_r:radio_service:s0 and u:object_r:mot_rcs_service:s0).
+ */
+ if(!strcmp(curr_spec->property_key, "rcs"))
+ ignore = 1;
+
+ if(!ignore) {
+ rc = -1;
+ errno = EINVAL;
+ }
} else {
selinux_log
(SELINUX_WARNING,
--
2.17.1

View File

@ -0,0 +1,84 @@
From ef94ddbd76328611893ace7870c0d3137fd26cdd Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 25 Oct 2019 13:29:20 +0200
Subject: [PATCH 07/10] Fix boot on Moto devices using unknown class
vendor sepolicy never contains new class or classorder, and are not
allowed to.
Though this is not tested, and it turns out Moto did it anyway.
This raises an issue, because class need to be ordered, and thus the cil
contains the ordering. This ordering needs to be merged.
Android 10 added new classes, so the ordering can no longer be merged,
and secilc fails on those devices, preventing boot.
Considering vendor are not supposed to declare new class (and thus
declare classorder), this fix ignores class-es/classorder in vendor
SELinux policy.
Since the vendor selinux policy has allows rules based on this context,
those allows will fail since the class doesn't exist.
Workaround this by ignoring rules with the problematic class
( keystore_moto_key )
Lucky us, this new class `keystore_moto_key` is used by Moto for
framework to framework (more accurately priv app to keymaster), since
our own framework doesn't use this class, simply ignoring it fixes the
issue.
Change-Id: I66339857634ebfdba359f12a99dfd0bff709d80b
---
libsepol/cil/src/cil_build_ast.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
index 307b1ee3..02cdcc65 100644
--- a/libsepol/cil/src/cil_build_ast.c
+++ b/libsepol/cil/src/cil_build_ast.c
@@ -386,6 +386,14 @@ int cil_gen_class(struct cil_db *db, struct cil_tree_node *parse_current, struct
struct cil_tree_node *perms = NULL;
int rc = SEPOL_ERR;
+ {
+ const char* path = cil_tree_get_cil_path(parse_current);
+ if(strstr(path, "vendor")) {
+ cil_clear_node(ast_node);
+ return SEPOL_OK;
+ }
+ }
+
rc = __cil_verify_syntax(parse_current, syntax, syntax_len);
if (rc != SEPOL_OK) {
goto exit;
@@ -452,6 +460,14 @@ int cil_gen_classorder(struct cil_db *db, struct cil_tree_node *parse_current, s
struct cil_list_item *head = NULL;
int rc = SEPOL_ERR;
+ {
+ const char* path = cil_tree_get_cil_path(parse_current);
+ if(strstr(path, "vendor")) {
+ cil_clear_node(ast_node);
+ return SEPOL_OK;
+ }
+ }
+
if (db == NULL || parse_current == NULL || ast_node == NULL) {
goto exit;
}
@@ -2050,6 +2066,14 @@ int cil_gen_avrule(struct cil_tree_node *parse_current, struct cil_tree_node *as
rule->src_str = parse_current->next->data;
rule->tgt_str = parse_current->next->next->data;
+ {
+ const char *classname = parse_current->next->next->next->cl_head->data;
+ if(strcmp(classname, "keystore_moto_key") == 0) {
+ cil_clear_node(ast_node);
+ return SEPOL_OK;
+ }
+ }
+
rc = cil_fill_classperms_list(parse_current->next->next->next, &rule->perms.classperms);
if (rc != SEPOL_OK) {
goto exit;
--
2.17.1

View File

@ -0,0 +1,27 @@
From 3d356da4654b5ae9eb2207f824555f0219687763 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 24 May 2020 17:22:22 +0200
Subject: [PATCH 08/10] Allow mismatches of exfat genfscon
---
libsepol/cil/src/cil_post.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c
index 68c0318e..75e5128c 100644
--- a/libsepol/cil/src/cil_post.c
+++ b/libsepol/cil/src/cil_post.c
@@ -488,6 +488,10 @@ int cil_post_genfscon_context_compare(const void *a, const void *b)
*/
if(strcmp(a_genfscon->path_str, "/devices/virtual/block/") == 0)
bypass = 1;
+ if(strcmp(a_genfscon->fs_str, "exfat") == 0 || strcmp(a_genfscon->fs_str, "esdfs") == 0) {
+ if(strcmp(a_genfscon->path_str, "/") == 0)
+ bypass = 1;
+ }
if(bypass == 1) {
fprintf(stderr, "Received conflicting %s vs %s but ignore\n", a_genfscon->path_str, b_genfscon->path_str);
return 0;
--
2.17.1

View File

@ -0,0 +1,45 @@
From f3d5e2eb212ebd4189428d6adb915880573962f9 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 9 Sep 2020 22:36:42 +0200
Subject: [PATCH 09/10] Revert "libsepol: Make an unknown permission an error
in CIL"
This reverts commit dc4e54126bf25dea4d51820922ccd1959be68fbc.
This is required because some targets calls undefined permissions:
- Realme X2 Pro calls sigcont
- Honor 7X calls perf_event
---
libsepol/cil/src/cil_resolve_ast.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
index 87575860..e72abdeb 100644
--- a/libsepol/cil/src/cil_resolve_ast.c
+++ b/libsepol/cil/src/cil_resolve_ast.c
@@ -131,14 +131,18 @@ static int __cil_resolve_perms(symtab_t *class_symtab, symtab_t *common_symtab,
}
}
if (rc != SEPOL_OK) {
+ struct cil_list *empty_list;
if (class_flavor == CIL_MAP_CLASS) {
cil_log(CIL_ERR, "Failed to resolve permission %s for map class\n", (char*)curr->data);
- } else {
- cil_log(CIL_ERR, "Failed to resolve permission %s\n", (char*)curr->data);
+ goto exit;
}
- goto exit;
+ cil_log(CIL_WARN, "Failed to resolve permission %s\n", (char*)curr->data);
+ /* Use an empty list to represent unknown perm */
+ cil_list_init(&empty_list, perm_strs->flavor);
+ cil_list_append(*perm_datums, CIL_LIST, empty_list);
+ } else {
+ cil_list_append(*perm_datums, CIL_DATUM, perm_datum);
}
- cil_list_append(*perm_datums, CIL_DATUM, perm_datum);
} else {
cil_list_append(*perm_datums, curr->flavor, curr->data);
}
--
2.17.1

View File

@ -0,0 +1,83 @@
From 00f7989d79ad8e219dae29de8e8f20e4dbab008a Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 27 Sep 2020 20:20:35 +0200
Subject: [PATCH 10/10] [HACK] For System-as-System devices, init won't call us
with /system_ext sepolicy
So add system_ext sepolicy ourselves
---
secilc/secilc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/secilc/secilc.c b/secilc/secilc.c
index 375320e6..162b87fb 100644
--- a/secilc/secilc.c
+++ b/secilc/secilc.c
@@ -233,6 +233,7 @@ int main(int argc, char *argv[])
usage(argv[0]);
}
}
+
if (optind >= argc) {
fprintf(stderr, "No cil files specified\n");
usage(argv[0]);
@@ -240,6 +241,11 @@ int main(int argc, char *argv[])
cil_set_log_level(log_level);
+ int needSystemExt = 1;
+ for (i = optind; i < argc; i++) {
+ if(strstr(argv[i], "system_ext")) needSystemExt = 0;
+ }
+
cil_db_init(&db);
cil_set_disable_dontaudit(db, disable_dontaudit);
cil_set_multiple_decls(db, multiple_decls);
@@ -261,6 +267,44 @@ int main(int argc, char *argv[])
}
for (i = optind; i < argc; i++) {
+ fprintf(stderr, "Hello, parsing %s\n", argv[i]);
+ if(needSystemExt && strstr(argv[i], "/etc/selinux/")) {
+ fprintf(stderr, "Hello, I'm adding system_ext to the mix!\n");
+ char *path = "/system/system_ext/etc/selinux/system_ext_sepolicy.cil";
+ file = fopen(path, "r");
+ if (!file) {
+ fprintf(stderr, "Could not open file: %s\n", path);
+ rc = SEPOL_ERR;
+ goto exit;
+ }
+ rc = stat(path, &filedata);
+ if (rc == -1) {
+ fprintf(stderr, "Could not stat file: %s\n", path);
+ rc = SEPOL_ERR;
+ goto exit;
+ }
+ file_size = filedata.st_size;
+
+ buffer = malloc(file_size);
+ rc = fread(buffer, file_size, 1, file);
+ if (rc != 1) {
+ fprintf(stderr, "Failure reading file: %s\n", path);
+ rc = SEPOL_ERR;
+ goto exit;
+ }
+ fclose(file);
+ file = NULL;
+
+ rc = cil_add_file(db, path, buffer, file_size);
+ if (rc != SEPOL_OK) {
+ fprintf(stderr, "Failure adding %s\n", path);
+ goto exit;
+ }
+
+ free(buffer);
+ buffer = NULL;
+
+ }
file = fopen(argv[i], "r");
if (!file) {
fprintf(stderr, "Could not open file: %s\n", argv[i]);
--
2.17.1

View File

@ -0,0 +1,182 @@
From 9f851c801719b45c79cd911d67ceb7e8f4cf63ab Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 31 Mar 2021 23:32:37 +0200
Subject: [PATCH] Workaround device/phh/treble conflict with SELinux policy
device/phh/treble defines the following three types (hostapd,
sysfs_usb_supply, rpmb_device)
However, Qualcomm Samsung Android 11 devices export those symbols as
typealias.
Type and typealias are fundamentally not mergeable.
Luckily, Samsung doesn't do anything with those typealias, so we can
simply ignore them.
Change-Id: I98db7e6eb55854887f90d0fd0f313fb0a19a488f
---
libsepol/cil/src/cil_binary.c | 8 ++++++--
libsepol/cil/src/cil_build_ast.c | 31 ++++++++++++++++++------------
libsepol/cil/src/cil_resolve_ast.c | 15 +++++++++++++--
3 files changed, 38 insertions(+), 16 deletions(-)
diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
index 03d53e1f..160fd0e0 100644
--- a/libsepol/cil/src/cil_binary.c
+++ b/libsepol/cil/src/cil_binary.c
@@ -515,13 +515,17 @@ int cil_typealias_to_policydb(policydb_t *pdb, struct cil_alias *cil_alias)
type_datum_init(sepol_alias);
rc = __cil_get_sepol_type_datum(pdb, DATUM(cil_alias->actual), &sepol_type);
- if (rc != SEPOL_OK) goto exit;
+ if (rc != SEPOL_OK) {
+ cil_log(CIL_ERR, "Failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);
+ goto exit;
+ }
sepol_alias->flavor = TYPE_TYPE;
key = cil_strdup(cil_alias->datum.fqn);
rc = symtab_insert(pdb, SYM_TYPES, key, sepol_alias, SCOPE_DECL, 0, NULL);
if (rc != SEPOL_OK) {
+ cil_log(CIL_ERR, "Failed at %s:%s:%d:%d\n", __FILE__, __FUNCTION__, __LINE__, rc);
goto exit;
}
sepol_alias->s.value = sepol_type->s.value;
@@ -3776,7 +3780,7 @@ int __cil_node_to_policydb(struct cil_tree_node *node, void *extra_args)
exit:
if (rc != SEPOL_OK) {
- cil_tree_log(node, CIL_ERR, "Binary policy creation failed");
+ cil_tree_log(node, CIL_ERR, "Binary policy creation failed, for pass = %d, flavor = %d", pass, node->flavor);
}
return rc;
}
diff --git a/libsepol/cil/src/cil_build_ast.c b/libsepol/cil/src/cil_build_ast.c
index 02cdcc65..2ba08bc6 100644
--- a/libsepol/cil/src/cil_build_ast.c
+++ b/libsepol/cil/src/cil_build_ast.c
@@ -1,16 +1,16 @@
/*
* Copyright 2011 Tresys Technology, LLC. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY TRESYS TECHNOLOGY, LLC ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
@@ -21,7 +21,7 @@
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* The views and conclusions contained in the software and documentation are those
* of the authors and should not be interpreted as representing official policies,
* either expressed or implied, of Tresys Technology, LLC.
@@ -64,7 +64,7 @@ int cil_fill_list(struct cil_tree_node *current, enum cil_flavor flavor, struct
CIL_SYN_END
};
int syntax_len = sizeof(syntax)/sizeof(*syntax);
-
+
rc = __cil_verify_syntax(current, syntax, syntax_len);
if (rc != SEPOL_OK) {
goto exit;
@@ -108,7 +108,7 @@ int cil_gen_node(struct cil_db *db, struct cil_tree_node *ast_node, struct cil_s
{
int rc = SEPOL_ERR;
symtab_t *symtab = NULL;
- struct cil_symtab_datum *prev;
+ struct cil_symtab_datum *prev = NULL;
rc = __cil_verify_name((const char*)key);
if (rc != SEPOL_OK) {
@@ -133,13 +133,20 @@ int cil_gen_node(struct cil_db *db, struct cil_tree_node *ast_node, struct cil_s
/* multiple_decls not ok, ret error */
cil_log(CIL_ERR, "Re-declaration of %s %s\n",
cil_node_to_string(ast_node), key);
- if (cil_symtab_get_datum(symtab, key, &datum) == SEPOL_OK) {
+ if (cil_symtab_get_datum(symtab, key, &prev) == SEPOL_OK) {
if (sflavor == CIL_SYM_BLOCKS) {
- struct cil_tree_node *node = datum->nodes->head->data;
+ struct cil_tree_node *node = prev->nodes->head->data;
cil_tree_log(node, CIL_ERR, "Previous declaration");
}
}
- goto exit;
+ if(
+ strcmp(key, "sysfs_usb_supply") == 0 ||
+ strcmp(key, "hostapd") == 0 ||
+ strcmp(key, "rpmb_device") == 0) {
+ cil_log(CIL_ERR, "Ignoring...");
+ } else {
+ goto exit;
+ }
}
/* multiple_decls is enabled and works for this datum type, add node */
cil_list_append(prev->nodes, CIL_NODE, ast_node);
@@ -572,7 +579,7 @@ int cil_gen_perm_nodes(struct cil_db *db, struct cil_tree_node *current_perm, st
while(current_perm != NULL) {
if (current_perm->cl_head != NULL) {
-
+
rc = SEPOL_ERR;
goto exit;
}
@@ -5717,7 +5724,7 @@ int cil_fill_ipaddr(struct cil_tree_node *addr_node, struct cil_ipaddr *addr)
return SEPOL_OK;
exit:
- cil_log(CIL_ERR, "Bad ip address or netmask\n");
+ cil_log(CIL_ERR, "Bad ip address or netmask\n");
return rc;
}
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
index e72abdeb..db3f24f4 100644
--- a/libsepol/cil/src/cil_resolve_ast.c
+++ b/libsepol/cil/src/cil_resolve_ast.c
@@ -512,7 +512,13 @@ int cil_resolve_aliasactual(struct cil_tree_node *current, void *extra_args, enu
}
if (NODE(alias_datum)->flavor != alias_flavor) {
cil_log(CIL_ERR, "%s is not an alias\n",alias_datum->name);
- rc = SEPOL_ERR;
+ if(
+ strcmp(alias_datum->name, "hostapd") == 0 ||
+ strcmp(alias_datum->name, "sysfs_usb_supply") == 0 ||
+ strcmp(alias_datum->name, "rpmb_device") == 0)
+ rc = 0;
+ else
+ rc = SEPOL_ERR;
goto exit;
}
@@ -553,7 +559,12 @@ int cil_resolve_alias_to_actual(struct cil_tree_node *current, enum cil_flavor f
int limit = 2;
if (alias->actual == NULL) {
- cil_tree_log(current, CIL_ERR, "Alias declared but not used");
+ cil_tree_log(current, CIL_ERR, "Alias %s declared but not used", a1->datum.name);
+ if(
+ strcmp(a1->datum.name, "hostapd") == 0 ||
+ strcmp(a1->datum.name, "sysfs_usb_supply") == 0 ||
+ strcmp(a1->datum.name, "rpmb_device") == 0)
+ return SEPOL_OK;
return SEPOL_ERR;
}
--
2.25.1

View File

@ -0,0 +1,54 @@
From 163f3f2b4a89df73d3ffede558d26bb0df966bbe Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Tue, 22 Sep 2020 10:38:04 +0200
Subject: [PATCH] GrGLCaps: allow ignoring vendor-supplied texture swizzle flag
* This is broken on MTK 8.1 vendor
Change-Id: I1ccae06f643f01e4ea6539e1d4e3c7df8d6e30ae
---
Android.bp | 1 +
src/gpu/gl/GrGLCaps.cpp | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/Android.bp b/Android.bp
index 122324c6ef..5ec949966a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -3,6 +3,7 @@
cc_library_static {
name: "libskia",
host_supported: true,
+ shared_libs: [ "libbase" ],
cflags: [
"-U_FORTIFY_SOURCE",
"-DATRACE_TAG=ATRACE_TAG_VIEW",
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 6a1bf56474..df007ba70c 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -22,6 +22,11 @@
#include "src/gpu/gl/GrGLTexture.h"
#include "src/utils/SkJSONWriter.h"
+#if defined(SK_BUILD_FOR_ANDROID)
+#include "android-base/properties.h"
+using android::base::GetBoolProperty;
+#endif
+
GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
const GrGLContextInfo& ctxInfo,
const GrGLInterface* glInterface) : INHERITED(contextOptions) {
@@ -273,6 +278,9 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
this->fShaderCaps->fTextureSwizzleAppliedInShader = false;
}
} // no WebGL support
+ if(GetBoolProperty("ro.skia.ignore_swizzle", false)) {
+ this->fShaderCaps->fTextureSwizzleAppliedInShader = true;
+ }
if (GR_IS_GR_GL(standard)) {
fMipMapLevelAndLodControlSupport = true;
--
2.17.1

View File

@ -0,0 +1,31 @@
From f85268cf7b0e928d741d316b59b3b31773fae7c8 Mon Sep 17 00:00:00 2001
From: Alexander Pohl <pohl199885@gmail.com>
Date: Fri, 15 Jun 2018 19:58:07 +0200
Subject: [PATCH 01/14] Fix WiFi-Display on Huawei devices (EMUI 8.0)
Huaweis media stack doesn't handle intra-refresh-mode, so skip the error instead.
Thanks to Chris Vandomelen for pointing that out.
---
media/libstagefright/ACodec.cpp | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 63ab6548b4..e25f8f6558 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -4432,9 +4432,8 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) {
if (msg->findInt32("intra-refresh-mode", &intraRefreshMode)) {
err = setCyclicIntraMacroblockRefresh(msg, intraRefreshMode);
if (err != OK) {
- ALOGE("Setting intra macroblock refresh mode (%d) failed: 0x%x",
- err, intraRefreshMode);
- return err;
+ ALOGE("setupAVCEncoderParameters(): set intra-refresh-mode failed, ignoring..");
+ //return err;
}
}
--
2.17.1

View File

@ -0,0 +1,36 @@
From 4ab15a33857452d990581a3d0073e35215e1c542 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 19 Aug 2018 22:59:06 +0200
Subject: [PATCH 02/14] ::Kirin:: Remove lock to prevent self-lock
With Huawei Camera HAL, we get the following call order:
cameraserver CameraService::enumerateProviders (*)
=> HAL ICameraProvider::getVendorTags
=> HAL ICameraProviderCallback::cameraDeviceStatusChange
=> cameraserver CameraService::addState
=> cameraserver CameraService::updateCameraNumAndIds (*)
The two functions marked with (*) take mServiceLock
Hence the safe-lock
Change-Id: I464255b5a3af8d75d72b1772ab55aa655f395a60
---
services/camera/libcameraservice/CameraService.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index af1e01d8e1..05252d6308 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -301,7 +301,7 @@ status_t CameraService::getSystemCameraKind(const String8& cameraId, SystemCamer
}
void CameraService::updateCameraNumAndIds() {
- Mutex::Autolock l(mServiceLock);
+ //Mutex::Autolock l(mServiceLock);
std::pair<int, int> systemAndNonSystemCameras = mCameraProviderManager->getCameraCount();
// Excludes hidden secure cameras
mNumberOfCameras =
--
2.17.1

View File

@ -0,0 +1,26 @@
From 1083cc0b59ed11aa69af22103ebaf74ae11f272c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 19 Aug 2018 23:05:26 +0200
Subject: [PATCH 03/14] We might not have a mFlashlight at this state, but
that's ok
---
services/camera/libcameraservice/CameraService.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 05252d6308..e1d23073f4 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -337,7 +337,7 @@ void CameraService::addStates(const String8 id) {
conflicting, deviceKind));
}
- if (mFlashlight->hasFlashUnit(id)) {
+ if (mFlashlight != nullptr && mFlashlight->hasFlashUnit(id)) {
Mutex::Autolock al(mTorchStatusMutex);
mTorchStatusMap.add(id, TorchModeStatus::AVAILABLE_OFF);
--
2.17.1

View File

@ -0,0 +1,62 @@
From 1c0e912c7bdef868de97dc07dd5227d298cd66a9 Mon Sep 17 00:00:00 2001
From: Artem Borisov <dedsa2002@gmail.com>
Date: Tue, 25 Sep 2018 12:39:22 +0300
Subject: [PATCH 04/14] CameraService: Support calling addStates in
enumerateProviders
Some pre-P camera HALs trigger onDeviceStatusChange callback during HAL init.
This is horribly wrong and causes a race condition between enumerateProviders
and onDeviceStatusChange. While it wasn't really harmful in O, in P call sequence
was changed and now this race condition leads to two problems: null pointer dereference
in addStates because mFlashlight is not initialized at a proper timing; mServiceLock
deadlock because updateCameraNumAndIds and enumerateProviders are called at the same time.
Moving addStates back to enumerateProviders makes the sequence more similar to O, and doesn't
let these two issues to happen.
Enable TARGET_CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE when it is necessary.
@Dil3mm4 edit: Instead of TARGET_CAMERA_NEEDS_ADD_STATES_IN_ENUMERATE let's use a system property to make it more generic and suitable for GSI use.
Change-Id: Ife25b9753fdb679ab0c77f385e1b8527551a4711
---
.../camera/libcameraservice/CameraService.cpp | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index e1d23073f4..83dea10f3a 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -221,6 +221,20 @@ status_t CameraService::enumerateProviders() {
for (auto& cameraId : deviceIds) {
String8 id8 = String8(cameraId.c_str());
+ if (property_get_bool("persist.sys.camera.huawei", false)) {
+ bool cameraFound = false;
+ {
+ Mutex::Autolock lock(mCameraStatesLock);
+ auto iter = mCameraStates.find(id8);
+ if (iter != mCameraStates.end()) {
+ cameraFound = true;
+ }
+ }
+ if (!cameraFound) {
+ addStates(id8);
+ }
+ }
+
if (getCameraState(id8) == nullptr) {
onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
}
@@ -375,8 +389,10 @@ void CameraService::onDeviceStatusChanged(const String8& id,
ALOGI("%s: Unknown camera ID %s, a new camera is added",
__FUNCTION__, id.string());
+ if (!property_get_bool("persist.sys.camera.huawei", false)) {
// First add as absent to make sure clients are notified below
addStates(id);
+ }
updateStatus(newStatus, id);
} else {
--
2.17.1

View File

@ -0,0 +1,131 @@
From 3afbad626827104662f61ab04ba3fbe6af32f73f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 5 Aug 2019 18:09:50 +0200
Subject: [PATCH 05/14] Fix BT in-call on CAF devices
See https://github.com/phhusson/treble_experimentations/issues/374
In Qualcomm's BSP audio_policy_configuration.xml, one route is missing,
from primary output and telephony to BT SCO.
Add it if we detect telephony and bt sco, but no such route.
Change-Id: Ifea0f88276ec9a0811f3cb1973c4b06f2c82077b
---
.../managerdefinitions/src/Serializer.cpp | 93 +++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 883e713326..d85dbdf113 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -596,6 +596,98 @@ Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSer
return route;
}
+static void fixupQualcommBtScoRoute(RouteTraits::Collection& routes, DevicePortTraits::Collection& devicePorts, HwModule* ctx) {
+ // On many Qualcomm devices, there is a BT SCO Headset Mic => primary input mix
+ // But Telephony Rx => BT SCO Headset route is missing
+ // When we detect such case, add the missing route
+
+ // If we have:
+ // <route type="mix" sink="Telephony Tx" sources="voice_tx"/>
+ // <route type="mix" sink="primary input" sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>
+ // <devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink" />
+ // And no <route type="mix" sink="BT SCO Headset" />
+
+ // Add:
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
+ bool foundBtScoHeadsetDevice = false;
+ for(const auto& device: devicePorts) {
+ if(device->getTagName() == "BT SCO Headset") {
+ foundBtScoHeadsetDevice = true;
+ break;
+ }
+ }
+ if(!foundBtScoHeadsetDevice) {
+ ALOGE("No BT SCO Headset device found, don't patch policy");
+ return;
+ }
+
+ bool foundTelephony = false;
+ bool foundBtScoInput = false;
+ bool foundScoHeadsetRoute = false;
+ for(const auto& route: routes) {
+ ALOGE("Looking at route %d\n", route->getType());
+ if(route->getType() != AUDIO_ROUTE_MIX)
+ continue;
+ auto sink = route->getSink();
+ ALOGE("... With sink %s\n", sink->getTagName().c_str());
+ if(sink->getTagName() == "Telephony Tx") {
+ foundTelephony = true;
+ continue;
+ }
+ if(sink->getTagName() == "BT SCO Headset") {
+ foundScoHeadsetRoute = true;
+ break;
+ }
+ for(const auto& source: route->getSources()) {
+ ALOGE("... With source %s\n", source->getTagName().c_str());
+ if(source->getTagName() == "BT SCO Headset Mic") {
+ foundBtScoInput = true;
+ break;
+ }
+ }
+ }
+ //The route we want to add is already there
+ ALOGE("Done looking for existing routes");
+ if(foundScoHeadsetRoute)
+ return;
+
+ ALOGE("No existing route found... %d %d", foundTelephony ? 1 : 0, foundBtScoInput ? 1 : 0);
+ //We couldn't find the routes we assume are required for the function we want to add
+ if(!foundTelephony || !foundBtScoInput)
+ return;
+ ALOGE("Adding our own.");
+
+ // Add:
+ // <route type="mix" sink="BT SCO Headset" sources="primary output,deep_buffer,compressed_offload,Telephony Rx"/>
+ AudioRoute *newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+
+ auto sink = ctx->findPortByTagName("BT SCO Headset");
+ ALOGE("Got sink %p\n", sink.get());
+ newRoute->setSink(sink);
+
+ Vector<sp<PolicyAudioPort>> sources;
+ for(const auto& sourceName: {
+ "primary output",
+ "deep_buffer",
+ "compressed_offload",
+ "Telephony Rx"
+ }) {
+ auto source = ctx->findPortByTagName(sourceName);
+ ALOGE("Got source %p\n", source.get());
+ if (source.get() != nullptr) {
+ sources.add(source);
+ source->addRoute(newRoute);
+ }
+ }
+
+ newRoute->setSources(sources);
+
+ sink->addRoute(newRoute);
+
+ auto ret = routes.add(newRoute);
+ ALOGE("route add returned %zd", ret);
+}
+
Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrSerializingCtx ctx)
{
std::string name = getXmlAttribute(cur, Attributes::name);
@@ -635,6 +727,7 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
if (status != NO_ERROR) {
return Status::fromStatusT(status);
}
+ fixupQualcommBtScoRoute(routes, devicePorts, module.get());
module->setRoutes(routes);
for (const xmlNode *children = cur->xmlChildrenNode; children != NULL;
--
2.17.1

View File

@ -0,0 +1,94 @@
From 4f7930e14f979ec5be530bd630ca9bb664050420 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 1 Oct 2019 13:35:49 +0200
Subject: [PATCH 06/14] Add (partial, cam id is hardcoded) support for Asus ZF6
motor camera
Change-Id: Iea6e1370780a1d16f728748d1d948d092532d8fe
---
.../camera/libcameraservice/CameraService.cpp | 26 +++++++++++++++++++
.../camera/libcameraservice/CameraService.h | 3 +++
2 files changed, 29 insertions(+)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 83dea10f3a..37ea512bdd 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -25,6 +25,7 @@
#include <ctime>
#include <string>
#include <sys/types.h>
+#include <sys/wait.h>
#include <inttypes.h>
#include <pthread.h>
@@ -139,6 +140,7 @@ Mutex CameraService::sProxyMutex;
sp<hardware::ICameraServiceProxy> CameraService::sCameraServiceProxy;
CameraService::CameraService() :
+ mPhysicalFrontCamStatus(false),
mEventLog(DEFAULT_EVENT_LOG_LENGTH),
mNumberOfCameras(0),
mNumberOfCamerasWithoutSystemCamera(0),
@@ -1785,6 +1787,7 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&
mServiceLock.lock();
} else {
// Otherwise, add client to active clients list
+ physicalFrontCam(cameraId == "1");
finishConnectLocked(client, partial);
}
} // lock is destroyed, allow further connect calls
@@ -1866,6 +1869,27 @@ status_t CameraService::addOfflineClient(String8 cameraId, sp<BasicClient> offli
return OK;
}
+void CameraService::physicalFrontCam(bool on) {
+ if(on == mPhysicalFrontCamStatus) return;
+ mPhysicalFrontCamStatus = on;
+
+ if(access("/dev/asusMotoDrv", F_OK) == 0) {
+ int pid = fork();
+ if(pid == 0) {
+ const char* cmd[] = {
+ "/system/bin/asus-motor",
+ "0",
+ NULL
+ };
+ cmd[1] = on ? "0" : "1";
+ execve("/system/bin/asus-motor", (char**)cmd, environ);
+ _exit(1);
+ } else {
+ waitpid(pid, NULL, 0);
+ }
+ }
+}
+
Status CameraService::setTorchMode(const String16& cameraId, bool enabled,
const sp<IBinder>& clientBinder) {
Mutex::Autolock lock(mServiceLock);
@@ -2840,6 +2864,8 @@ binder::Status CameraService::BasicClient::disconnect() {
}
mDisconnected = true;
+ sCameraService->physicalFrontCam(false);
+
sCameraService->removeByClient(this);
sCameraService->logDisconnected(mCameraIdStr, mClientPid, String8(mClientPackageName));
sCameraService->mCameraProviderManager->removeRef(CameraProviderManager::DeviceMode::CAMERA,
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 4321201100..85b1706996 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -202,6 +202,9 @@ public:
// Register an offline client for a given active camera id
status_t addOfflineClient(String8 cameraId, sp<BasicClient> offlineClient);
+ bool mPhysicalFrontCamStatus;
+ void physicalFrontCam(bool on);
+
/////////////////////////////////////////////////////////////////////
// Client functionality
--
2.17.1

View File

@ -0,0 +1,59 @@
From 93d21e226a4cac72ebc73f8fcec3001160d8570f Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Thu, 23 Jan 2020 11:13:43 +0800
Subject: [PATCH 07/14] audiopolicy: try again with trimmed audio port name if
not found
* In Spreadtrum BSP, some audio routes may contain ports with extra
spaces at the beginning and the end, causing audiopolicy to refuse to
load and leading to broken audio.
* Fix this by retrying with trimmed port name when not found. Do not
use trimmed name all the time because a white space is a valid
character in port name, and we cannot be sure nobody is using it for
legitimite purposes.
Change-Id: I993708b28e8404bc8c483d71a850ac69382231bd
---
.../managerdefinitions/src/Serializer.cpp | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index d85dbdf113..e25dda07c7 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -539,6 +539,17 @@ Return<DevicePortTraits::Element> DevicePortTraits::deserialize(const xmlNode *c
return deviceDesc;
}
+char* trim(char * s) {
+ int l = strlen(s);
+
+ if (l > 0) {
+ while (isspace(s[l - 1])) --l;
+ while (*s && isspace(*s)) ++s, --l;
+ }
+
+ return strndup(s, l);
+}
+
Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSerializingCtx ctx)
{
std::string type = getXmlAttribute(cur, Attributes::type);
@@ -579,8 +590,11 @@ Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSer
if (strlen(devTag) != 0) {
sp<PolicyAudioPort> source = ctx->findPortByTagName(devTag);
if (source == NULL) {
- ALOGE("%s: no source found with name=%s", __func__, devTag);
- return Status::fromStatusT(BAD_VALUE);
+ source = ctx->findPortByTagName(trim(devTag));
+ if (source == NULL) {
+ ALOGE("%s: no source found with name=%s", __func__, devTag);
+ return Status::fromStatusT(BAD_VALUE);
+ }
}
sources.add(source);
}
--
2.17.1

View File

@ -0,0 +1,46 @@
From 2c80a9c1453230a62f538fc128f286005d91b802 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 13 Apr 2020 21:01:16 +0200
Subject: [PATCH 08/14] There are three SCO devices. Fallback from one to the
others if needed
Change-Id: I414dcb6b154855c00cb8520b23dc1069827864b2
---
.../managerdefinitions/src/HwModule.cpp | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
index d31e4437e1..b2ca5e85de 100644
--- a/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/HwModule.cpp
@@ -292,6 +292,27 @@ sp <HwModule> HwModuleCollection::getModuleForDeviceType(audio_devices_t type,
}
}
}
+ //We didn't find one? Ok but all SCOs are equivalent surely?
+ if(type == AUDIO_DEVICE_OUT_BLUETOOTH_SCO ||
+ type == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET ||
+ type == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) {
+ ALOGE("Fallback SCO");
+ if(type != AUDIO_DEVICE_OUT_BLUETOOTH_SCO) {
+ auto ret = getModuleForDeviceType(AUDIO_DEVICE_OUT_BLUETOOTH_SCO, encodedFormat);
+ ALOGE("Fallback SCO simple? %s", (ret != nullptr) ? "yes" : "no");
+ if(ret != nullptr) return ret;
+ }
+ if(type != AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
+ auto ret = getModuleForDeviceType(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET, encodedFormat);
+ ALOGE("Fallback SCO headset? %s", (ret != nullptr) ? "yes" : "no");
+ if(ret != nullptr) return ret;
+ }
+ if(type != AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) {
+ auto ret = getModuleForDeviceType(AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT, encodedFormat);
+ ALOGE("Fallback SCO carkit? %s", (ret != nullptr) ? "yes" : "no");
+ if(ret != nullptr) return ret;
+ }
+ }
return nullptr;
}
--
2.17.1

View File

@ -0,0 +1,82 @@
From ab92e063952b11ee1090cbf9c0ba0935325a54af Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 14 May 2020 19:54:55 +0200
Subject: [PATCH] Add persist.sys.phh.samsung.camera_ids property to access
hidden Samsung cameras
Change-Id: I2c7bf535272acc28ed2277e96c78ddd28a0b4593
---
services/camera/libcameraservice/Android.bp | 3 ++-
.../common/CameraProviderManager.cpp | 14 ++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp
index 53fc1be7eb..99ca362bf3 100644
--- a/services/camera/libcameraservice/Android.bp
+++ b/services/camera/libcameraservice/Android.bp
@@ -131,7 +131,8 @@ cc_library_shared {
"android.hardware.camera.device@3.3",
"android.hardware.camera.device@3.4",
"android.hardware.camera.device@3.5",
- "android.hardware.camera.device@3.6"
+ "android.hardware.camera.device@3.6",
+ "vendor.samsung.hardware.camera.provider@3.0",
],
static_libs: [
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 876d70d7cf..0bff3606df 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -21,6 +21,7 @@
#include "CameraProviderManager.h"
#include <android/hardware/camera/device/3.5/ICameraDevice.h>
+#include <vendor/samsung/hardware/camera/provider/3.0/ISehCameraProvider.h>
#include <algorithm>
#include <chrono>
@@ -1330,6 +1331,7 @@ status_t CameraProviderManager::ProviderInfo::initialize(
mMinorVersion = 6;
}
}
+
// We need to check again since cast2_6.isOk() succeeds even if the provider
// version isn't actually 2.6.
if (interface2_6 == nullptr){
@@ -1358,6 +1360,9 @@ status_t CameraProviderManager::ProviderInfo::initialize(
return mapToStatusT(status);
}
+ auto samsungCast = vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider::castFrom(interface);
+ auto samsungProvider = samsungCast.isOk() ? static_cast<sp<vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider>>(samsungCast) : nullptr;
+
hardware::Return<bool> linked = interface->linkToDeath(this, /*cookie*/ mId);
if (!linked.isOk()) {
ALOGE("%s: Transaction error in linking to camera provider '%s' death: %s",
@@ -1388,7 +1393,7 @@ status_t CameraProviderManager::ProviderInfo::initialize(
// Get initial list of camera devices, if any
std::vector<std::string> devices;
- hardware::Return<void> ret = interface->getCameraIdList([&status, this, &devices](
+ auto cb = [&status, this, &devices](
Status idStatus,
const hardware::hidl_vec<hardware::hidl_string>& cameraDeviceNames) {
status = idStatus;
@@ -1405,7 +1410,12 @@ status_t CameraProviderManager::ProviderInfo::initialize(
mProviderPublicCameraIds.push_back(id);
}
}
- } });
+ } };
+ hardware::Return<void> ret;
+ if(samsungProvider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
+ ret = samsungProvider->sehGetCameraIdList(cb);
+ else
+ ret = interface->getCameraIdList(cb);
if (!ret.isOk()) {
ALOGE("%s: Transaction error in getting camera ID list from provider '%s': %s",
__FUNCTION__, mProviderName.c_str(), linked.description().c_str());
--
2.25.1

View File

@ -0,0 +1,45 @@
From 6dff7fa42818b525faa0a80d161ad54055ebc38e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 19 May 2020 14:01:14 +0200
Subject: [PATCH 11/14] Add a property to force camera timestamp source
Some devices wrongly report their timesource
Camera's timesource can either be CLOCK_MONOTONIC, or CLOCK_BOOTTIME
The former doesn't increment in sleep, while the later does.
There is a camera HAL property for that, though some devices don't
report it properly.
This issue happens on Xiaomi Redmi 7A, it needs to force the value to 1
Add a property persist.sys.phh.camera.force_timestampsource to force
timestamp source.
---
.../libcameraservice/device3/Camera3Device.cpp | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 4a509aa745..cdf9fc783e 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -316,8 +316,16 @@ status_t Camera3Device::initializeCommonLocked() {
// Measure the clock domain offset between camera and video/hw_composer
camera_metadata_entry timestampSource =
mDeviceInfo.find(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE);
- if (timestampSource.count > 0 && timestampSource.data.u8[0] ==
- ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME) {
+ int timestampSourceValue = 0;
+ if ((timestampSource.count > 0 && timestampSource.data.u8[0] ==
+ ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME)) {
+ timestampSourceValue = 1;
+ }
+ int forceTimestampSource = property_get_int32("persist.sys.phh.camera.force_timestampsource", -1);
+ //Don't override if it's -1, default value
+ if(forceTimestampSource == 0) timestampSourceValue = 0;
+ if(forceTimestampSource == 1) timestampSourceValue = 1;
+ if (timestampSourceValue == 1) {
mTimestampOffset = getMonoToBoottimeOffset();
}
--
2.17.1

View File

@ -0,0 +1,79 @@
From 7f14fcbf4bcf6d8f8c4b89f6ac4b91bc4961ed6f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 24 Apr 2018 00:14:28 +0200
Subject: [PATCH 12/14] FIH devices: Fix "Earpiece" audio output
On some FIH devices (confirmed on Razer, and probably on Aquos SS2),
Earpiece is not listed in attachedDevices, and devicePort's profile
mentions it is AUDIO_CHANNEL_IN_MONO, instead of AUDIO_CHANNEL_OUT_MONO.
Detect such cases (output device, but got only AUDIO_CHANNEL_IN_MONO),
and fix both channelMasks and attachedDevices
Change-Id: I4a88ba6d34d0fcd346eeea2ca903772f0271040a
---
.../managerdefinitions/src/Serializer.cpp | 27 ++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index e25dda07c7..a8eb142c81 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -396,15 +396,24 @@ Return<AudioGainTraits::Element> AudioGainTraits::deserialize(const xmlNode *cur
}
}
+static bool fixedEarpieceChannels = false;
Return<AudioProfileTraits::Element> AudioProfileTraits::deserialize(const xmlNode *cur,
- PtrSerializingCtx /*serializingContext*/)
+ PtrSerializingCtx serializingContext)
{
+ bool isOutput = serializingContext != nullptr;
std::string samplingRates = getXmlAttribute(cur, Attributes::samplingRates);
std::string format = getXmlAttribute(cur, Attributes::format);
std::string channels = getXmlAttribute(cur, Attributes::channelMasks);
+ ChannelTraits::Collection channelsMask = channelMasksFromString(channels, ",");
+
+ //Some Foxconn devices have wrong earpiece channel mask, leading to no channel mask
+ if(channelsMask.size() == 1 && *channelsMask.begin() == AUDIO_CHANNEL_IN_MONO && isOutput) {
+ fixedEarpieceChannels = true;
+ channelsMask = channelMasksFromString("AUDIO_CHANNEL_OUT_MONO", ",");
+ }
Element profile = new AudioProfile(formatFromString(format, gDynamicFormat),
- channelMasksFromString(channels, ","),
+ channelsMask,
samplingRatesFromString(samplingRates, ","));
profile->setDynamicFormat(profile->getFormat() == gDynamicFormat);
@@ -517,7 +526,11 @@ Return<DevicePortTraits::Element> DevicePortTraits::deserialize(const xmlNode *c
Element deviceDesc = new DeviceDescriptor(type, name, address, encodedFormats);
AudioProfileTraits::Collection profiles;
- status_t status = deserializeCollection<AudioProfileTraits>(cur, &profiles, NULL);
+ status_t status;
+ if(audio_is_output_devices(type))
+ status = deserializeCollection<AudioProfileTraits>(cur, &profiles, (PtrSerializingCtx)1);
+ else
+ status = deserializeCollection<AudioProfileTraits>(cur, &profiles, NULL);
if (status != NO_ERROR) {
return Status::fromStatusT(status);
}
@@ -782,6 +795,14 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
}
}
}
+
+ if(fixedEarpieceChannels) {
+ sp<DeviceDescriptor> device =
+ module->getDeclaredDevices().getDeviceFromTagName("Earpiece");
+ if(device != 0)
+ ctx->addDevice(device);
+ fixedEarpieceChannels = false;
+ }
return module;
}
--
2.17.1

View File

@ -0,0 +1,32 @@
From 4b6dc11462996df5987ac339bf2fb750f500a067 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 12 Sep 2020 12:32:50 +0200
Subject: [PATCH 13/14] [audiopolicy] No longer make re-assigning legacy audio
groups fatal. Mi9 declares AUDIO_STREAM_PATCH and AUDIO_STREAM_REROUTING
which is defined by framework too
Change-Id: I794fe22d63a8af705be4f5f09b9879ecaab3eae5
---
services/audiopolicy/engine/common/src/EngineBase.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/services/audiopolicy/engine/common/src/EngineBase.cpp b/services/audiopolicy/engine/common/src/EngineBase.cpp
index 1bc7fe3dcc..fe18d0d794 100644
--- a/services/audiopolicy/engine/common/src/EngineBase.cpp
+++ b/services/audiopolicy/engine/common/src/EngineBase.cpp
@@ -206,9 +206,9 @@ engineConfig::ParsingResult EngineBase::loadAudioPolicyEngineConfig()
}
if (group.stream != AUDIO_STREAM_DEFAULT) {
// A legacy stream can be assigned once to a volume group
- LOG_ALWAYS_FATAL_IF(checkStreamForGroups(group.stream, mVolumeGroups),
- "stream %s already assigned to a volume group, "
- "review the configuration", toString(group.stream).c_str());
+ if(checkStreamForGroups(group.stream, mVolumeGroups)) {
+ ALOGE("stream %s already assigned to a volume group, review the configuration", toString(group.stream).c_str());
+ }
volumeGroup->addSupportedStream(group.stream);
}
addSupportedAttributesToGroup(group, volumeGroup, strategy);
--
2.17.1

View File

@ -0,0 +1,341 @@
From d24b9bfa7113578d6a9e7a98a01e0ef6dfb970ea Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 25 May 2020 21:26:54 +0200
Subject: [PATCH 14/14] Add persist.sys.phh.disable_a2dp_offload property to
force a2dp offload
Change-Id: Id474540c33c594cc4010a1a398d82bff8aadaeea
---
media/libstagefright/ACodec.cpp | 20 +-
.../managerdefinitions/src/Serializer.cpp | 181 +++++++++++++++++-
.../audiopolicy/enginedefault/src/Engine.cpp | 2 +-
.../managerdefault/AudioPolicyManager.cpp | 3 +
4 files changed, 199 insertions(+), 7 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index e25f8f6558..7ff3c8f61b 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1166,6 +1166,9 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
return err;
}
+ ALOGE("Window undequeued buffers is %d\n", *minUndequeuedBuffers);
+ ALOGE("Consumerrequested %d\n", def.nBufferCountMin);
+
// FIXME: assume that surface is controlled by app (native window
// returns the number for the case when surface is not controlled by app)
// FIXME2: This means that minUndeqeueudBufs can be 1 larger than reported
@@ -1178,22 +1181,29 @@ status_t ACodec::configureOutputBuffersFromNativeWindow(
// 2. try to allocate two (2) additional buffers to reduce starvation from
// the consumer
// plus an extra buffer to account for incorrect minUndequeuedBufs
- for (OMX_U32 extraBuffers = 2 + 1; /* condition inside loop */; extraBuffers--) {
- OMX_U32 newBufferCount =
- def.nBufferCountMin + *minUndequeuedBuffers + extraBuffers;
+ for (int extraBuffers = 2 + 1; /* condition inside loop */; extraBuffers--) {
+ int a = def.nBufferCountMin;
+ int b = *minUndequeuedBuffers;
+ int c = extraBuffers;
+ int newBufferCount = a+b+c;
def.nBufferCountActual = newBufferCount;
err = mOMXNode->setParameter(
OMX_IndexParamPortDefinition, &def, sizeof(def));
if (err == OK) {
- *minUndequeuedBuffers += extraBuffers;
+ ALOGE("Managed to allocate %d buffers (%d extra)\n", newBufferCount, extraBuffers);
+ if(extraBuffers > 0) {
+ *minUndequeuedBuffers += extraBuffers;
+ } else {
+ *minUndequeuedBuffers -= -extraBuffers;
+ }
break;
}
ALOGW("[%s] setting nBufferCountActual to %u failed: %d",
mComponentName.c_str(), newBufferCount, err);
/* exit condition */
- if (extraBuffers == 0) {
+ if (extraBuffers == -2 || newBufferCount == 1) {
return err;
}
}
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index a8eb142c81..73e4a3e096 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -29,6 +29,7 @@
#include <utils/StrongPointer.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
+#include <cutils/properties.h>
#include "Serializer.h"
#include "TypeConverter.h"
@@ -36,6 +37,8 @@ namespace android {
namespace {
+static bool forceDisableA2dpOffload = false;
+
// TODO(mnaganov): Consider finding an alternative for using HIDL code.
using hardware::Return;
using hardware::Status;
@@ -318,7 +321,7 @@ status_t deserializeCollection(const xmlNode *cur,
return status;
}
} else {
- return BAD_VALUE;
+ ALOGE("Ignoring...");
}
}
}
@@ -734,12 +737,34 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
Element module = new HwModule(name.c_str(), versionMajor, versionMinor);
+ bool isA2dpModule = strcmp(name.c_str(), "a2dp") == 0;
+ bool isPrimaryModule = strcmp(name.c_str(), "primary") == 0;
+
// Deserialize childrens: Audio Mix Port, Audio Device Ports (Source/Sink), Audio Routes
MixPortTraits::Collection mixPorts;
status_t status = deserializeCollection<MixPortTraits>(cur, &mixPorts, NULL);
if (status != NO_ERROR) {
return Status::fromStatusT(status);
}
+ if(forceDisableA2dpOffload && isA2dpModule) {
+ for(const auto& mixPort: mixPorts) {
+ ALOGE("Disable a2dp offload...? %s", mixPort->getTagName().c_str());
+ //"a2dp" sw module already has a2dp out
+ if(mixPort->getTagName() == "a2dp output") {
+ forceDisableA2dpOffload = false;
+ break;
+ }
+ }
+ }
+ if(forceDisableA2dpOffload && isA2dpModule) {
+ //Add
+ //<mixPort name="a2dp output" role="source"/>
+ auto mixPort = new IOProfile("a2dp output", AUDIO_PORT_ROLE_SOURCE);
+ AudioProfileTraits::Collection profiles;
+ profiles.add(AudioProfile::createFullDynamic());
+ mixPort->setAudioProfiles(profiles);
+ mixPorts.push_back(mixPort);
+ }
module->setProfiles(mixPorts);
DevicePortTraits::Collection devicePorts;
@@ -747,6 +772,90 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
if (status != NO_ERROR) {
return Status::fromStatusT(status);
}
+ Vector<std::string> a2dpOuts;
+ a2dpOuts.push_back("BT A2DP Out");
+ a2dpOuts.push_back("BT A2DP Headphones");
+ a2dpOuts.push_back("BT A2DP Speaker");
+ if(forceDisableA2dpOffload) {
+ if(isA2dpModule) {
+ //<devicePort tagName="BT A2DP Out" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP" role="sink" address="lhdc_a2dp">
+ // <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ // samplingRates="44100,48000,96000"
+ // channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+ //</devicePort>
+ if(true) {
+ FormatVector formats;
+ //auto devicePortOut = new DeviceDescriptor(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, formats, "BT A2DP Out");
+ auto devicePortOut = new DeviceDescriptor(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, "BT A2DP Out");
+ AudioProfileTraits::Collection profiles;
+ ChannelTraits::Collection channels;
+ channels.insert(AUDIO_CHANNEL_OUT_STEREO);
+ SampleRateSet sampleRates;
+ sampleRates.insert(44100);
+ sampleRates.insert(48000);
+ sampleRates.insert(96000);
+ auto profile = new AudioProfile(AUDIO_FORMAT_PCM_16_BIT, channels, sampleRates);
+ profiles.add(profile);
+ devicePortOut->setAudioProfiles(profiles);
+ devicePortOut->setAddress("lhdc_a2dp");
+ devicePorts.add(devicePortOut);
+ }
+ //<devicePort tagName="BT A2DP Headphones" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES" role="sink" address="lhdc_a2dp">
+ // <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ // samplingRates="44100,48000,96000"
+ // channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+ //</devicePort>
+ if(true) {
+ FormatVector formats;
+ auto devicePortOut = new DeviceDescriptor(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, "BT A2DP Headphones");
+ AudioProfileTraits::Collection profiles;
+ ChannelTraits::Collection channels;
+ channels.insert(AUDIO_CHANNEL_OUT_STEREO);
+ SampleRateSet sampleRates;
+ sampleRates.insert(44100);
+ sampleRates.insert(48000);
+ sampleRates.insert(96000);
+ auto profile = new AudioProfile(AUDIO_FORMAT_PCM_16_BIT, channels, sampleRates);
+ profiles.add(profile);
+ devicePortOut->setAudioProfiles(profiles);
+ devicePortOut->setAddress("lhdc_a2dp");
+ devicePorts.add(devicePortOut);
+ }
+ //<devicePort tagName="BT A2DP Speaker" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER" role="sink" address="lhdc_a2dp">
+ // <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ // samplingRates="44100,48000,96000"
+ // channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
+ //</devicePort>
+ if(true) {
+ FormatVector formats;
+ auto devicePortOut = new DeviceDescriptor(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, "BT A2DP Speaker");
+ AudioProfileTraits::Collection profiles;
+ ChannelTraits::Collection channels;
+ channels.insert(AUDIO_CHANNEL_OUT_STEREO);
+ SampleRateSet sampleRates;
+ sampleRates.insert(44100);
+ sampleRates.insert(48000);
+ sampleRates.insert(96000);
+ auto profile = new AudioProfile(AUDIO_FORMAT_PCM_16_BIT, channels, sampleRates);
+ profiles.add(profile);
+ devicePortOut->setAudioProfiles(profiles);
+ devicePortOut->setAddress("lhdc_a2dp");
+ devicePorts.add(devicePortOut);
+
+ }
+ } else if(isPrimaryModule) {
+ for(const auto& out: a2dpOuts) {
+ auto iterA = std::find_if(devicePorts.begin(), devicePorts.end(), [out](const auto port) {
+ if(port->getTagName() == out) return true;
+ return false;
+ });
+ if(iterA != devicePorts.end()) {
+ ALOGE("Erasing device port %s", (*iterA)->getTagName().c_str());
+ devicePorts.erase(iterA);
+ }
+ }
+ }
+ }
module->setDeclaredDevices(devicePorts);
RouteTraits::Collection routes;
@@ -754,7 +863,76 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
if (status != NO_ERROR) {
return Status::fromStatusT(status);
}
+ if(forceDisableA2dpOffload) {
+ if(strcmp(name.c_str(), "primary") == 0) {
+ for(const auto& out: a2dpOuts) {
+ auto iterA = std::find_if(routes.begin(), routes.end(), [out](const auto route) {
+ if(route->getType() != AUDIO_ROUTE_MIX)
+ return false;
+ auto sink = route->getSink();
+ if(sink->getTagName() == out) {
+ return true;
+ }
+ return false;
+ });
+ if(iterA != routes.end()) {
+ auto sink = (*iterA)->getSink()->getTagName();
+ ALOGE("Erasing route %s", sink.c_str());
+ routes.erase(iterA);
+ }
+ }
+ } else if(isA2dpModule) {
+ //<route type="mix" sink="BT A2DP Out"
+ // sources="a2dp output"/>
+ if(true) {
+ auto newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+ auto sink = module->findPortByTagName("BT A2DP Out");
+ auto source = module->findPortByTagName("a2dp output");
+ newRoute->setSink(sink);
+ Vector<sp<PolicyAudioPort>> sources;
+ sources.add(source);
+
+ sink->addRoute(newRoute);
+ source->addRoute(newRoute);
+ newRoute->setSources(sources);
+
+ routes.add(newRoute);
+ }
+ //<route type="mix" sink="BT A2DP Headphones"
+ // sources="a2dp output"/>
+ if(true) {
+ auto newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+ auto sink = module->findPortByTagName("BT A2DP Headphones");
+ auto source = module->findPortByTagName("a2dp output");
+ newRoute->setSink(sink);
+ Vector<sp<PolicyAudioPort>> sources;
+ sources.add(source);
+
+ sink->addRoute(newRoute);
+ source->addRoute(newRoute);
+ newRoute->setSources(sources);
+ routes.add(newRoute);
+ }
+ //<route type="mix" sink="BT A2DP Speaker"
+ // sources="a2dp output"/>
+ if(true) {
+ auto newRoute = new AudioRoute(AUDIO_ROUTE_MIX);
+ auto sink = module->findPortByTagName("BT A2DP Speaker");
+ auto source = module->findPortByTagName("a2dp output");
+ newRoute->setSink(sink);
+ Vector<sp<PolicyAudioPort>> sources;
+ sources.add(source);
+
+ sink->addRoute(newRoute);
+ source->addRoute(newRoute);
+ newRoute->setSources(sources);
+ routes.add(newRoute);
+ }
+ }
+ }
+ ALOGE("Good morning");
fixupQualcommBtScoRoute(routes, devicePorts, module.get());
+ ALOGE("Good morning2");
module->setRoutes(routes);
for (const xmlNode *children = cur->xmlChildrenNode; children != NULL;
@@ -932,6 +1110,7 @@ status_t PolicySerializer::deserialize(const char *configFile, AudioPolicyConfig
status_t deserializeAudioPolicyFile(const char *fileName, AudioPolicyConfig *config)
{
PolicySerializer serializer;
+ forceDisableA2dpOffload = property_get_bool("persist.sys.phh.disable_a2dp_offload", false);
return serializer.deserialize(fileName, config);
}
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index b14d2bbb0b..16a7a4bbac 100755
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -52,7 +52,7 @@ static const std::vector<legacy_strategy_map>& getLegacyStrategy() {
{ "STRATEGY_ENFORCED_AUDIBLE", STRATEGY_ENFORCED_AUDIBLE },
{ "STRATEGY_TRANSMITTED_THROUGH_SPEAKER", STRATEGY_TRANSMITTED_THROUGH_SPEAKER },
{ "STRATEGY_ACCESSIBILITY", STRATEGY_ACCESSIBILITY },
- { "STRATEGY_REROUTING", STRATEGY_REROUTING },
+ //{ "STRATEGY_REROUTING", STRATEGY_REROUTING },
{ "STRATEGY_PATCH", STRATEGY_REROUTING }, // boiler to manage stream patch volume
{ "STRATEGY_CALL_ASSISTANT", STRATEGY_CALL_ASSISTANT },
};
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index c5c13e9a5a..1c5ed86b86 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -93,6 +93,8 @@ bool operator!= (const SortedVector<T> &left, const SortedVector<T> &right)
return !(left == right);
}
+static bool forceDisableA2dpOffload = false;
+
// ----------------------------------------------------------------------------
// AudioPolicyInterface implementation
// ----------------------------------------------------------------------------
@@ -4458,6 +4460,7 @@ static status_t deserializeAudioPolicyXmlConfig(AudioPolicyConfig &config) {
} else if (property_get_bool("persist.bluetooth.bluetooth_audio_hal.disabled", false)) {
fileNames.push_back(AUDIO_POLICY_BLUETOOTH_LEGACY_HAL_XML_CONFIG_FILE_NAME);
}
+ forceDisableA2dpOffload = property_get_bool("persist.sys.phh.disable_a2dp_offload", false);
fileNames.push_back(AUDIO_POLICY_XML_CONFIG_FILE_NAME);
for (const char* fileName : fileNames) {
--
2.17.1

View File

@ -0,0 +1,40 @@
From 3c374cb65bd0e28c73fbd452e8201487dd1acb94 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 3 Dec 2019 14:04:17 +0100
Subject: [PATCH 15/15] Fix for some Huawei camera
---
services/camera/libcameraservice/CameraService.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 5d062a5fb3..97e9825c51 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "CameraService"
#define ATRACE_TAG ATRACE_TAG_CAMERA
-//#define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
#include <algorithm>
#include <climits>
@@ -235,10 +235,11 @@ status_t CameraService::enumerateProviders() {
if (!cameraFound) {
addStates(id8);
}
- }
-
- if (getCameraState(id8) == nullptr) {
onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
+ } else {
+ if (getCameraState(id8) == nullptr) {
+ onDeviceStatusChanged(id8, CameraDeviceStatus::PRESENT);
+ }
}
}
--
2.25.1

View File

@ -0,0 +1,30 @@
From 6a6c54584fae07783b493a56afd047984f589ed0 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 21 Dec 2020 20:19:11 +0100
Subject: [PATCH 16/16] Make camera IDs filter-out optional
Nowadays most people have Camera 2 apps, and would like to have all
cameras, rather than limit which cameras are available.
Add a property for that.
---
.../camera/libcameraservice/common/CameraProviderManager.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 0bff3606df..3e6ad1ef52 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -183,7 +183,9 @@ std::vector<std::string> CameraProviderManager::getAPI1CompatibleCameraDeviceIds
// API1 app doesn't handle logical and physical camera devices well. So
// for each camera facing, only take the first id advertised by HAL in
// all [logical, physical1, physical2, ...] id combos, and filter out the rest.
- filterLogicalCameraIdsLocked(providerDeviceIds);
+ if(!property_get_bool("persist.sys.phh.include_all_cameras", false)) {
+ filterLogicalCameraIdsLocked(providerDeviceIds);
+ }
collectDeviceIdsLocked(providerDeviceIds, publicDeviceIds, systemDeviceIds);
}
auto sortFunc =
--
2.25.1

View File

@ -0,0 +1,88 @@
From 8d97b4814211158932b8482888f5b7bcc8a5a21e Mon Sep 17 00:00:00 2001
From: Houxiang Dai <houxiang.dai@mediatek.com>
Date: Thu, 23 Jul 2020 14:07:22 +0800
Subject: [PATCH 17/30] ACodec: Handle HDR10+ metadata at
OutputPortSettingsChangedState
[Description]
handle kWhatSetParameters message in OutputPortSettingsChangedState
handle OMX_EventConfigUpdate event in OutputPortSettingsChangedState
In HDR10+ test, we have to associate each HDR10+ metadata to a particular
frame. If receive a kWhatSetParameters message with "hdr10-plus-info"
buffer, it should not be deferred in OutputPortSettingsChangedState and
adopt OMX_SetConfig to associates this config with the next input buffer
sent in OMX_EmptyThisBuffer. The OMX_EventConfigUpdate event report from
component should be handled also in OutputPortSettingsChangedState,
where is to associate updated "hdr10-plus-info" metadata with the next
output buffer sent via FillBufferDone callback.
Bug: 157213958
Bug: 157435393
Change-Id: I27e4614487414063831fa760b9e9ca96b1c3712c
(cherry picked from commit c111aa4fda9b5b434edb1b46898ff8dd7e51cec6)
---
media/libstagefright/ACodec.cpp | 36 ++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index b9d0f5bb72..f843c7f45f 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -8296,13 +8296,34 @@ bool ACodec::OutputPortSettingsChangedState::onMessageReceived(
FALLTHROUGH_INTENDED;
}
case kWhatResume:
+ {
+ ALOGV("[%s] Deferring resume", mCodec->mComponentName.c_str());
+
+ mCodec->deferMessage(msg);
+ handled = true;
+ break;
+ }
+
case kWhatSetParameters:
{
- if (msg->what() == kWhatResume) {
- ALOGV("[%s] Deferring resume", mCodec->mComponentName.c_str());
+ sp<AMessage> params;
+ CHECK(msg->findMessage("params", &params));
+
+ sp<ABuffer> hdr10PlusInfo;
+ if (params->findBuffer("hdr10-plus-info", &hdr10PlusInfo)) {
+ if (hdr10PlusInfo != nullptr && hdr10PlusInfo->size() > 0) {
+ (void)mCodec->setHdr10PlusInfo(hdr10PlusInfo);
+ }
+ params->removeEntryAt(params->findEntryByName("hdr10-plus-info"));
+
+ if (params->countEntries() == 0) {
+ msg->removeEntryAt(msg->findEntryByName("params"));
+ }
}
- mCodec->deferMessage(msg);
+ if (msg->countEntries() > 0) {
+ mCodec->deferMessage(msg);
+ }
handled = true;
break;
}
@@ -8417,6 +8438,15 @@ bool ACodec::OutputPortSettingsChangedState::onOMXEvent(
return false;
}
+ case OMX_EventConfigUpdate:
+ {
+ CHECK_EQ(data1, (OMX_U32)kPortIndexOutput);
+
+ mCodec->onConfigUpdate((OMX_INDEXTYPE)data2);
+
+ return true;
+ }
+
default:
return BaseState::onOMXEvent(event, data1, data2);
}
--
2.25.1

View File

@ -0,0 +1,174 @@
From a141c7102252377bc882b982b36980edb60f931e Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Tue, 5 Jan 2021 18:58:15 -0800
Subject: [PATCH 19/30] CCodec: store flushed config as work items
Store flushed config as work items and queue them to the component
directly, instead of going through MediaCodecBuffer.
Bug: 176501678
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Test: atest CtsMediaTestCases:AdaptivePlaybackTest
Merged-In: I19991101c388eca49226ad2abc37df9cea22dbb8
Change-Id: I19991101c388eca49226ad2abc37df9cea22dbb8
(cherry picked from commit 5ebfcb24855e526ec040b9f41d216f7604b8981a)
---
media/codec2/sfplugin/CCodecBufferChannel.cpp | 119 ++++++++----------
media/codec2/sfplugin/CCodecBufferChannel.h | 2 +-
2 files changed, 53 insertions(+), 68 deletions(-)
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index 1654b11c31..b8ca41b9a8 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -1300,54 +1300,30 @@ status_t CCodecBufferChannel::requestInitialInputBuffers() {
return a.capacity < b.capacity;
});
- {
- Mutexed<std::list<sp<ABuffer>>>::Locked configs(mFlushedConfigs);
- if (!configs->empty()) {
- while (!configs->empty()) {
- sp<ABuffer> config = configs->front();
- configs->pop_front();
- // Find the smallest input buffer that can fit the config.
- auto i = std::find_if(
- clientInputBuffers.begin(),
- clientInputBuffers.end(),
- [cfgSize = config->size()](const ClientInputBuffer& b) {
- return b.capacity >= cfgSize;
- });
- if (i == clientInputBuffers.end()) {
- ALOGW("[%s] no input buffer large enough for the config "
- "(%zu bytes)",
- mName, config->size());
- return NO_MEMORY;
- }
- sp<MediaCodecBuffer> buffer = i->buffer;
- memcpy(buffer->base(), config->data(), config->size());
- buffer->setRange(0, config->size());
- buffer->meta()->clear();
- buffer->meta()->setInt64("timeUs", 0);
- buffer->meta()->setInt32("csd", 1);
- if (queueInputBufferInternal(buffer) != OK) {
- ALOGW("[%s] Error while queueing a flushed config",
- mName);
- return UNKNOWN_ERROR;
- }
- clientInputBuffers.erase(i);
- }
- } else if (oStreamFormat.value == C2BufferData::LINEAR &&
- (!prepend || prepend.value == PREPEND_HEADER_TO_NONE)) {
- sp<MediaCodecBuffer> buffer = clientInputBuffers.front().buffer;
- // WORKAROUND: Some apps expect CSD available without queueing
- // any input. Queue an empty buffer to get the CSD.
- buffer->setRange(0, 0);
- buffer->meta()->clear();
- buffer->meta()->setInt64("timeUs", 0);
- if (queueInputBufferInternal(buffer) != OK) {
- ALOGW("[%s] Error while queueing an empty buffer to get CSD",
- mName);
- return UNKNOWN_ERROR;
- }
- clientInputBuffers.pop_front();
+ std::list<std::unique_ptr<C2Work>> flushedConfigs;
+ mFlushedConfigs.lock()->swap(flushedConfigs);
+ if (!flushedConfigs.empty()) {
+ err = mComponent->queue(&flushedConfigs);
+ if (err != C2_OK) {
+ ALOGW("[%s] Error while queueing a flushed config", mName);
+ return UNKNOWN_ERROR;
}
}
+ if (oStreamFormat.value == C2BufferData::LINEAR &&
+ (!prepend || prepend.value == PREPEND_HEADER_TO_NONE)) {
+ sp<MediaCodecBuffer> buffer = clientInputBuffers.front().buffer;
+ // WORKAROUND: Some apps expect CSD available without queueing
+ // any input. Queue an empty buffer to get the CSD.
+ buffer->setRange(0, 0);
+ buffer->meta()->clear();
+ buffer->meta()->setInt64("timeUs", 0);
+ if (queueInputBufferInternal(buffer) != OK) {
+ ALOGW("[%s] Error while queueing an empty buffer to get CSD",
+ mName);
+ return UNKNOWN_ERROR;
+ }
+ clientInputBuffers.pop_front();
+ }
for (const ClientInputBuffer& clientInputBuffer: clientInputBuffers) {
mCallback->onInputBufferAvailable(
@@ -1396,27 +1372,36 @@ void CCodecBufferChannel::release() {
void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushedWork) {
ALOGV("[%s] flush", mName);
- {
- Mutexed<std::list<sp<ABuffer>>>::Locked configs(mFlushedConfigs);
- for (const std::unique_ptr<C2Work> &work : flushedWork) {
- if (!(work->input.flags & C2FrameData::FLAG_CODEC_CONFIG)) {
- continue;
- }
- if (work->input.buffers.empty()
- || work->input.buffers.front()->data().linearBlocks().empty()) {
- ALOGD("[%s] no linear codec config data found", mName);
- continue;
- }
- C2ReadView view =
- work->input.buffers.front()->data().linearBlocks().front().map().get();
- if (view.error() != C2_OK) {
- ALOGD("[%s] failed to map flushed codec config data: %d", mName, view.error());
- continue;
- }
- configs->push_back(ABuffer::CreateAsCopy(view.data(), view.capacity()));
- ALOGV("[%s] stashed flushed codec config data (size=%u)", mName, view.capacity());
- }
- }
+ std::list<std::unique_ptr<C2Work>> configs;
+ for (const std::unique_ptr<C2Work> &work : flushedWork) {
+ if (!(work->input.flags & C2FrameData::FLAG_CODEC_CONFIG)) {
+ continue;
+ }
+ if (work->input.buffers.empty()
+ || work->input.buffers.front() == nullptr
+ || work->input.buffers.front()->data().linearBlocks().empty()) {
+ ALOGD("[%s] no linear codec config data found", mName);
+ continue;
+ }
+ std::unique_ptr<C2Work> copy(new C2Work);
+ copy->input.flags = C2FrameData::flags_t(work->input.flags | C2FrameData::FLAG_DROP_FRAME);
+ copy->input.ordinal = work->input.ordinal;
+ copy->input.buffers.insert(
+ copy->input.buffers.begin(),
+ work->input.buffers.begin(),
+ work->input.buffers.end());
+ for (const std::unique_ptr<C2Param> &param : work->input.configUpdate) {
+ copy->input.configUpdate.push_back(C2Param::Copy(*param));
+ }
+ copy->input.infoBuffers.insert(
+ copy->input.infoBuffers.begin(),
+ work->input.infoBuffers.begin(),
+ work->input.infoBuffers.end());
+ copy->worklets.emplace_back(new C2Worklet);
+ configs.push_back(std::move(copy));
+ ALOGV("[%s] stashed flushed codec config data", mName);
+ }
+ mFlushedConfigs.lock()->swap(configs);
{
Mutexed<Input>::Locked input(mInput);
input->buffers->flush();
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.h b/media/codec2/sfplugin/CCodecBufferChannel.h
index 046c5c3c49..e2c9aaa287 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.h
+++ b/media/codec2/sfplugin/CCodecBufferChannel.h
@@ -277,7 +277,7 @@ private:
uint32_t outputDelay;
};
Mutexed<Output> mOutput;
- Mutexed<std::list<sp<ABuffer>>> mFlushedConfigs;
+ Mutexed<std::list<std::unique_ptr<C2Work>>> mFlushedConfigs;
std::atomic_uint64_t mFrameIndex;
std::atomic_uint64_t mFirstValidFrameIndex;
--
2.25.1

View File

@ -0,0 +1,121 @@
From bfa866666f0fb3e95755e5fb5d22a89c1fdd6767 Mon Sep 17 00:00:00 2001
From: David Stevens <stevensd@google.com>
Date: Tue, 20 Oct 2020 15:00:41 +0900
Subject: [PATCH 20/30] BufferPool: limit number of idle buffers in caches
Some systems have limits on the total number of graphics buffers that
can be allocated, not just the total size. When dealing with
particularly small buffers, the caches could end up retaining 1000s of
buffers. This change adds an additional eviction trigger based on the
number of idle cached buffers.
Bug: 170702290
Bug: 171553040
Test: android.video.cts.VideoEncoderDecoderTest on ARCVM
Change-Id: If3f4433ba1794ccb624b864a56619c8613a315f2
(cherry picked from commit 0f50e523ef1404f9afbaa7b919e2801e5d94012a)
Merged-In: If3f4433ba1794ccb624b864a56619c8613a315f2
---
media/bufferpool/2.0/AccessorImpl.cpp | 13 +++++++++----
media/bufferpool/2.0/AccessorImpl.h | 6 ++++++
media/bufferpool/2.0/BufferPoolClient.cpp | 12 ++++++++++--
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/media/bufferpool/2.0/AccessorImpl.cpp b/media/bufferpool/2.0/AccessorImpl.cpp
index 6111feafb9..1d2562e41d 100644
--- a/media/bufferpool/2.0/AccessorImpl.cpp
+++ b/media/bufferpool/2.0/AccessorImpl.cpp
@@ -39,6 +39,8 @@ namespace {
static constexpr size_t kMinAllocBytesForEviction = 1024*1024*15;
static constexpr size_t kMinBufferCountForEviction = 25;
+ static constexpr size_t kMaxUnusedBufferCount = 64;
+ static constexpr size_t kUnusedBufferCountTarget = kMaxUnusedBufferCount - 16;
static constexpr nsecs_t kEvictGranularityNs = 1000000000; // 1 sec
static constexpr nsecs_t kEvictDurationNs = 5000000000; // 5 secs
@@ -724,9 +726,11 @@ ResultStatus Accessor::Impl::BufferPool::addNewBuffer(
}
void Accessor::Impl::BufferPool::cleanUp(bool clearCache) {
- if (clearCache || mTimestampUs > mLastCleanUpUs + kCleanUpDurationUs) {
+ if (clearCache || mTimestampUs > mLastCleanUpUs + kCleanUpDurationUs ||
+ mStats.buffersNotInUse() > kMaxUnusedBufferCount) {
mLastCleanUpUs = mTimestampUs;
- if (mTimestampUs > mLastLogUs + kLogDurationUs) {
+ if (mTimestampUs > mLastLogUs + kLogDurationUs ||
+ mStats.buffersNotInUse() > kMaxUnusedBufferCount) {
mLastLogUs = mTimestampUs;
ALOGD("bufferpool2 %p : %zu(%zu size) total buffers - "
"%zu(%zu size) used buffers - %zu/%zu (recycle/alloc) - "
@@ -737,8 +741,9 @@ void Accessor::Impl::BufferPool::cleanUp(bool clearCache) {
mStats.mTotalFetches, mStats.mTotalTransfers);
}
for (auto freeIt = mFreeBuffers.begin(); freeIt != mFreeBuffers.end();) {
- if (!clearCache && (mStats.mSizeCached < kMinAllocBytesForEviction
- || mBuffers.size() < kMinBufferCountForEviction)) {
+ if (!clearCache && mStats.buffersNotInUse() <= kUnusedBufferCountTarget &&
+ (mStats.mSizeCached < kMinAllocBytesForEviction ||
+ mBuffers.size() < kMinBufferCountForEviction)) {
break;
}
auto it = mBuffers.find(*freeIt);
diff --git a/media/bufferpool/2.0/AccessorImpl.h b/media/bufferpool/2.0/AccessorImpl.h
index cd1b4d08c1..3d39941337 100644
--- a/media/bufferpool/2.0/AccessorImpl.h
+++ b/media/bufferpool/2.0/AccessorImpl.h
@@ -193,6 +193,12 @@ private:
: mSizeCached(0), mBuffersCached(0), mSizeInUse(0), mBuffersInUse(0),
mTotalAllocations(0), mTotalRecycles(0), mTotalTransfers(0), mTotalFetches(0) {}
+ /// # of currently unused buffers
+ size_t buffersNotInUse() const {
+ ALOG_ASSERT(mBuffersCached >= mBuffersInUse);
+ return mBuffersCached - mBuffersInUse;
+ }
+
/// A new buffer is allocated on an allocation request.
void onBufferAllocated(size_t allocSize) {
mSizeCached += allocSize;
diff --git a/media/bufferpool/2.0/BufferPoolClient.cpp b/media/bufferpool/2.0/BufferPoolClient.cpp
index 342fef6b9d..9308b8159b 100644
--- a/media/bufferpool/2.0/BufferPoolClient.cpp
+++ b/media/bufferpool/2.0/BufferPoolClient.cpp
@@ -32,6 +32,8 @@ namespace implementation {
static constexpr int64_t kReceiveTimeoutUs = 1000000; // 100ms
static constexpr int kPostMaxRetry = 3;
static constexpr int kCacheTtlUs = 1000000; // TODO: tune
+static constexpr size_t kMaxCachedBufferCount = 64;
+static constexpr size_t kCachedBufferCountTarget = kMaxCachedBufferCount - 16;
class BufferPoolClient::Impl
: public std::enable_shared_from_this<BufferPoolClient::Impl> {
@@ -136,6 +138,10 @@ private:
--mActive;
mLastChangeUs = getTimestampNow();
}
+
+ int cachedBufferCount() const {
+ return mBuffers.size() - mActive;
+ }
} mCache;
// FMQ - release notifier
@@ -668,10 +674,12 @@ bool BufferPoolClient::Impl::syncReleased(uint32_t messageId) {
// should have mCache.mLock
void BufferPoolClient::Impl::evictCaches(bool clearCache) {
int64_t now = getTimestampNow();
- if (now >= mLastEvictCacheUs + kCacheTtlUs || clearCache) {
+ if (now >= mLastEvictCacheUs + kCacheTtlUs ||
+ clearCache || mCache.cachedBufferCount() > kMaxCachedBufferCount) {
size_t evicted = 0;
for (auto it = mCache.mBuffers.begin(); it != mCache.mBuffers.end();) {
- if (!it->second->hasCache() && (it->second->expire() || clearCache)) {
+ if (!it->second->hasCache() && (it->second->expire() ||
+ clearCache || mCache.cachedBufferCount() > kCachedBufferCountTarget)) {
it = mCache.mBuffers.erase(it);
++evicted;
} else {
--
2.25.1

View File

@ -0,0 +1,37 @@
From 7e08eb2a701487a4b56b449fd5758b8ab5cfce90 Mon Sep 17 00:00:00 2001
From: Taehwan Kim <t_h.kim@samsung.com>
Date: Thu, 17 Sep 2020 12:26:40 +0900
Subject: [PATCH 21/30] CCodec: fix underflow issue on handleImageData
the logic is assumed that gralloc does assume a contiguous mapping
at GraphicView2MediaImageConverter() in Codec2Buffer.
if it doesn't, underflow could happen because
type of variable is unsigned.
Bug: 168757280
Change-Id: I04e13d0680af74e76d96d3ab10a549f6368205cf
Signed-off-by: Taehwan Kim <t_h.kim@samsung.com>
(cherry picked from commit fd9b809147b78330d1db7ec17e200071e779fd46)
---
media/codec2/sfplugin/CCodecBuffers.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index bddaa9f22b..692da584ce 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -91,7 +91,9 @@ void CCodecBuffers::handleImageData(const sp<Codec2Buffer> &buffer) {
newFormat->setInt32(KEY_STRIDE, stride);
ALOGD("[%s] updating stride = %d", mName, stride);
if (img->mNumPlanes > 1 && stride > 0) {
- int32_t vstride = (img->mPlane[1].mOffset - img->mPlane[0].mOffset) / stride;
+ int64_t offsetDelta =
+ (int64_t)img->mPlane[1].mOffset - (int64_t)img->mPlane[0].mOffset;
+ int32_t vstride = int32_t(offsetDelta / stride);
newFormat->setInt32(KEY_SLICE_HEIGHT, vstride);
ALOGD("[%s] updating vstride = %d", mName, vstride);
}
--
2.25.1

View File

@ -0,0 +1,139 @@
From 73517d3e56b2ee0eb171af1e68fa1c729eadd564 Mon Sep 17 00:00:00 2001
From: Ray Essick <essick@google.com>
Date: Mon, 14 Sep 2020 17:05:07 -0700
Subject: [PATCH 22/30] OMX Opus decoder omits sample rate / channel count
The OMX Opus decoder doesn't signal back the channel/samplerate info to
the framework, leading to a CTS failure when checking required values.
Based on an AOSP patch provided by denis.hsu@mediatek.com
Bug: 166695414
Test: CtsMediaTestCases android.media.cts.DecoderTest#testDecodeOpusChannelsAndRates
Change-Id: If710405caea4be6336b4aec3aa0c051ad3c0fe95
(cherry picked from commit 74d4b70841b2aa3154b10b82ebcc6737d1d36a6d)
---
media/libstagefright/ACodec.cpp | 26 +++++++++++++++++++
.../codecs/opus/dec/SoftOpus.cpp | 11 +++++---
.../libstagefright/codecs/opus/dec/SoftOpus.h | 2 ++
.../include/media/stagefright/ACodec.h | 1 +
4 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index f843c7f45f..7ea444dc77 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -2247,6 +2247,12 @@ status_t ACodec::configureCodec(
}
err = setupG711Codec(encoder, sampleRate, numChannels);
}
+ } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_OPUS)) {
+ int32_t numChannels = 1, sampleRate = 48000;
+ if (msg->findInt32("channel-count", &numChannels) &&
+ msg->findInt32("sample-rate", &sampleRate)) {
+ err = setupOpusCodec(encoder, sampleRate, numChannels);
+ }
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_FLAC)) {
// numChannels needs to be set to properly communicate PCM values.
int32_t numChannels = 2, sampleRate = 44100, compressionLevel = -1;
@@ -3120,6 +3126,26 @@ status_t ACodec::setupG711Codec(bool encoder, int32_t sampleRate, int32_t numCha
kPortIndexInput, sampleRate, numChannels);
}
+status_t ACodec::setupOpusCodec(bool encoder, int32_t sampleRate, int32_t numChannels) {
+ if (encoder) {
+ return INVALID_OPERATION;
+ }
+ OMX_AUDIO_PARAM_ANDROID_OPUSTYPE def;
+ InitOMXParams(&def);
+ def.nPortIndex = kPortIndexInput;
+ status_t err = mOMXNode->getParameter(
+ (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidOpus, &def, sizeof(def));
+ if (err != OK) {
+ ALOGE("setupOpusCodec(): Error %d getting OMX_IndexParamAudioAndroidOpus parameter", err);
+ return err;
+ }
+ def.nSampleRate = sampleRate;
+ def.nChannels = numChannels;
+ err = mOMXNode->setParameter(
+ (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidOpus, &def, sizeof(def));
+ return err;
+}
+
status_t ACodec::setupFlacCodec(
bool encoder, int32_t numChannels, int32_t sampleRate, int32_t compressionLevel,
AudioEncoding encoding) {
diff --git a/media/libstagefright/codecs/opus/dec/SoftOpus.cpp b/media/libstagefright/codecs/opus/dec/SoftOpus.cpp
index 4f61aa8be2..5bb1879da1 100644
--- a/media/libstagefright/codecs/opus/dec/SoftOpus.cpp
+++ b/media/libstagefright/codecs/opus/dec/SoftOpus.cpp
@@ -58,6 +58,8 @@ SoftOpus::SoftOpus(
mInputBufferCount(0),
mDecoder(NULL),
mHeader(NULL),
+ mNumChannels(1),
+ mSamplingRate(kRate),
mCodecDelay(0),
mSeekPreRoll(0),
mAnchorTimeUs(0),
@@ -169,11 +171,11 @@ OMX_ERRORTYPE SoftOpus::internalGetParameter(
}
opusParams->nAudioBandWidth = 0;
- opusParams->nSampleRate = kRate;
+ opusParams->nSampleRate = mSamplingRate;
opusParams->nBitRate = 0;
if (!isConfigured()) {
- opusParams->nChannels = 1;
+ opusParams->nChannels = mNumChannels;
} else {
opusParams->nChannels = mHeader->channels;
}
@@ -274,7 +276,8 @@ OMX_ERRORTYPE SoftOpus::internalSetParameter(
if (opusParams->nPortIndex != 0) {
return OMX_ErrorUndefined;
}
-
+ mNumChannels = opusParams->nChannels;
+ mSamplingRate = opusParams->nSampleRate;
return OMX_ErrorNone;
}
@@ -496,6 +499,8 @@ void SoftOpus::onQueueFilled(OMX_U32 /* portIndex */) {
*(reinterpret_cast<int64_t*>(inHeader->pBuffer +
inHeader->nOffset)),
kRate);
+ mSamplingRate = kRate;
+ mNumChannels = mHeader->channels;
notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
mOutputPortSettingsChange = AWAITING_DISABLED;
}
diff --git a/media/libstagefright/codecs/opus/dec/SoftOpus.h b/media/libstagefright/codecs/opus/dec/SoftOpus.h
index 91cafa14c7..00058c8212 100644
--- a/media/libstagefright/codecs/opus/dec/SoftOpus.h
+++ b/media/libstagefright/codecs/opus/dec/SoftOpus.h
@@ -70,6 +70,8 @@ private:
OpusMSDecoder *mDecoder;
OpusHeader *mHeader;
+ int32_t mNumChannels;
+ int32_t mSamplingRate;
int64_t mCodecDelay;
int64_t mSeekPreRoll;
int64_t mSamplesToDiscard;
diff --git a/media/libstagefright/include/media/stagefright/ACodec.h b/media/libstagefright/include/media/stagefright/ACodec.h
index 83e92b9f43..105e7f7f98 100644
--- a/media/libstagefright/include/media/stagefright/ACodec.h
+++ b/media/libstagefright/include/media/stagefright/ACodec.h
@@ -499,6 +499,7 @@ private:
status_t setupAMRCodec(bool encoder, bool isWAMR, int32_t bitRate);
status_t setupG711Codec(bool encoder, int32_t sampleRate, int32_t numChannels);
+ status_t setupOpusCodec(bool encoder, int32_t sampleRate, int32_t numChannels);
status_t setupFlacCodec(
bool encoder, int32_t numChannels, int32_t sampleRate, int32_t compressionLevel,
AudioEncoding encoding);
--
2.25.1

View File

@ -0,0 +1,138 @@
From bf69673517df3b7c1f90cc07621f8af998310110 Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Tue, 22 Sep 2020 18:44:47 -0700
Subject: [PATCH 23/30] ACodec: submit extra output metadata buffers if in low
latency mode
Bug: 166250452
Test: atest CtsMediaTestCases:DecoderTest
Merged-In: I134a16a70e8ac94dbd4f505c0a5553a3ca0f87a2
Change-Id: I134a16a70e8ac94dbd4f505c0a5553a3ca0f87a2
(cherry picked from commit 7e0bb3845b3059c0ee5bd33e506368828cca40fe)
---
media/libstagefright/ACodec.cpp | 39 ++++++++++++++++++-
.../include/media/stagefright/ACodec.h | 2 +
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 7ea444dc77..0f8cd39edb 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -279,6 +279,13 @@ protected:
void postFillThisBuffer(BufferInfo *info);
+ void maybePostExtraOutputMetadataBufferRequest() {
+ if (!mPendingExtraOutputMetadataBufferRequest) {
+ (new AMessage(kWhatSubmitExtraOutputMetadataBuffer, mCodec))->post();
+ mPendingExtraOutputMetadataBufferRequest = true;
+ }
+ }
+
private:
// Handles an OMX message. Returns true iff message was handled.
bool onOMXMessage(const sp<AMessage> &msg);
@@ -302,6 +309,8 @@ private:
void getMoreInputDataIfPossible();
+ bool mPendingExtraOutputMetadataBufferRequest;
+
DISALLOW_EVIL_CONSTRUCTORS(BaseState);
};
@@ -555,6 +564,7 @@ ACodec::ACodec()
mShutdownInProgress(false),
mExplicitShutdown(false),
mIsLegacyVP9Decoder(false),
+ mIsLowLatency(false),
mEncoderDelay(0),
mEncoderPadding(0),
mRotationDegrees(0),
@@ -2425,6 +2435,7 @@ status_t ACodec::setLowLatency(int32_t lowLatency) {
if (err != OK) {
ALOGE("decoder can not set low-latency to %d (err %d)", lowLatency, err);
}
+ mIsLowLatency = (lowLatency && err == OK);
return err;
}
@@ -5785,7 +5796,8 @@ status_t ACodec::requestIDRFrame() {
ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState)
: AState(parentState),
- mCodec(codec) {
+ mCodec(codec),
+ mPendingExtraOutputMetadataBufferRequest(false) {
}
ACodec::BaseState::PortMode ACodec::BaseState::getPortMode(
@@ -5886,6 +5898,21 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) {
break;
}
+ case kWhatSubmitExtraOutputMetadataBuffer: {
+ mPendingExtraOutputMetadataBufferRequest = false;
+ if (getPortMode(kPortIndexOutput) == RESUBMIT_BUFFERS && mCodec->mIsLowLatency) {
+ // Decoders often need more than one output buffer to be
+ // submitted before processing a single input buffer.
+ // For low latency codecs, we don't want to wait for more input
+ // to be queued to get those output buffers submitted.
+ if (mCodec->submitOutputMetadataBuffer() == OK
+ && mCodec->mMetadataBuffersToSubmit > 0) {
+ maybePostExtraOutputMetadataBufferRequest();
+ }
+ }
+ break;
+ }
+
default:
return false;
}
@@ -6242,7 +6269,12 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
(outputMode == FREE_BUFFERS ? "FREE" :
outputMode == KEEP_BUFFERS ? "KEEP" : "RESUBMIT"));
if (outputMode == RESUBMIT_BUFFERS) {
- mCodec->submitOutputMetadataBuffer();
+ status_t err = mCodec->submitOutputMetadataBuffer();
+ if (mCodec->mIsLowLatency
+ && err == OK
+ && mCodec->mMetadataBuffersToSubmit > 0) {
+ maybePostExtraOutputMetadataBufferRequest();
+ }
}
}
info->checkReadFence("onInputBufferFilled");
@@ -7388,6 +7420,9 @@ void ACodec::ExecutingState::submitOutputMetaBuffers() {
break;
}
}
+ if (mCodec->mIsLowLatency) {
+ maybePostExtraOutputMetadataBufferRequest();
+ }
// *** NOTE: THE FOLLOWING WORKAROUND WILL BE REMOVED ***
mCodec->signalSubmitOutputMetadataBufferIfEOS_workaround();
diff --git a/media/libstagefright/include/media/stagefright/ACodec.h b/media/libstagefright/include/media/stagefright/ACodec.h
index 105e7f7f98..8ef92783ec 100644
--- a/media/libstagefright/include/media/stagefright/ACodec.h
+++ b/media/libstagefright/include/media/stagefright/ACodec.h
@@ -147,6 +147,7 @@ private:
kWhatReleaseCodecInstance = 'relC',
kWhatForceStateTransition = 'fstt',
kWhatCheckIfStuck = 'Cstk',
+ kWhatSubmitExtraOutputMetadataBuffer = 'sbxo',
};
enum {
@@ -272,6 +273,7 @@ private:
bool mShutdownInProgress;
bool mExplicitShutdown;
bool mIsLegacyVP9Decoder;
+ bool mIsLowLatency;
// If "mKeepComponentAllocated" we only transition back to Loaded state
// and do not release the component instance.
--
2.25.1

View File

@ -0,0 +1,39 @@
From 20517633099c124e1c639fab9b693c32875c7fba Mon Sep 17 00:00:00 2001
From: Paras Nagda <pnagda@codeaurora.org>
Date: Tue, 27 Oct 2020 13:01:47 +0530
Subject: [PATCH 24/30] NuPlayerRenderer: Reset negative media time to zero
Reset negative media time to zero before call is made to
Mediaclock's setStartingTimeMedia().
Test:run android.mediastress.cts.HEVCR1080pAacLongPlayerTest#testPlay00 on gsi
Bug: 170621757
Bug: 171945667
Bug: 170797642
Bug: 171562715
Bug: 171850618
Change-Id: I2c405007b38229038119760423156bd53a2701c0
---
media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index c30f048c2d..7e8fe45121 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -922,6 +922,11 @@ size_t NuPlayer::Renderer::fillAudioBuffer(void *buffer, size_t size) {
firstEntry = false;
int64_t mediaTimeUs;
CHECK(entry->mBuffer->meta()->findInt64("timeUs", &mediaTimeUs));
+ if (mediaTimeUs < 0) {
+ ALOGD("fillAudioBuffer: reset negative media time %.2f secs to zero",
+ mediaTimeUs / 1E6);
+ mediaTimeUs = 0;
+ }
ALOGV("fillAudioBuffer: rendering audio at media time %.2f secs", mediaTimeUs / 1E6);
setAudioFirstAnchorTimeIfNeeded_l(mediaTimeUs);
}
--
2.25.1

View File

@ -0,0 +1,68 @@
From 3e4bfa2b9f1516d70f117c16abfa7bb7b085faf5 Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Thu, 12 Nov 2020 11:14:42 -0800
Subject: [PATCH 25/30] C2OMXNode: read delay from component to determine
buffer count
Bug: 169398817
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Test: atest CtsMediaTestCases:VideoEncoderTest
Change-Id: I76a3411addd83108d2da2c8f74df55acab03a365
(cherry picked from commit 414eb15c3c6cd7e1677245508fd23899bef01feb)
---
media/codec2/sfplugin/C2OMXNode.cpp | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/media/codec2/sfplugin/C2OMXNode.cpp b/media/codec2/sfplugin/C2OMXNode.cpp
index c7588e9a51..dd1f4858a5 100644
--- a/media/codec2/sfplugin/C2OMXNode.cpp
+++ b/media/codec2/sfplugin/C2OMXNode.cpp
@@ -25,6 +25,7 @@
#include <C2AllocatorGralloc.h>
#include <C2BlockInternal.h>
#include <C2Component.h>
+#include <C2Config.h>
#include <C2PlatformSupport.h>
#include <OMX_Component.h>
@@ -44,6 +45,8 @@ namespace android {
namespace {
+constexpr OMX_U32 kPortIndexInput = 0;
+
class Buffer2D : public C2Buffer {
public:
explicit Buffer2D(C2ConstGraphicBlock block) : C2Buffer({ block }) {}
@@ -200,11 +203,27 @@ status_t C2OMXNode::getParameter(OMX_INDEXTYPE index, void *params, size_t size)
return BAD_VALUE;
}
OMX_PARAM_PORTDEFINITIONTYPE *pDef = (OMX_PARAM_PORTDEFINITIONTYPE *)params;
- // TODO: read these from intf()
+ if (pDef->nPortIndex != kPortIndexInput) {
+ break;
+ }
+
pDef->nBufferCountActual = 16;
+
+ std::shared_ptr<Codec2Client::Component> comp = mComp.lock();
+ C2PortActualDelayTuning::input inputDelay(0);
+ C2ActualPipelineDelayTuning pipelineDelay(0);
+ c2_status_t c2err = comp->query(
+ {&inputDelay, &pipelineDelay}, {}, C2_DONT_BLOCK, nullptr);
+ if (c2err == C2_OK || c2err == C2_BAD_INDEX) {
+ pDef->nBufferCountActual = 4;
+ pDef->nBufferCountActual += (inputDelay ? inputDelay.value : 0u);
+ pDef->nBufferCountActual += (pipelineDelay ? pipelineDelay.value : 0u);
+ }
+
pDef->eDomain = OMX_PortDomainVideo;
pDef->format.video.nFrameWidth = mWidth;
pDef->format.video.nFrameHeight = mHeight;
+ pDef->format.video.eColorFormat = OMX_COLOR_FormatAndroidOpaque;
err = OK;
break;
}
--
2.25.1

View File

@ -0,0 +1,37 @@
From 9a6c5d750f7060922c4a9675f45df15310e75d5b Mon Sep 17 00:00:00 2001
From: Sungtak Lee <taklee@google.com>
Date: Sun, 8 Nov 2020 00:07:27 -0800
Subject: [PATCH 26/30] CCodec: Increase max linear buffer size for 8K video
Increase max linear buffer size to fit a 8K video frame.
Bug: 172190459
Bug: 173683705
Bug: 173725276
Bug: 173768931
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Change-Id: I47cfc2718447ac51be0f90638d7e7055fd7d95ba
(cherry picked from commit 5692578e0d3ff5eb273a63ee9a4f07b719508973)
---
media/codec2/sfplugin/CCodecBuffers.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/media/codec2/sfplugin/CCodecBuffers.h b/media/codec2/sfplugin/CCodecBuffers.h
index 4772ab53eb..c383a7ce1a 100644
--- a/media/codec2/sfplugin/CCodecBuffers.h
+++ b/media/codec2/sfplugin/CCodecBuffers.h
@@ -33,8 +33,8 @@ class MemoryDealer;
class SkipCutBuffer;
constexpr size_t kLinearBufferSize = 1048576;
-// This can fit 4K RGBA frame, and most likely client won't need more than this.
-constexpr size_t kMaxLinearBufferSize = 4096 * 2304 * 4;
+// This can fit an 8K frame.
+constexpr size_t kMaxLinearBufferSize = 7680 * 4320 * 2;
/**
* Base class for representation of buffers at one port.
--
2.25.1

View File

@ -0,0 +1,56 @@
From 55aa1d77e5fa44434fa4ec7976bd3d4ef0bd4629 Mon Sep 17 00:00:00 2001
From: Lajos Molnar <lajos@google.com>
Date: Wed, 12 Aug 2020 15:56:31 -0700
Subject: [PATCH 27/30] omx: calculate nodePrefix only for components listed in
IOmx
Also make common prefix matching case insensitive.
Bug: 162578527
Change-Id: Iaf66967fd519e0c3eabb8f0c320b8c7e7fd03497
(cherry picked from commit 42f653bd87672f3427bdb522f46c55502e6d20d1)
---
media/libstagefright/omx/1.0/OmxStore.cpp | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/media/libstagefright/omx/1.0/OmxStore.cpp b/media/libstagefright/omx/1.0/OmxStore.cpp
index 67f478ead0..b5c116656f 100644
--- a/media/libstagefright/omx/1.0/OmxStore.cpp
+++ b/media/libstagefright/omx/1.0/OmxStore.cpp
@@ -54,6 +54,24 @@ OmxStore::OmxStore(
});
}
+ if (!nodes.empty()) {
+ auto anyNode = nodes.cbegin();
+ std::string::const_iterator first = anyNode->cbegin();
+ std::string::const_iterator last = anyNode->cend();
+ for (const std::string &name : nodes) {
+ std::string::const_iterator it1 = first;
+ for (std::string::const_iterator it2 = name.cbegin();
+ it1 != last && it2 != name.cend() && tolower(*it1) == tolower(*it2);
+ ++it1, ++it2) {
+ }
+ last = it1;
+ }
+ mPrefix = std::string(first, last);
+ LOG(INFO) << "omx common prefix: '" << mPrefix.c_str() << "'";
+ } else {
+ LOG(INFO) << "omx common prefix: no nodes";
+ }
+
MediaCodecsXmlParser parser;
parser.parseXmlFilesInSearchDirs(xmlNames, searchDirs);
if (profilingResultsXmlPath != nullptr) {
@@ -112,8 +130,6 @@ OmxStore::OmxStore(
mRoleList[i] = std::move(role);
++i;
}
-
- mPrefix = parser.getCommonPrefix();
}
OmxStore::~OmxStore() {
--
2.25.1

View File

@ -0,0 +1,126 @@
From 7fda1fcb614eab32aec99713919c2e915cca1ccd Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Wed, 25 Nov 2020 10:12:32 -0800
Subject: [PATCH 28/30] C2AllocatorBlob: allow multiple maps
Test: CtsMediaTestCases:DecoderTest
Test: CtsMediaV2TestCases:CodecDecoderTest
Test: VtsHalMediaC2V1_0TargetVideoDecTest
Test: VtsHalMediaC2V1_0TargetVideoEncTest
Test: VtsHalMediaC2V1_0TargetAudioDecTest
Test: VtsHalMediaC2V1_0TargetAudioEncTest
Bug: 173730101
Change-Id: Ief24371e19c8e957ea218ffd9bbfd516353b0cc9
(cherry picked from d04f34cdd8c7ce1a3249a9fbfdd18ca989bb1685)
---
media/codec2/vndk/C2AllocatorBlob.cpp | 72 ++++++++++++++++++++++++---
1 file changed, 66 insertions(+), 6 deletions(-)
diff --git a/media/codec2/vndk/C2AllocatorBlob.cpp b/media/codec2/vndk/C2AllocatorBlob.cpp
index 50c9e59af8..aa054998f8 100644
--- a/media/codec2/vndk/C2AllocatorBlob.cpp
+++ b/media/codec2/vndk/C2AllocatorBlob.cpp
@@ -17,6 +17,8 @@
// #define LOG_NDEBUG 0
#define LOG_TAG "C2AllocatorBlob"
+#include <set>
+
#include <C2AllocatorBlob.h>
#include <C2PlatformSupport.h>
@@ -67,6 +69,10 @@ public:
private:
const std::shared_ptr<C2GraphicAllocation> mGraphicAllocation;
const C2Allocator::id_t mAllocatorId;
+
+ std::mutex mMapLock;
+ std::multiset<std::pair<size_t, size_t>> mMappedOffsetSize;
+ uint8_t *mMappedAddr;
};
C2AllocationBlob::C2AllocationBlob(
@@ -74,20 +80,74 @@ C2AllocationBlob::C2AllocationBlob(
C2Allocator::id_t allocatorId)
: C2LinearAllocation(capacity),
mGraphicAllocation(std::move(graphicAllocation)),
- mAllocatorId(allocatorId) {}
+ mAllocatorId(allocatorId),
+ mMappedAddr(nullptr) {}
-C2AllocationBlob::~C2AllocationBlob() {}
+C2AllocationBlob::~C2AllocationBlob() {
+ if (mMappedAddr) {
+ C2Rect rect(capacity(), kLinearBufferHeight);
+ mGraphicAllocation->unmap(&mMappedAddr, rect, nullptr);
+ }
+}
c2_status_t C2AllocationBlob::map(size_t offset, size_t size, C2MemoryUsage usage,
C2Fence* fence, void** addr /* nonnull */) {
+ *addr = nullptr;
+ if (size > capacity() || offset > capacity() || offset > capacity() - size) {
+ ALOGV("C2AllocationBlob: map: bad offset / size: offset=%zu size=%zu capacity=%u",
+ offset, size, capacity());
+ return C2_BAD_VALUE;
+ }
+ std::unique_lock<std::mutex> lock(mMapLock);
+ if (mMappedAddr) {
+ *addr = mMappedAddr + offset;
+ mMappedOffsetSize.insert({offset, size});
+ ALOGV("C2AllocationBlob: mapped from existing mapping: offset=%zu size=%zu capacity=%u",
+ offset, size, capacity());
+ return C2_OK;
+ }
C2PlanarLayout layout;
- C2Rect rect = C2Rect(size, kLinearBufferHeight).at(offset, 0u);
- return mGraphicAllocation->map(rect, usage, fence, &layout, reinterpret_cast<uint8_t**>(addr));
+ C2Rect rect = C2Rect(capacity(), kLinearBufferHeight);
+ c2_status_t err = mGraphicAllocation->map(rect, usage, fence, &layout, &mMappedAddr);
+ if (err != C2_OK) {
+ ALOGV("C2AllocationBlob: map failed: offset=%zu size=%zu capacity=%u err=%d",
+ offset, size, capacity(), err);
+ mMappedAddr = nullptr;
+ return err;
+ }
+ *addr = mMappedAddr + offset;
+ mMappedOffsetSize.insert({offset, size});
+ ALOGV("C2AllocationBlob: new map succeeded: offset=%zu size=%zu capacity=%u",
+ offset, size, capacity());
+ return C2_OK;
}
c2_status_t C2AllocationBlob::unmap(void* addr, size_t size, C2Fence* fenceFd) {
- C2Rect rect(size, kLinearBufferHeight);
- return mGraphicAllocation->unmap(reinterpret_cast<uint8_t**>(&addr), rect, fenceFd);
+ std::unique_lock<std::mutex> lock(mMapLock);
+ uint8_t *u8Addr = static_cast<uint8_t *>(addr);
+ if (u8Addr < mMappedAddr || mMappedAddr + capacity() < u8Addr + size) {
+ ALOGV("C2AllocationBlob: unmap: Bad addr / size: addr=%p size=%zu capacity=%u",
+ addr, size, capacity());
+ return C2_BAD_VALUE;
+ }
+ auto it = mMappedOffsetSize.find(std::make_pair(u8Addr - mMappedAddr, size));
+ if (it == mMappedOffsetSize.end()) {
+ ALOGV("C2AllocationBlob: unrecognized map: addr=%p size=%zu capacity=%u",
+ addr, size, capacity());
+ return C2_BAD_VALUE;
+ }
+ mMappedOffsetSize.erase(it);
+ if (!mMappedOffsetSize.empty()) {
+ ALOGV("C2AllocationBlob: still maintain mapping: addr=%p size=%zu capacity=%u",
+ addr, size, capacity());
+ return C2_OK;
+ }
+ C2Rect rect(capacity(), kLinearBufferHeight);
+ c2_status_t err = mGraphicAllocation->unmap(&mMappedAddr, rect, fenceFd);
+ ALOGV("C2AllocationBlob: last unmap: addr=%p size=%zu capacity=%u err=%d",
+ addr, size, capacity(), err);
+ mMappedAddr = nullptr;
+ return err;
}
/* ====================================== BLOB ALLOCATOR ====================================== */
--
2.25.1

View File

@ -0,0 +1,546 @@
From 607c1d606efd9f955ad7545dbfdaf38450c5ce20 Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Thu, 3 Dec 2020 11:07:58 -0800
Subject: [PATCH 29/30] CCodec: fix ByteBuffer mode image
- Set offset to (0,0) of Y plane.
- Fix wrapping criteria.
Bug: 169379476
Test: atest CtsMediaTestCases -- --module-arg CtsMediaTestCases:size:small
Test: atest ccodec_unit_test
Change-Id: Ic7e074ddaef277833707363b0b9fecfe210bd57f
(cherry picked from commit 2eb063152f67e886472ed42c07f3634a5eb63f19)
---
media/codec2/sfplugin/CCodecBuffers.cpp | 3 +
media/codec2/sfplugin/Codec2Buffer.cpp | 14 +-
.../sfplugin/tests/CCodecBuffers_test.cpp | 450 +++++++++++++++++-
3 files changed, 456 insertions(+), 11 deletions(-)
diff --git a/media/codec2/sfplugin/CCodecBuffers.cpp b/media/codec2/sfplugin/CCodecBuffers.cpp
index 692da584ce..566a18fbee 100644
--- a/media/codec2/sfplugin/CCodecBuffers.cpp
+++ b/media/codec2/sfplugin/CCodecBuffers.cpp
@@ -96,6 +96,9 @@ void CCodecBuffers::handleImageData(const sp<Codec2Buffer> &buffer) {
int32_t vstride = int32_t(offsetDelta / stride);
newFormat->setInt32(KEY_SLICE_HEIGHT, vstride);
ALOGD("[%s] updating vstride = %d", mName, vstride);
+ buffer->setRange(
+ img->mPlane[0].mOffset,
+ buffer->size() - img->mPlane[0].mOffset);
}
}
setFormat(newFormat);
diff --git a/media/codec2/sfplugin/Codec2Buffer.cpp b/media/codec2/sfplugin/Codec2Buffer.cpp
index 25e7da9206..19414a0a0c 100644
--- a/media/codec2/sfplugin/Codec2Buffer.cpp
+++ b/media/codec2/sfplugin/Codec2Buffer.cpp
@@ -276,20 +276,22 @@ public:
int32_t planeSize = 0;
for (uint32_t i = 0; i < layout.numPlanes; ++i) {
const C2PlaneInfo &plane = layout.planes[i];
- ssize_t minOffset = plane.minOffset(mWidth, mHeight);
- ssize_t maxOffset = plane.maxOffset(mWidth, mHeight);
+ int64_t planeStride = std::abs(plane.rowInc / plane.colInc);
+ ssize_t minOffset = plane.minOffset(
+ mWidth / plane.colSampling, mHeight / plane.rowSampling);
+ ssize_t maxOffset = plane.maxOffset(
+ mWidth / plane.colSampling, mHeight / plane.rowSampling);
if (minPtr > mView.data()[i] + minOffset) {
minPtr = mView.data()[i] + minOffset;
}
if (maxPtr < mView.data()[i] + maxOffset) {
maxPtr = mView.data()[i] + maxOffset;
}
- planeSize += std::abs(plane.rowInc) * align(mHeight, 64)
- / plane.rowSampling / plane.colSampling
- * divUp(mAllocatedDepth, 8u);
+ planeSize += planeStride * divUp(mAllocatedDepth, 8u)
+ * align(mHeight, 64) / plane.rowSampling;
}
- if ((maxPtr - minPtr + 1) <= planeSize) {
+ if (minPtr == mView.data()[0] && (maxPtr - minPtr + 1) <= planeSize) {
// FIXME: this is risky as reading/writing data out of bound results
// in an undefined behavior, but gralloc does assume a
// contiguous mapping
diff --git a/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp b/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp
index 5bee605276..ad8f6e555b 100644
--- a/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp
+++ b/media/codec2/sfplugin/tests/CCodecBuffers_test.cpp
@@ -18,22 +18,31 @@
#include <gtest/gtest.h>
+#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/MediaCodecConstants.h>
+#include <C2BlockInternal.h>
#include <C2PlatformSupport.h>
namespace android {
+static std::shared_ptr<RawGraphicOutputBuffers> GetRawGraphicOutputBuffers(
+ int32_t width, int32_t height) {
+ std::shared_ptr<RawGraphicOutputBuffers> buffers =
+ std::make_shared<RawGraphicOutputBuffers>("test");
+ sp<AMessage> format{new AMessage};
+ format->setInt32(KEY_WIDTH, width);
+ format->setInt32(KEY_HEIGHT, height);
+ buffers->setFormat(format);
+ return buffers;
+}
+
TEST(RawGraphicOutputBuffersTest, ChangeNumSlots) {
constexpr int32_t kWidth = 3840;
constexpr int32_t kHeight = 2160;
std::shared_ptr<RawGraphicOutputBuffers> buffers =
- std::make_shared<RawGraphicOutputBuffers>("test");
- sp<AMessage> format{new AMessage};
- format->setInt32("width", kWidth);
- format->setInt32("height", kHeight);
- buffers->setFormat(format);
+ GetRawGraphicOutputBuffers(kWidth, kHeight);
std::shared_ptr<C2BlockPool> pool;
ASSERT_EQ(OK, GetCodec2BlockPool(C2BlockPool::BASIC_GRAPHIC, nullptr, &pool));
@@ -96,4 +105,435 @@ TEST(RawGraphicOutputBuffersTest, ChangeNumSlots) {
}
}
+class TestGraphicAllocation : public C2GraphicAllocation {
+public:
+ TestGraphicAllocation(
+ uint32_t width,
+ uint32_t height,
+ const C2PlanarLayout &layout,
+ size_t capacity,
+ std::vector<size_t> offsets)
+ : C2GraphicAllocation(width, height),
+ mLayout(layout),
+ mMemory(capacity, 0xAA),
+ mOffsets(offsets) {
+ }
+
+ c2_status_t map(
+ C2Rect rect, C2MemoryUsage usage, C2Fence *fence,
+ C2PlanarLayout *layout, uint8_t **addr) override {
+ (void)rect;
+ (void)usage;
+ (void)fence;
+ *layout = mLayout;
+ for (size_t i = 0; i < mLayout.numPlanes; ++i) {
+ addr[i] = mMemory.data() + mOffsets[i];
+ }
+ return C2_OK;
+ }
+
+ c2_status_t unmap(uint8_t **, C2Rect, C2Fence *) override { return C2_OK; }
+
+ C2Allocator::id_t getAllocatorId() const override { return -1; }
+
+ const C2Handle *handle() const override { return nullptr; }
+
+ bool equals(const std::shared_ptr<const C2GraphicAllocation> &other) const override {
+ return other.get() == this;
+ }
+
+private:
+ C2PlanarLayout mLayout;
+ std::vector<uint8_t> mMemory;
+ std::vector<uint8_t *> mAddr;
+ std::vector<size_t> mOffsets;
+};
+
+class LayoutTest : public ::testing::TestWithParam<std::tuple<bool, std::string, bool, int32_t>> {
+private:
+ static C2PlanarLayout YUVPlanarLayout(int32_t stride) {
+ C2PlanarLayout layout = {
+ C2PlanarLayout::TYPE_YUV,
+ 3, /* numPlanes */
+ 3, /* rootPlanes */
+ {}, /* planes --- to be filled below */
+ };
+ layout.planes[C2PlanarLayout::PLANE_Y] = {
+ C2PlaneInfo::CHANNEL_Y,
+ 1, /* colInc */
+ stride, /* rowInc */
+ 1, /* colSampling */
+ 1, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_Y, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_U] = {
+ C2PlaneInfo::CHANNEL_CB,
+ 1, /* colInc */
+ stride / 2, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_U, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_V] = {
+ C2PlaneInfo::CHANNEL_CR,
+ 1, /* colInc */
+ stride / 2, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_V, /* rootIx */
+ 0, /* offset */
+ };
+ return layout;
+ }
+
+ static C2PlanarLayout YUVSemiPlanarLayout(int32_t stride) {
+ C2PlanarLayout layout = {
+ C2PlanarLayout::TYPE_YUV,
+ 3, /* numPlanes */
+ 2, /* rootPlanes */
+ {}, /* planes --- to be filled below */
+ };
+ layout.planes[C2PlanarLayout::PLANE_Y] = {
+ C2PlaneInfo::CHANNEL_Y,
+ 1, /* colInc */
+ stride, /* rowInc */
+ 1, /* colSampling */
+ 1, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_Y, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_U] = {
+ C2PlaneInfo::CHANNEL_CB,
+ 2, /* colInc */
+ stride, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_U, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_V] = {
+ C2PlaneInfo::CHANNEL_CR,
+ 2, /* colInc */
+ stride, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_U, /* rootIx */
+ 1, /* offset */
+ };
+ return layout;
+ }
+
+ static C2PlanarLayout YVUSemiPlanarLayout(int32_t stride) {
+ C2PlanarLayout layout = {
+ C2PlanarLayout::TYPE_YUV,
+ 3, /* numPlanes */
+ 2, /* rootPlanes */
+ {}, /* planes --- to be filled below */
+ };
+ layout.planes[C2PlanarLayout::PLANE_Y] = {
+ C2PlaneInfo::CHANNEL_Y,
+ 1, /* colInc */
+ stride, /* rowInc */
+ 1, /* colSampling */
+ 1, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_Y, /* rootIx */
+ 0, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_U] = {
+ C2PlaneInfo::CHANNEL_CB,
+ 2, /* colInc */
+ stride, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_V, /* rootIx */
+ 1, /* offset */
+ };
+ layout.planes[C2PlanarLayout::PLANE_V] = {
+ C2PlaneInfo::CHANNEL_CR,
+ 2, /* colInc */
+ stride, /* rowInc */
+ 2, /* colSampling */
+ 2, /* rowSampling */
+ 8, /* allocatedDepth */
+ 8, /* bitDepth */
+ 0, /* rightShift */
+ C2PlaneInfo::NATIVE,
+ C2PlanarLayout::PLANE_V, /* rootIx */
+ 0, /* offset */
+ };
+ return layout;
+ }
+
+ static std::shared_ptr<C2GraphicBlock> CreateGraphicBlock(
+ uint32_t width,
+ uint32_t height,
+ const C2PlanarLayout &layout,
+ size_t capacity,
+ std::vector<size_t> offsets) {
+ std::shared_ptr<C2GraphicAllocation> alloc = std::make_shared<TestGraphicAllocation>(
+ width,
+ height,
+ layout,
+ capacity,
+ offsets);
+
+ return _C2BlockFactory::CreateGraphicBlock(alloc);
+ }
+
+ static constexpr uint8_t GetPixelValue(uint8_t value, uint32_t row, uint32_t col) {
+ return (uint32_t(value) * row + col) & 0xFF;
+ }
+
+ static void FillPlane(C2GraphicView &view, size_t index, uint8_t value) {
+ C2PlanarLayout layout = view.layout();
+
+ uint8_t *rowPtr = view.data()[index];
+ C2PlaneInfo plane = layout.planes[index];
+ for (uint32_t row = 0; row < view.height() / plane.rowSampling; ++row) {
+ uint8_t *colPtr = rowPtr;
+ for (uint32_t col = 0; col < view.width() / plane.colSampling; ++col) {
+ *colPtr = GetPixelValue(value, row, col);
+ colPtr += plane.colInc;
+ }
+ rowPtr += plane.rowInc;
+ }
+ }
+
+ static void FillBlock(const std::shared_ptr<C2GraphicBlock> &block) {
+ C2GraphicView view = block->map().get();
+
+ FillPlane(view, C2PlanarLayout::PLANE_Y, 'Y');
+ FillPlane(view, C2PlanarLayout::PLANE_U, 'U');
+ FillPlane(view, C2PlanarLayout::PLANE_V, 'V');
+ }
+
+ static bool VerifyPlane(
+ const MediaImage2 *mediaImage,
+ const uint8_t *base,
+ uint32_t index,
+ uint8_t value,
+ std::string *errorMsg) {
+ *errorMsg = "";
+ MediaImage2::PlaneInfo plane = mediaImage->mPlane[index];
+ const uint8_t *rowPtr = base + plane.mOffset;
+ for (uint32_t row = 0; row < mediaImage->mHeight / plane.mVertSubsampling; ++row) {
+ const uint8_t *colPtr = rowPtr;
+ for (uint32_t col = 0; col < mediaImage->mWidth / plane.mHorizSubsampling; ++col) {
+ if (GetPixelValue(value, row, col) != *colPtr) {
+ *errorMsg = AStringPrintf("row=%u col=%u expected=%02x actual=%02x",
+ row, col, GetPixelValue(value, row, col), *colPtr).c_str();
+ return false;
+ }
+ colPtr += plane.mColInc;
+ }
+ rowPtr += plane.mRowInc;
+ }
+ return true;
+ }
+
+public:
+ static constexpr int32_t kWidth = 320;
+ static constexpr int32_t kHeight = 240;
+ static constexpr int32_t kGapLength = kWidth * kHeight * 10;
+
+ static std::shared_ptr<C2Buffer> CreateAndFillBufferFromParam(const ParamType &param) {
+ bool contiguous = std::get<0>(param);
+ std::string planeOrderStr = std::get<1>(param);
+ bool planar = std::get<2>(param);
+ int32_t stride = std::get<3>(param);
+
+ C2PlanarLayout::plane_index_t planeOrder[3];
+ C2PlanarLayout layout;
+
+ if (planeOrderStr.size() != 3) {
+ return nullptr;
+ }
+ for (size_t i = 0; i < 3; ++i) {
+ C2PlanarLayout::plane_index_t planeIndex;
+ switch (planeOrderStr[i]) {
+ case 'Y': planeIndex = C2PlanarLayout::PLANE_Y; break;
+ case 'U': planeIndex = C2PlanarLayout::PLANE_U; break;
+ case 'V': planeIndex = C2PlanarLayout::PLANE_V; break;
+ default: return nullptr;
+ }
+ planeOrder[i] = planeIndex;
+ }
+
+ if (planar) {
+ layout = YUVPlanarLayout(stride);
+ } else { // semi-planar
+ for (size_t i = 0; i < 3; ++i) {
+ if (planeOrder[i] == C2PlanarLayout::PLANE_U) {
+ layout = YUVSemiPlanarLayout(stride);
+ break;
+ }
+ if (planeOrder[i] == C2PlanarLayout::PLANE_V) {
+ layout = YVUSemiPlanarLayout(stride);
+ break;
+ }
+ }
+ }
+
+ size_t yPlaneSize = stride * kHeight;
+ size_t uvPlaneSize = stride * kHeight / 4;
+ size_t capacity = yPlaneSize + uvPlaneSize * 2;
+ std::vector<size_t> offsets(3);
+
+ if (!contiguous) {
+ if (planar) {
+ capacity += kGapLength * 2;
+ } else { // semi-planar
+ capacity += kGapLength;
+ }
+ }
+
+ offsets[planeOrder[0]] = 0;
+ size_t planeSize = (planeOrder[0] == C2PlanarLayout::PLANE_Y) ? yPlaneSize : uvPlaneSize;
+ for (size_t i = 1; i < 3; ++i) {
+ offsets[planeOrder[i]] = offsets[planeOrder[i - 1]] + planeSize;
+ if (!contiguous) {
+ offsets[planeOrder[i]] += kGapLength;
+ }
+ planeSize = (planeOrder[i] == C2PlanarLayout::PLANE_Y) ? yPlaneSize : uvPlaneSize;
+ if (!planar // semi-planar
+ && planeOrder[i - 1] != C2PlanarLayout::PLANE_Y
+ && planeOrder[i] != C2PlanarLayout::PLANE_Y) {
+ offsets[planeOrder[i]] = offsets[planeOrder[i - 1]] + 1;
+ planeSize = uvPlaneSize * 2 - 1;
+ }
+ }
+
+ std::shared_ptr<C2GraphicBlock> block = CreateGraphicBlock(
+ kWidth,
+ kHeight,
+ layout,
+ capacity,
+ offsets);
+ FillBlock(block);
+ return C2Buffer::CreateGraphicBuffer(
+ block->share(block->crop(), C2Fence()));
+ }
+
+ static bool VerifyClientBuffer(
+ const sp<MediaCodecBuffer> &buffer, std::string *errorMsg) {
+ *errorMsg = "";
+ sp<ABuffer> imageData;
+ if (!buffer->format()->findBuffer("image-data", &imageData)) {
+ *errorMsg = "Missing image data";
+ return false;
+ }
+ MediaImage2 *mediaImage = (MediaImage2 *)imageData->data();
+ if (mediaImage->mType != MediaImage2::MEDIA_IMAGE_TYPE_YUV) {
+ *errorMsg = AStringPrintf("Unexpected type: %d", mediaImage->mType).c_str();
+ return false;
+ }
+ std::string planeErrorMsg;
+ if (!VerifyPlane(mediaImage, buffer->base(), MediaImage2::Y, 'Y', &planeErrorMsg)) {
+ *errorMsg = "Y plane does not match: " + planeErrorMsg;
+ return false;
+ }
+ if (!VerifyPlane(mediaImage, buffer->base(), MediaImage2::U, 'U', &planeErrorMsg)) {
+ *errorMsg = "U plane does not match: " + planeErrorMsg;
+ return false;
+ }
+ if (!VerifyPlane(mediaImage, buffer->base(), MediaImage2::V, 'V', &planeErrorMsg)) {
+ *errorMsg = "V plane does not match: " + planeErrorMsg;
+ return false;
+ }
+
+ int32_t width, height, stride;
+ buffer->format()->findInt32(KEY_WIDTH, &width);
+ buffer->format()->findInt32(KEY_HEIGHT, &height);
+ buffer->format()->findInt32(KEY_STRIDE, &stride);
+
+ MediaImage2 legacyYLayout = {
+ MediaImage2::MEDIA_IMAGE_TYPE_Y,
+ 1, // mNumPlanes
+ uint32_t(width),
+ uint32_t(height),
+ 8,
+ 8,
+ {}, // mPlane
+ };
+ legacyYLayout.mPlane[MediaImage2::Y] = {
+ 0, // mOffset
+ 1, // mColInc
+ stride, // mRowInc
+ 1, // mHorizSubsampling
+ 1, // mVertSubsampling
+ };
+ if (!VerifyPlane(&legacyYLayout, buffer->data(), MediaImage2::Y, 'Y', &planeErrorMsg)) {
+ *errorMsg = "Y plane by legacy layout does not match: " + planeErrorMsg;
+ return false;
+ }
+ return true;
+ }
+
+};
+
+TEST_P(LayoutTest, VerifyLayout) {
+ std::shared_ptr<RawGraphicOutputBuffers> buffers =
+ GetRawGraphicOutputBuffers(kWidth, kHeight);
+
+ std::shared_ptr<C2Buffer> c2Buffer = CreateAndFillBufferFromParam(GetParam());
+ ASSERT_NE(nullptr, c2Buffer);
+ sp<MediaCodecBuffer> clientBuffer;
+ size_t index;
+ ASSERT_EQ(OK, buffers->registerBuffer(c2Buffer, &index, &clientBuffer));
+ ASSERT_NE(nullptr, clientBuffer);
+ std::string errorMsg;
+ ASSERT_TRUE(VerifyClientBuffer(clientBuffer, &errorMsg)) << errorMsg;
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ RawGraphicOutputBuffersTest,
+ LayoutTest,
+ ::testing::Combine(
+ ::testing::Bool(), /* contiguous */
+ ::testing::Values("YUV", "YVU", "UVY", "VUY"),
+ ::testing::Bool(), /* planar */
+ ::testing::Values(320, 512)),
+ [](const ::testing::TestParamInfo<LayoutTest::ParamType> &info) {
+ std::string contiguous = std::get<0>(info.param) ? "Contiguous" : "Noncontiguous";
+ std::string planar = std::get<2>(info.param) ? "Planar" : "SemiPlanar";
+ return contiguous
+ + std::get<1>(info.param)
+ + planar
+ + std::to_string(std::get<3>(info.param));
+ });
+
} // namespace android
--
2.25.1

View File

@ -0,0 +1,53 @@
From c833b08d188dbb1294e164958c51ac2afb0e3e2e Mon Sep 17 00:00:00 2001
From: Wonsik Kim <wonsik@google.com>
Date: Tue, 5 Jan 2021 18:55:22 -0800
Subject: [PATCH 31/32] CCodec: workaround for frame drops
Retain old behavior for lower resolution (<=4K) to workaround
possible frame drops.
Bug: 175354926
Bug: 175182085
Test: atest CtsCameraTestCases:RecordingTest
Change-Id: I170102e928714c5b48817bf7915f55ce8a6280f0
---
media/codec2/sfplugin/CCodec.cpp | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 2f16ca1104..55ff18f4a2 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -247,15 +247,20 @@ public:
return NO_INIT;
}
- size_t numSlots = 4;
- constexpr OMX_U32 kPortIndexInput = 0;
-
- OMX_PARAM_PORTDEFINITIONTYPE param;
- param.nPortIndex = kPortIndexInput;
- status_t err = mNode->getParameter(OMX_IndexParamPortDefinition,
- &param, sizeof(param));
- if (err == OK) {
- numSlots = param.nBufferCountActual;
+ size_t numSlots = 16;
+ // WORKAROUND: having more slots improve performance while consuming
+ // more memory. This is a temporary workaround to reduce memory for
+ // larger-than-4K scenario.
+ if (mWidth * mHeight > 4096 * 2340) {
+ constexpr OMX_U32 kPortIndexInput = 0;
+
+ OMX_PARAM_PORTDEFINITIONTYPE param;
+ param.nPortIndex = kPortIndexInput;
+ status_t err = mNode->getParameter(OMX_IndexParamPortDefinition,
+ &param, sizeof(param));
+ if (err == OK) {
+ numSlots = param.nBufferCountActual;
+ }
}
for (size_t i = 0; i < numSlots; ++i) {
--
2.25.1

View File

@ -0,0 +1,66 @@
From ecab6fe48819adeafaceec1a33e7e1d380caec75 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 13 Mar 2021 14:20:03 -0500
Subject: [PATCH 33/38] Support Samsung R multi-cams
---
services/camera/libcameraservice/Android.bp | 1 +
.../libcameraservice/common/CameraProviderManager.cpp | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/services/camera/libcameraservice/Android.bp b/services/camera/libcameraservice/Android.bp
index be275e9346..bede98bfdc 100644
--- a/services/camera/libcameraservice/Android.bp
+++ b/services/camera/libcameraservice/Android.bp
@@ -129,6 +129,7 @@ cc_library_shared {
"android.hardware.camera.device@3.5",
"android.hardware.camera.device@3.6",
"vendor.samsung.hardware.camera.provider@3.0",
+ "vendor.samsung.hardware.camera.provider@4.0",
],
static_libs: [
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 3e6ad1ef52..b7d1a57567 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -22,6 +22,7 @@
#include <android/hardware/camera/device/3.5/ICameraDevice.h>
#include <vendor/samsung/hardware/camera/provider/3.0/ISehCameraProvider.h>
+#include <vendor/samsung/hardware/camera/provider/4.0/ISehCameraProvider.h>
#include <algorithm>
#include <chrono>
@@ -1363,7 +1364,9 @@ status_t CameraProviderManager::ProviderInfo::initialize(
}
auto samsungCast = vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider::castFrom(interface);
+ auto samsung40Cast = vendor::samsung::hardware::camera::provider::V4_0::ISehCameraProvider::castFrom(interface);
auto samsungProvider = samsungCast.isOk() ? static_cast<sp<vendor::samsung::hardware::camera::provider::V3_0::ISehCameraProvider>>(samsungCast) : nullptr;
+ auto samsung40Provider = samsung40Cast.isOk() ? static_cast<sp<vendor::samsung::hardware::camera::provider::V4_0::ISehCameraProvider>>(samsung40Cast) : nullptr;
hardware::Return<bool> linked = interface->linkToDeath(this, /*cookie*/ mId);
if (!linked.isOk()) {
@@ -1401,6 +1404,7 @@ status_t CameraProviderManager::ProviderInfo::initialize(
status = idStatus;
if (status == Status::OK) {
for (auto& name : cameraDeviceNames) {
+ ALOGE("Listing camera ID %s", name.c_str());
uint16_t major, minor;
std::string type, id;
status_t res = parseDeviceName(name, &major, &minor, &type, &id);
@@ -1414,7 +1418,9 @@ status_t CameraProviderManager::ProviderInfo::initialize(
}
} };
hardware::Return<void> ret;
- if(samsungProvider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
+ if(samsung40Provider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
+ ret = samsung40Provider->sehGetCameraIdList(cb);
+ else if(samsungProvider != nullptr && property_get_bool("persist.sys.phh.samsung.camera_ids", false))
ret = samsungProvider->sehGetCameraIdList(cb);
else
ret = interface->getCameraIdList(cb);
--
2.25.1

View File

@ -0,0 +1,30 @@
From 347755b3b0d26b557ac0775433ccdbabe23ac6ed Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 23 Mar 2021 00:16:42 +0100
Subject: [PATCH 34/38] [audiopolicy] Don't crash on unknown audio devices
---
.../common/managerdefinitions/src/Serializer.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 73e4a3e096..1f200ad850 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -951,7 +951,12 @@ Return<ModuleTraits::Element> ModuleTraits::deserialize(const xmlNode *cur, PtrS
sp<DeviceDescriptor> device = module->getDeclaredDevices().
getDeviceFromTagName(std::string(reinterpret_cast<const char*>(
attachedDevice.get())));
- ctx->addDevice(device);
+ if(device != nullptr) {
+ ctx->addDevice(device);
+ } else {
+ ALOGE("NULL DEVICE %s: %s %s=%s", __func__, tag, childAttachedDeviceTag,
+ reinterpret_cast<const char*>(attachedDevice.get()));
+ }
}
}
}
--
2.25.1

View File

@ -0,0 +1,99 @@
From 0b8723c62a0d5b63f8afd46fddc3c38123b49d04 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Sun, 28 Mar 2021 16:17:36 +0800
Subject: [PATCH 35/38] AudioPolicyManager: retry with SW bridge if hardware
audio patch fails
* On two of my MT6771 Q vendor devices, in-call audio is broken due to
the audio HAL claiming to support HW audio patch between the Rx / Tx
devices but failing when called with `createAudioPatch`.
> 03-28 11:56:42.300 1345 1345 W AudioALSAHardware: sinks[0].type ==
AUDIO_PORT_TYPE_DEVICE
> 03-28 11:56:42.300 1345 1345 W AudioALSAHardware: [createAudioPatch]
[5082]
> 03-28 11:56:42.300 1345 1345 E AudioALSAHardware: Fail status -38
> 03-28 11:56:42.300 1345 1345 W DeviceHAL: Error from HAL Device in
function create_audio_patch: Function not implemented
> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager:
createAudioPatchInternal patch panel could not connect device patch,
error -38
> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager:
createTelephonyPatch() error -38 creating RX audio patch
* This was not broken on Q because
`AudioPolicyManager::updateCallRouting` bypasses `createAudioPatch` by
directly calling the legacy `setOutputDevice` when `supportsPatch` is
true, i.e. `createAudioPatch` was *only* used for SW bridge for
in-call audio before R.
* As a workaround, re-try by forcing the creation of a SW bridge after
`createAudioPatch` fails. We could also restore the old behavior of
`updateCallRouting`, but that would probably break in-call audio on
newer HALs that may or may not work properly with `setOutputDevice`.
---
.../managerdefault/AudioPolicyManager.cpp | 13 ++++++++++---
.../audiopolicy/managerdefault/AudioPolicyManager.h | 4 +++-
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 63dcd538b1..6d2c38811e 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -3490,7 +3490,8 @@ status_t AudioPolicyManager::getAudioPort(struct audio_port *port)
status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *patch,
audio_patch_handle_t *handle,
uid_t uid, uint32_t delayMs,
- const sp<SourceClientDescriptor>& sourceDesc)
+ const sp<SourceClientDescriptor>& sourceDesc,
+ bool forceSwBridge)
{
ALOGV("%s", __func__);
if (handle == NULL || patch == NULL) {
@@ -3694,7 +3695,8 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
// - audio HAL version is >= 3.0 but no route has been declared between devices
// - called from startAudioSource (aka sourceDesc != nullptr) and source device does
// not have a gain controller
- if (!srcDevice->hasSameHwModuleAs(sinkDevice) ||
+ // - a previous attempt at using HW bridge failed (forceSwBridge)
+ if (forceSwBridge || !srcDevice->hasSameHwModuleAs(sinkDevice) ||
(srcDevice->getModuleVersionMajor() < 3) ||
!srcDevice->getModule()->supportsPatch(srcDevice, sinkDevice) ||
(sourceDesc != nullptr &&
@@ -3759,7 +3761,12 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
__func__, index, handle, patchBuilder.patch(), delayMs, uid, &patchDesc);
if (status != NO_ERROR) {
ALOGW("%s patch panel could not connect device patch, error %d", __func__, status);
- return INVALID_OPERATION;
+ if (forceSwBridge || patch->sinks[0].type != AUDIO_PORT_TYPE_DEVICE) {
+ return INVALID_OPERATION;
+ } else {
+ ALOGW("Retrying with software bridging.");
+ return createAudioPatchInternal(patch, handle, uid, delayMs, sourceDesc, true);
+ }
}
} else {
return BAD_VALUE;
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index b588f898d4..60cbd7175e 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -910,12 +910,14 @@ private:
* @param[in] delayMs if required
* @param[in] sourceDesc [optional] in case of external source, source client to be
* configured by the patch, i.e. assigning an Output (HW or SW)
+ * @param[in] forceSwBridge [optional] force the creation of a SW bridge (internal use only)
* @return NO_ERROR if patch installed correctly, error code otherwise.
*/
status_t createAudioPatchInternal(const struct audio_patch *patch,
audio_patch_handle_t *handle,
uid_t uid, uint32_t delayMs = 0,
- const sp<SourceClientDescriptor>& sourceDesc = nullptr);
+ const sp<SourceClientDescriptor>& sourceDesc = nullptr,
+ bool forceSwBridge = false);
/**
* @brief releaseAudioPatchInternal internal function to remove an audio patch
* @param[in] handle of the patch to be removed
--
2.25.1

View File

@ -0,0 +1,26 @@
From c8a6af6fd0f3134b96fc291910cfc0380bc0dc31 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 28 Mar 2021 14:47:52 +0200
Subject: [PATCH 36/38] Reenable STRATEGY_ROUTING. This is a leftover of tries
of 587b198, wrongly commited in 20f869
---
services/audiopolicy/enginedefault/src/Engine.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index 16a7a4bbac..b14d2bbb0b 100755
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -52,7 +52,7 @@ static const std::vector<legacy_strategy_map>& getLegacyStrategy() {
{ "STRATEGY_ENFORCED_AUDIBLE", STRATEGY_ENFORCED_AUDIBLE },
{ "STRATEGY_TRANSMITTED_THROUGH_SPEAKER", STRATEGY_TRANSMITTED_THROUGH_SPEAKER },
{ "STRATEGY_ACCESSIBILITY", STRATEGY_ACCESSIBILITY },
- //{ "STRATEGY_REROUTING", STRATEGY_REROUTING },
+ { "STRATEGY_REROUTING", STRATEGY_REROUTING },
{ "STRATEGY_PATCH", STRATEGY_REROUTING }, // boiler to manage stream patch volume
{ "STRATEGY_CALL_ASSISTANT", STRATEGY_CALL_ASSISTANT },
};
--
2.25.1

View File

@ -0,0 +1,40 @@
From c3bd3dc63c34de7c688b24999769f7eb504784a3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 28 Mar 2021 14:48:49 +0200
Subject: [PATCH 37/38] Use a fake volume policy when none has been found
This is useful, because on Samsung devices, the "real"
(=non-gsi-cheating) audio policy doesn't have any volume policy.
This requires actually adding the fake audio policy xml file (done in
device/phh/treble)
---
services/audiopolicy/engine/config/src/EngineConfig.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/services/audiopolicy/engine/config/src/EngineConfig.cpp b/services/audiopolicy/engine/config/src/EngineConfig.cpp
index 4842cb282f..e8d6917754 100644
--- a/services/audiopolicy/engine/config/src/EngineConfig.cpp
+++ b/services/audiopolicy/engine/config/src/EngineConfig.cpp
@@ -717,11 +717,17 @@ android::status_t parseLegacyVolumes(VolumeGroups &volumeGroups) {
snprintf(audioPolicyXmlConfigFile, sizeof(audioPolicyXmlConfigFile),
"%s/%s", path.c_str(), fileName);
ret = parseLegacyVolumeFile(audioPolicyXmlConfigFile, volumeGroups);
- if (ret == NO_ERROR) {
+ ALOGE("Parsing volume for %s gave %zu", audioPolicyXmlConfigFile, volumeGroups.size());
+ if (ret == NO_ERROR && volumeGroups.size() > 0) {
return ret;
}
}
}
+ ret = parseLegacyVolumeFile("/system/etc/fake_audio_policy_volume.xml", volumeGroups);
+ ALOGE("Parsing volume for /system/etc/fake_audio_policy_volume.xml gave %zu", volumeGroups.size());
+ if (ret == NO_ERROR && volumeGroups.size() == 0) {
+ return ret;
+ }
return BAD_VALUE;
}
--
2.25.1

View File

@ -0,0 +1,31 @@
From 23f277e7a6afee9d256582204099c4c645606b98 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 28 Mar 2021 18:54:47 +0200
Subject: [PATCH 38/38] Not all sources in a route are valid. Dont ignore the
whole route because of one broken source
---
.../audiopolicy/common/managerdefinitions/src/Serializer.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 1f200ad850..e57bd24724 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -609,10 +609,11 @@ Return<RouteTraits::Element> RouteTraits::deserialize(const xmlNode *cur, PtrSer
source = ctx->findPortByTagName(trim(devTag));
if (source == NULL) {
ALOGE("%s: no source found with name=%s", __func__, devTag);
- return Status::fromStatusT(BAD_VALUE);
}
}
- sources.add(source);
+ if(source != nullptr) {
+ sources.add(source);
+ }
}
devTag = strtok(NULL, ",");
}
--
2.25.1

View File

@ -0,0 +1,73 @@
From 2fd4810ec5e6a453e980cacba2e1bcdd30b3f967 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 14 Apr 2021 10:20:22 +0800
Subject: [PATCH 39/40] Revert "AudioPolicyManager: retry with SW bridge if
hardware audio patch fails"
This reverts commit 5d869232d42a2fee6b7cb07b6a240aef5838021b.
---
.../managerdefault/AudioPolicyManager.cpp | 13 +++----------
.../audiopolicy/managerdefault/AudioPolicyManager.h | 4 +---
2 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 6d2c38811e..63dcd538b1 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -3490,8 +3490,7 @@ status_t AudioPolicyManager::getAudioPort(struct audio_port *port)
status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *patch,
audio_patch_handle_t *handle,
uid_t uid, uint32_t delayMs,
- const sp<SourceClientDescriptor>& sourceDesc,
- bool forceSwBridge)
+ const sp<SourceClientDescriptor>& sourceDesc)
{
ALOGV("%s", __func__);
if (handle == NULL || patch == NULL) {
@@ -3695,8 +3694,7 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
// - audio HAL version is >= 3.0 but no route has been declared between devices
// - called from startAudioSource (aka sourceDesc != nullptr) and source device does
// not have a gain controller
- // - a previous attempt at using HW bridge failed (forceSwBridge)
- if (forceSwBridge || !srcDevice->hasSameHwModuleAs(sinkDevice) ||
+ if (!srcDevice->hasSameHwModuleAs(sinkDevice) ||
(srcDevice->getModuleVersionMajor() < 3) ||
!srcDevice->getModule()->supportsPatch(srcDevice, sinkDevice) ||
(sourceDesc != nullptr &&
@@ -3761,12 +3759,7 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *
__func__, index, handle, patchBuilder.patch(), delayMs, uid, &patchDesc);
if (status != NO_ERROR) {
ALOGW("%s patch panel could not connect device patch, error %d", __func__, status);
- if (forceSwBridge || patch->sinks[0].type != AUDIO_PORT_TYPE_DEVICE) {
- return INVALID_OPERATION;
- } else {
- ALOGW("Retrying with software bridging.");
- return createAudioPatchInternal(patch, handle, uid, delayMs, sourceDesc, true);
- }
+ return INVALID_OPERATION;
}
} else {
return BAD_VALUE;
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 60cbd7175e..b588f898d4 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -910,14 +910,12 @@ private:
* @param[in] delayMs if required
* @param[in] sourceDesc [optional] in case of external source, source client to be
* configured by the patch, i.e. assigning an Output (HW or SW)
- * @param[in] forceSwBridge [optional] force the creation of a SW bridge (internal use only)
* @return NO_ERROR if patch installed correctly, error code otherwise.
*/
status_t createAudioPatchInternal(const struct audio_patch *patch,
audio_patch_handle_t *handle,
uid_t uid, uint32_t delayMs = 0,
- const sp<SourceClientDescriptor>& sourceDesc = nullptr,
- bool forceSwBridge = false);
+ const sp<SourceClientDescriptor>& sourceDesc = nullptr);
/**
* @brief releaseAudioPatchInternal internal function to remove an audio patch
* @param[in] handle of the patch to be removed
--
2.25.1

View File

@ -0,0 +1,78 @@
From 7bb3de067cec0c8c3bd5341bf9ad42b808fefd39 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 14 Apr 2021 11:09:12 +0800
Subject: [PATCH 40/40] APM: Fall back to legacy voice call routing if creating
audio patch failed
* On some MT6771 Q vendor devices, in-call audio is broken due to APM
failing to create an HW audio patch for RX / TX devices.
> 03-28 11:56:42.300 1345 1345 W DeviceHAL: Error from HAL Device in
function create_audio_patch: Function not implemented
> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager:
createAudioPatchInternal patch panel could not connect device patch,
error -38
> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager:
createTelephonyPatch() error -38 creating RX audio patch
* Our previous attempt at fixing this by falling back to SW bridging was
wrong, because SW bridging requires a corresponding audio policy
configuration that includes said SW bridges, which is not the case on
these devices.
* The sole reason why this was broken at all is that the new R behavior
tries to use the newer `createAudioPatch` interface of the audio HAL,
which is broken on these devices for telephony inputs and outputs,
even though the HAL claims to support it.
* Let's fall back to pre-R behavior (i.e. using the legacy
setOutputDevices() interface) whenever the new method fails. The
legacy method takes care of TX (Mic input) as well, so we don't need
to create the TX patch either.
---
.../managerdefault/AudioPolicyManager.cpp | 23 +++++++++++++++----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 63dcd538b1..124c6ca6ef 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -575,17 +575,30 @@ uint32_t AudioPolicyManager::updateCallRouting(const DeviceVector &rxDevices, ui
createTxPatch = !(availablePrimaryModuleInputDevices().contains(txSourceDevice)) &&
(txSinkDevice != 0);
}
- // Use legacy routing method for voice calls via setOutputDevice() on primary output.
- // Otherwise, create two audio patches for TX and RX path.
- if (!createRxPatch) {
- muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
- } else { // create RX path audio patch
+ if (createRxPatch) { // create RX path audio patch
mCallRxPatch = createTelephonyPatch(true /*isRx*/, rxDevices.itemAt(0), delayMs);
+ if (mCallRxPatch == nullptr) {
+ // Fall back to legacy routing for voice calls if the new patching method
+ // failed. setOutputDevice() will take care of TX in this case, so don't
+ // create the TX patch either.
+ // This is seen on some MT6771 devices on Q vendor, where the HAL claims
+ // support for HW patch between telephony inputs and outputs, but fails
+ // to create one when called with the createAudioPatch() method. SW audio
+ // bridges are also broken on them due to improperly configured audio policy.
+ ALOGW("Failed to create RX path audio patch, falling back to pre-R behavior");
+ createRxPatch = false;
+ createTxPatch = false;
+ }
+
// If the TX device is on the primary HW module but RX device is
// on other HW module, SinkMetaData of telephony input should handle it
// assuming the device uses audio HAL V5.0 and above
}
+ // Use legacy routing method for voice calls via setOutputDevice() on primary output.
+ if (!createRxPatch) {
+ muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs);
+ }
if (createTxPatch) { // create TX path audio patch
// terminate active capture if on the same HW module as the call TX source device
// FIXME: would be better to refine to only inputs whose profile connects to the
--
2.25.1

View File

@ -0,0 +1,31 @@
From 494741f30b1c6a1ce223e6331d6ade70e9bc0b52 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 28 Nov 2017 18:28:04 +0100
Subject: [PATCH] Relax requirement for visible flag to sdcards
The vast majority of sdcard readers are stable enough to be declared by
the API. (I see no counter-example)
FBE broke adoptable storage with SDCard, hence this need.
Change-Id: Ia616671c03562d1eadaff5531a5c708a62d7ad3a
---
.../core/java/com/android/server/StorageManagerService.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 498c52a5aa6..dd7f4560000 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -1525,7 +1525,8 @@ class StorageManagerService extends IStorageManager.Stub
// Adoptable public disks are visible to apps, since they meet
// public API requirement of being in a stable location.
- if (vol.disk.isAdoptable()) {
+ // Assume all SDs match this as well
+ if (vol.disk.isAdoptable() || vol.disk.isSd()) {
vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
} else if (vol.disk.isSd()) {
vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
--
2.25.1

View File

@ -0,0 +1,136 @@
From db0376e279f7aa4744934376157b844f51d334ce Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 24 Mar 2018 08:01:48 +0100
Subject: [PATCH] backlight: Fix backlight control on Galaxy S9(+)
Change-Id: I1fbbb47939c377597ef8ad6b88b2acea5f4acaa6
:backlight: S9 brightness override only for screen
Change-Id: Ie16a46336fa64850014b962429f7a20ff569222f
:backlight: [WIP] Fix OP6 brightness
Change-Id: If08959ece6cac1f27e1f1a0bd966ee8e1813241d
:backlight: Try to make brightness more generic using property set by rw-system
Change-Id: I0f20ca4b1f0fa1fcfd19833aa291fbdf16d6eedd
:backlight: Add Qualcomm starlte
Change-Id: I12a445344deb8b2e59a2f6ce6b24c1ffe5675092
:backlight: Switch samsung light fingerprint match to regexp, to include Note9
Change-Id: I2995f7bab615aec125927a5a027ad8f9ae43405f
Add a property toggle to enable high brightness range on samsung device
Change-Id: I649a3985ef87f46a5515a63935fdae9cdcbd8ec5
:backlight: Add japanese S9
Change-Id: I5e245469f5f51fed14c6080e5be72506e10389e0
:backlight: Fix backlight on S10*. Add an additional property to check, so testers can try it more easily
Change-Id: Ia224e641cad8561201b4dee3d896362bee80c903
:backlight: Make samsung light HAL more overridable
Change-Id: Ie04f394f8a614da8070f330bcadbcbe12895bed0
Use new backlight control API only for backlight, not for other lights
Change-Id: I35c35fabff8b275f35671dcb8578b96dcad526f1
:backlight: fixup
Change-Id: I4e85178327d2bb63d5d0a37786058843662a89ba
---
.../android/server/lights/LightsService.java | 49 ++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/lights/LightsService.java b/services/core/java/com/android/server/lights/LightsService.java
index f712e8de353..43264cb32d2 100644
--- a/services/core/java/com/android/server/lights/LightsService.java
+++ b/services/core/java/com/android/server/lights/LightsService.java
@@ -33,6 +33,7 @@ import android.os.Looper;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemProperties;
import android.os.Trace;
import android.provider.Settings;
import android.util.Slog;
@@ -302,12 +303,13 @@ public class LightsService extends SystemService {
+ ": brightness=" + brightness);
return;
}
+
// Ideally, we'd like to set the brightness mode through the SF/HWC as well, but
// right now we just fall back to the old path through Lights brightessMode is
// anything but USER or the device shouldBeInLowPersistenceMode().
if (brightnessMode == BRIGHTNESS_MODE_USER && !shouldBeInLowPersistenceMode()
&& mHwLight.type == LightsManager.LIGHT_ID_BACKLIGHT
- && mSurfaceControlMaximumBrightness == 255) {
+ && mSurfaceControlMaximumBrightness == 255 && mHwLight.id == 0) {
// New system
// TODO: the last check should be mSurfaceControlMaximumBrightness != 0; the
// reason we enforce 255 right now is to stay consistent with the old path. In
@@ -322,6 +324,51 @@ public class LightsService extends SystemService {
// Old system
int brightnessInt = BrightnessSynchronizer.brightnessFloatToInt(
getContext(), brightness);
+
+ if(mHwLight.id == 0) {
+ String fp = SystemProperties.get("ro.vendor.build.fingerprint", "hello");
+ if(fp.matches(".*astarqlte.*")) {
+ int newBrightness = brightnessInt;
+ if(SystemProperties.getBoolean("persist.sys.samsung.full_brightness", false)) {
+ newBrightness = (int) (brightnessInt * 365.0 / 255.0);
+ }
+ setLightLocked(newBrightness, LIGHT_FLASH_HARDWARE, 0, 0, brightnessMode);
+ return;
+ }
+
+ int useSamsungBacklight = SystemProperties.getInt("persist.sys.phh.samsung_backlight", -1);
+ if(useSamsungBacklight != 0) {
+ if(useSamsungBacklight > 0 ||
+ fp.matches(".*beyond.*lte.*") ||
+ fp.matches(".*(crown|star)[q2]*lte.*") ||
+ fp.matches(".*(SC-0[23]K|SCV3[89]).*")) {
+ int ratio = 100;
+ if(useSamsungBacklight > 1)
+ ratio = useSamsungBacklight;
+ int newBrightness = brightnessInt * ratio;
+ if(SystemProperties.getBoolean("persist.sys.samsung.full_brightness", false)) {
+ newBrightness = (int) (brightnessInt * 40960.0 / 255.0);
+ }
+ setLightLocked(newBrightness, LIGHT_FLASH_HARDWARE, 0, 0, brightnessMode);
+ return;
+ }
+ }
+
+ boolean qcomExtendBrightness = SystemProperties.getBoolean("persist.extend.brightness", false);
+ int scale = SystemProperties.getInt("persist.display.max_brightness", 1023);
+ //This is set by vndk-detect
+ int qcomScale = SystemProperties.getInt("persist.sys.qcom-brightness", -1);
+ if(qcomScale != -1) {
+ qcomExtendBrightness = true;
+ scale = qcomScale;
+ }
+
+ if(qcomExtendBrightness) {
+ setLightLocked(brightnessInt * scale / 255, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
+ return;
+ }
+ }
+
int color = brightnessInt & 0x000000ff;
color = 0xff000000 | (color << 16) | (color << 8) | color;
setLightLocked(color, LIGHT_FLASH_NONE, 0, 0, brightnessMode);
--
2.25.1

View File

@ -0,0 +1,43 @@
From b236ed36a97c09a15fa18d3387ff20dadd5be965 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 1 May 2018 17:47:36 +0200
Subject: [PATCH 03/25] Also scan /system/overlay
Change-Id: Ib0223560606b80cdaaa986b159b34b4db0154589
---
core/jni/android_util_AssetManager.cpp | 4 ++++
core/jni/fd_utils.cpp | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 12abc256a20..3133f2f3023 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -140,6 +140,10 @@ static jobjectArray NativeCreateIdmapsForStaticOverlaysTargetingAndroid(JNIEnv*
input_dirs.push_back(AssetManager::OEM_OVERLAY_DIR);
}
+ if (stat("/system/overlay", &st) == 0) {
+ input_dirs.push_back("/system/overlay");
+ }
+
if (input_dirs.empty()) {
LOG(WARNING) << "no directories for idmap2 to scan";
return env->NewObjectArray(0, g_stringClass, nullptr);
diff --git a/core/jni/fd_utils.cpp b/core/jni/fd_utils.cpp
index c72668f84fb..d4307ae6579 100644
--- a/core/jni/fd_utils.cpp
+++ b/core/jni/fd_utils.cpp
@@ -135,7 +135,8 @@ bool FileDescriptorWhitelist::IsAllowed(const std::string& path) const {
|| android::base::StartsWith(path, kSystemOdmOverlayDir)
|| android::base::StartsWith(path, kOdmOverlayDir)
|| android::base::StartsWith(path, kSystemOemOverlayDir)
- || android::base::StartsWith(path, kOemOverlayDir))
+ || android::base::StartsWith(path, kOemOverlayDir)
+ || android::base::StartsWith(path, "/system/overlay"))
&& android::base::EndsWith(path, kApkSuffix)
&& path.find("/../") == std::string::npos) {
return true;
--
2.17.1

View File

@ -0,0 +1,25 @@
From 2436b6da10c438a3b71ca3a2a5aa9705e7c00813 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 17 May 2018 20:28:35 +0200
Subject: [PATCH 04/25] Don't crash if there is IR HAL is not declared
---
services/core/java/com/android/server/ConsumerIrService.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/services/core/java/com/android/server/ConsumerIrService.java b/services/core/java/com/android/server/ConsumerIrService.java
index 2ed6c77baa0..c574a03c9a3 100644
--- a/services/core/java/com/android/server/ConsumerIrService.java
+++ b/services/core/java/com/android/server/ConsumerIrService.java
@@ -50,8 +50,6 @@ public class ConsumerIrService extends IConsumerIrService.Stub {
if (!mHasNativeHal) {
throw new RuntimeException("FEATURE_CONSUMER_IR present, but no IR HAL loaded!");
}
- } else if (mHasNativeHal) {
- throw new RuntimeException("IR HAL present, but FEATURE_CONSUMER_IR is not set!");
}
}
--
2.17.1

View File

@ -0,0 +1,28 @@
From 25b2ec68fe9ce8a2e3b35fc91ff47ae65ba95be4 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 30 May 2018 14:05:30 +0200
Subject: [PATCH 05/25] Fix(?) #62
---
.../src/com/android/keyguard/KeyguardUpdateMonitor.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 3acbfb87c3f..358053343f2 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -1270,7 +1270,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
- handleFingerprintError(errMsgId, errString.toString());
+ if(errString != null)
+ handleFingerprintError(errMsgId, errString.toString());
+ else
+ handleFingerprintError(errMsgId, "unknown error");
}
@Override
--
2.17.1

View File

@ -0,0 +1,38 @@
From f3d0a467c4c1f9df19c3c4819b4c6cb4b26fe2a3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 11 Sep 2020 23:42:37 +0200
Subject: [PATCH] property-matching RROs: allow to prefix the value with + to
do glob match instead of exact match
Change-Id: I1f5b7c907523eb6e48d41f5163984564d3db9506
---
cmds/idmap2/idmap2/Scan.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmds/idmap2/idmap2/Scan.cpp b/cmds/idmap2/idmap2/Scan.cpp
index 36250450cc7..6a5162dd0d9 100644
--- a/cmds/idmap2/idmap2/Scan.cpp
+++ b/cmds/idmap2/idmap2/Scan.cpp
@@ -15,6 +15,7 @@
*/
#include <dirent.h>
+#include <fnmatch.h>
#include <fstream>
#include <memory>
@@ -187,7 +188,10 @@ Result<Unit> Scan(const std::vector<std::string>& args) {
// if property set & equal to value, then include overlay - otherwise skip
if (android::base::GetProperty(overlay_info->requiredSystemPropertyName, "") !=
overlay_info->requiredSystemPropertyValue) {
- continue;
+ auto osValue = android::base::GetProperty(overlay_info->requiredSystemPropertyName, "");
+ if(fnmatch(overlay_info->requiredSystemPropertyValue.c_str()+1, osValue.c_str(), 0) != 0) {
+ continue;
+ }
}
}
--
2.25.1

View File

@ -0,0 +1,33 @@
From 649f6bd7789acae16c1e3fa8c57919bd4ae0d1e3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 2 Jul 2018 23:36:39 +0200
Subject: [PATCH 07/25] [Galaxy S9] "remaining" of HAL onEnroll is actually a
percent of progress
Change-Id: I8a586163eca93ae3c5bd968d1e7ddbf994ddcc91
---
.../server/biometrics/fingerprint/FingerprintService.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
index 6b7ba6a56d8..c247731be13 100644
--- a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
@@ -588,7 +588,13 @@ public class FingerprintService extends BiometricServiceBase {
final Fingerprint fingerprint =
new Fingerprint(getBiometricUtils().getUniqueName(getContext(), groupId),
groupId, fingerId, deviceId);
- FingerprintService.super.handleEnrollResult(fingerprint, remaining);
+
+ int remaining2 = remaining;
+ String fp = android.os.SystemProperties.get("ro.vendor.build.fingerprint");
+ if(fp != null && (fp.contains("starlte") || fp.contains("star2lte") || fp.contains("starqlte") || fp.contains("star2qlte")))
+ remaining2 = 100 - remaining2;
+
+ FingerprintService.super.handleEnrollResult(fingerprint, remaining2);
});
}
--
2.17.1

View File

@ -0,0 +1,25 @@
From 4ee7b7947513a5481b0b69a3c59e0c7cf6509153 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 6 Aug 2018 12:49:00 +0200
Subject: [PATCH 08/25] Show APN Settings for CDMA carriers
---
telephony/java/android/telephony/CarrierConfigManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index 3d455d51dd7..d351598a55e 100755
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -3898,7 +3898,7 @@ public class CarrierConfigManager {
sDefaults.putBoolean(KEY_MDN_IS_ADDITIONAL_VOICEMAIL_NUMBER_BOOL, false);
sDefaults.putBoolean(KEY_OPERATOR_SELECTION_EXPAND_BOOL, true);
sDefaults.putBoolean(KEY_PREFER_2G_BOOL, true);
- sDefaults.putBoolean(KEY_SHOW_APN_SETTING_CDMA_BOOL, false);
+ sDefaults.putBoolean(KEY_SHOW_APN_SETTING_CDMA_BOOL, true);
sDefaults.putBoolean(KEY_SHOW_CDMA_CHOICES_BOOL, false);
sDefaults.putBoolean(KEY_SMS_REQUIRES_DESTINATION_NUMBER_CONVERSION_BOOL, false);
sDefaults.putBoolean(KEY_SUPPORT_EMERGENCY_SMS_OVER_IMS_BOOL, false);
--
2.17.1

View File

@ -0,0 +1,45 @@
From c53ddf67401c177fe29d0c2eca146e1548ed4ecb Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 21 Aug 2018 22:24:02 +0200
Subject: [PATCH] Don't wait IR HAL to the infinity and beyond
Change-Id: I3afded27441bbee8244d5fda544b3e6d1238dc1b
---
.../core/java/com/android/server/ConsumerIrService.java | 7 -------
services/core/jni/com_android_server_ConsumerIrService.cpp | 2 +-
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/services/core/java/com/android/server/ConsumerIrService.java b/services/core/java/com/android/server/ConsumerIrService.java
index 2ed6c77baa0..82ec033bc30 100644
--- a/services/core/java/com/android/server/ConsumerIrService.java
+++ b/services/core/java/com/android/server/ConsumerIrService.java
@@ -46,13 +46,6 @@ public class ConsumerIrService extends IConsumerIrService.Stub {
mWakeLock.setReferenceCounted(true);
mHasNativeHal = halOpen();
- if (mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CONSUMER_IR)) {
- if (!mHasNativeHal) {
- throw new RuntimeException("FEATURE_CONSUMER_IR present, but no IR HAL loaded!");
- }
- } else if (mHasNativeHal) {
- throw new RuntimeException("IR HAL present, but FEATURE_CONSUMER_IR is not set!");
- }
}
@Override
diff --git a/services/core/jni/com_android_server_ConsumerIrService.cpp b/services/core/jni/com_android_server_ConsumerIrService.cpp
index 2ca348b3ae4..148fba9a688 100644
--- a/services/core/jni/com_android_server_ConsumerIrService.cpp
+++ b/services/core/jni/com_android_server_ConsumerIrService.cpp
@@ -36,7 +36,7 @@ static sp<IConsumerIr> mHal;
static jboolean halOpen(JNIEnv* /* env */, jobject /* obj */) {
// TODO(b/31632518)
- mHal = IConsumerIr::getService();
+ mHal = IConsumerIr::tryGetService();
return mHal != nullptr;
}
--
2.25.1

View File

@ -0,0 +1,39 @@
From 6befde035c29a499fd4320753909c98a2c239410 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Thu, 8 Nov 2018 23:04:03 +0100
Subject: [PATCH 10/25] Re-order services so that it works even without qtaguid
Change-Id: I0c0f527b3ae151d45c68f7ac6c205da3f34e74df
---
.../android/server/net/NetworkPolicyManagerService.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index d6557f6410e..e65edcdc12c 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -731,6 +731,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
Trace.traceBegin(Trace.TRACE_TAG_NETWORK, "systemReady");
final int oldPriority = Process.getThreadPriority(Process.myTid());
try {
+ mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
+ mAppStandby = LocalServices.getService(AppStandbyInternal.class);
+ mNetworkStats = LocalServices.getService(NetworkStatsManagerInternal.class);
+
// Boost thread's priority during system server init
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
if (!isBandwidthControlEnabled()) {
@@ -738,10 +742,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
return;
}
- mUsageStats = LocalServices.getService(UsageStatsManagerInternal.class);
- mAppStandby = LocalServices.getService(AppStandbyInternal.class);
- mNetworkStats = LocalServices.getService(NetworkStatsManagerInternal.class);
-
synchronized (mUidRulesFirstLock) {
synchronized (mNetworkPoliciesSecondLock) {
updatePowerSaveWhitelistUL();
--
2.17.1

View File

@ -0,0 +1,176 @@
From bff763fb4b54c97fbb3535ea68a093acf81969bc Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 24 Mar 2019 23:05:14 +0100
Subject: [PATCH] Support new samsung Pie and Q light hal and Samsung Power
HALs
Change-Id: I37dc7af3fbc6f9bfa2a4822d4dfba817e803945e
---
services/core/jni/Android.bp | 3 ++
...om_android_server_lights_LightsService.cpp | 51 +++++++++++++++++++
...droid_server_power_PowerManagerService.cpp | 22 ++++++++
3 files changed, 76 insertions(+)
diff --git a/services/core/jni/Android.bp b/services/core/jni/Android.bp
index 0b085d65e4c..36315e951e3 100644
--- a/services/core/jni/Android.bp
+++ b/services/core/jni/Android.bp
@@ -169,6 +169,9 @@ cc_defaults {
"suspend_control_aidl_interface-cpp",
"vendor.lineage.power@1.0",
"vendor.lineage.power-cpp",
+ "vendor.samsung.hardware.miscpower@2.0",
+ "vendor.samsung.hardware.light@2.0",
+ "vendor.samsung.hardware.light@3.0",
],
static_libs: [
diff --git a/services/core/jni/com_android_server_lights_LightsService.cpp b/services/core/jni/com_android_server_lights_LightsService.cpp
index 35d8219651d..b45b2137d0e 100644
--- a/services/core/jni/com_android_server_lights_LightsService.cpp
+++ b/services/core/jni/com_android_server_lights_LightsService.cpp
@@ -23,6 +23,10 @@
#include <android/hardware/light/2.0/ILight.h>
#include <android/hardware/light/2.0/types.h>
+#include <vendor/samsung/hardware/light/2.0/ISecLight.h>
+#include <vendor/samsung/hardware/light/2.0/types.h>
+#include <vendor/samsung/hardware/light/3.0/ISehLight.h>
+#include <vendor/samsung/hardware/light/3.0/types.h>
#include <android-base/chrono_utils.h>
#include <utils/misc.h>
#include <utils/Log.h>
@@ -40,8 +44,17 @@ using Type = ::android::hardware::light::V2_0::Type;
template<typename T>
using Return = ::android::hardware::Return<T>;
+using ISecLight = ::vendor::samsung::hardware::light::V2_0::ISecLight;
+using SecType = ::vendor::samsung::hardware::light::V2_0::SecType;
+using ISehLight = ::vendor::samsung::hardware::light::V3_0::ISehLight;
+using SehType = ::vendor::samsung::hardware::light::V3_0::SehType;
+using SehLightState = ::vendor::samsung::hardware::light::V3_0::SehLightState;
static bool sLightSupported = true;
+static sp<ISecLight> sSecHal;
+static sp<ISehLight> sSehHal;
+static bool sSecTried = false;
+
static bool validate(jint light, jint flash, jint brightness) {
bool valid = true;
@@ -152,6 +165,44 @@ static void setLight_native(
colorARGB = (colorAlpha << 24) + (colorARGB & 0x00FFFFFF);
}
+ if(!sSecTried) {
+ sSecHal = ISecLight::getService();
+ sSehHal = ISehLight::getService();
+ //sSecTried = true;
+ }
+
+ if(sSecHal != nullptr) {
+ SecType type = static_cast<SecType>(light);
+ LightState state = constructState(
+ colorARGB, flashMode, onMS, offMS, brightnessMode);
+
+ {
+ android::base::Timer t;
+ Return<Status> ret = sSecHal->setLightSec(type, state);
+ processReturn(ret, static_cast<Type>(light), state);
+ if (t.duration() > 50ms) ALOGD("Excessive delay setting light");
+ }
+ }
+
+ if(sSehHal != nullptr && light == 0 && flashMode == static_cast<jint>(Flash::HARDWARE)) {
+ SehType type = static_cast<SehType>(light);
+ SehLightState state {};
+ state.flashMode = Flash::NONE;
+ Brightness brightness = static_cast<Brightness>(brightnessMode);
+ state.brightnessMode = brightness;
+ state.extendedBrightness = colorARGB;
+
+ {
+ android::base::Timer t;
+ Return<Status> ret = sSehHal->sehSetLight(type, state);
+ if(!ret.isOk()) {
+ ALOGE("Failed to issue set light command.");
+ }
+ if (t.duration() > 50ms) ALOGD("Excessive delay setting light");
+ }
+ return;
+ }
+
Type type = static_cast<Type>(light);
LightState state = constructState(
colorARGB, flashMode, onMS, offMS, brightnessMode);
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
index 61d53351af5..dcd33366a35 100644
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
@@ -24,6 +24,7 @@
#include <android/hardware/power/Mode.h>
#include <android/system/suspend/1.0/ISystemSuspend.h>
#include <android/system/suspend/ISuspendControlService.h>
+#include <vendor/samsung/hardware/miscpower/2.0/ISehMiscPower.h>
#include <nativehelper/JNIHelp.h>
#include <vendor/lineage/power/1.0/ILineagePower.h>
#include <vendor/lineage/power/IPower.h>
@@ -69,6 +70,7 @@ using LineageBoostAidl = vendor::lineage::power::Boost;
using LineageFeatureV1_0 = vendor::lineage::power::V1_0::LineageFeature;
using LineageFeatureAidl = vendor::lineage::power::Feature;
using LineagePowerHint1_0 = vendor::lineage::power::V1_0::LineagePowerHint;
+using ISehMiscPower = vendor::samsung::hardware::miscpower::V2_0::ISehMiscPower;
namespace android {
@@ -86,6 +88,8 @@ static sp<IPowerV1_1> gPowerHalHidlV1_1_ = nullptr;
static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
static sp<ILineagePowerAidl> gLineagePowerHalAidl_ = nullptr;
+static sp<ISehMiscPower> gSehMiscPower = nullptr;
+static bool gPowerHalExists = true;
static std::mutex gPowerHalMutex;
static std::mutex gLineagePowerHalMutex;
@@ -132,6 +136,10 @@ static HalVersion connectPowerHalLocked() {
gPowerHalAidlExists = false;
}
}
+ if (gPowerHalExists && gPowerHalHidlV1_0_ == nullptr) {
+ gSehMiscPower = ISehMiscPower::getService();
+ gPowerHalHidlV1_0_ = IPowerV1_0::getService("miscpower");
+ }
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
if (gPowerHalHidlV1_0_) {
@@ -190,6 +198,12 @@ static HalVersion connectLineagePowerHalLocked() {
return HalVersion::NONE;
}
+sp<ISehMiscPower> getSehMiscPower() {
+ std::lock_guard<std::mutex> lock(gPowerHalMutex);
+ connectPowerHalLocked();
+ return gSehMiscPower;
+}
+
// Retrieve a copy of PowerHAL HIDL V1_0
sp<IPowerV1_0> getPowerHalHidlV1_0() {
std::lock_guard<std::mutex> lock(gPowerHalMutex);
@@ -559,6 +573,14 @@ static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean
return;
}
}
+ sp<ISehMiscPower> sehMiscPower = getSehMiscPower();
+ if(sehMiscPower != nullptr) {
+ android::base::Timer t;
+ Return<void> ret = sehMiscPower->setInteractiveAsync(enable, 0);
+ if(!ret.isOk()) {
+ ALOGE("set interactive async() failed: seh misc setInteractiveAsync");
+ }
+ }
}
static void nativeSetAutoSuspend(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
--
2.25.1

View File

@ -0,0 +1,29 @@
From ea68a77524fc2cbfa571d7afa01442460b3ea284 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 2 Jul 2019 21:19:29 +0200
Subject: [PATCH 12/25] Make Samsung fingerprint broken HAL overridable
Change-Id: I8be38daa7c80fdb61e9209f12215e6daea171d03
---
.../server/biometrics/fingerprint/FingerprintService.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
index c247731be13..5552086c17f 100644
--- a/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/biometrics/fingerprint/FingerprintService.java
@@ -590,8 +590,10 @@ public class FingerprintService extends BiometricServiceBase {
groupId, fingerId, deviceId);
int remaining2 = remaining;
+ int overrideSamsung = android.os.SystemProperties.getInt("persist.sys.phh.samsung_fingerprint", -1);
+
String fp = android.os.SystemProperties.get("ro.vendor.build.fingerprint");
- if(fp != null && (fp.contains("starlte") || fp.contains("star2lte") || fp.contains("starqlte") || fp.contains("star2qlte")))
+ if(overrideSamsung == 1 || (overrideSamsung != 0 && fp != null && fp.startsWith("samsung/")))
remaining2 = 100 - remaining2;
FingerprintService.super.handleEnrollResult(fingerprint, remaining2);
--
2.17.1

View File

@ -0,0 +1,38 @@
From e9848dbafb20526eed8e5d8dfbd2df01b240cab8 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 11 Aug 2019 10:30:37 +0200
Subject: [PATCH 13/25] Add property to use linear brightness slider
Change-Id: I1af7eb923779fa60c7a735904ba8fc82d0622c1d
---
.../com/android/settingslib/display/BrightnessUtils.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
index 4f86afaa995..f1fe73a6a1d 100644
--- a/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/display/BrightnessUtils.java
@@ -51,7 +51,12 @@ public class BrightnessUtils {
* @param max The maximum acceptable value for the setting.
* @return The corresponding setting value.
*/
+ private static final boolean useLinearBrightness = android.os.SystemProperties.getBoolean("persist.sys.phh.linear_brightness", false);
public static final int convertGammaToLinear(int val, int min, int max) {
+ if(useLinearBrightness) {
+ if(val < 4) return 1;
+ return val/4;
+ }
final float normalizedVal = MathUtils.norm(GAMMA_SPACE_MIN, GAMMA_SPACE_MAX, val);
final float ret;
if (normalizedVal <= R) {
@@ -127,6 +132,7 @@ public class BrightnessUtils {
* @return The corresponding slider value
*/
public static final int convertLinearToGammaFloat(float val, float min, float max) {
+ if(useLinearBrightness) return (int)(val*4);
// For some reason, HLG normalizes to the range [0, 12] rather than [0, 1]
final float normalizedVal = MathUtils.norm(min, max, val) * 12;
final float ret;
--
2.17.1

View File

@ -0,0 +1,45 @@
From 33ba0d099de0181f34b3795ad5b2ee25d8c252a4 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 12 Aug 2019 23:08:26 +0200
Subject: [PATCH 14/25] Add support for samsung touch proximity sensor as
fallback to real proximity sensor
---
.../server/display/DisplayPowerController.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 9411c562945..774e5a38777 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -527,6 +527,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ if(mProximitySensor == null) {
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
+ for(Sensor sensor: sensors) {
+ if("com.samsung.sensor.touch_proximity".equals(sensor.getStringType()))
+ mProximitySensor = sensor;
+ }
+ }
if (mProximitySensor != null) {
mProximityThreshold = Math.min(mProximitySensor.getMaximumRange(),
TYPICAL_PROXIMITY_THRESHOLD);
@@ -1970,6 +1977,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
public void onSensorChanged(SensorEvent event) {
if (mProximitySensorEnabled) {
final long time = SystemClock.uptimeMillis();
+ if("com.samsung.sensor.touch_proximity".equals(mProximitySensor.getStringType())) {
+ int v = (int)event.values[0];
+ boolean positive = (v <= 4);
+ android.util.Log.d("PHH", "Samsung sensor changed " + positive + ":" + v);
+ handleProximitySensorEvent(time, positive);
+ return;
+ }
final float distance = event.values[0];
boolean positive = distance >= 0.0f && distance < mProximityThreshold;
handleProximitySensorEvent(time, positive);
--
2.17.1

View File

@ -0,0 +1,31 @@
From 298c7cd14541920c09b4bbcfb3255ec1ddcaad67 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 14 Aug 2019 23:36:45 +0200
Subject: [PATCH 15/25] Also add com.samsung.sensor.physical_proximity (if
available, it is more a true proximity sensor than touch proximity sensor)
---
.../com/android/server/display/DisplayPowerController.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 774e5a38777..4c12ebbd94f 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -527,6 +527,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ if(mProximitySensor == null) {
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
+ for(Sensor sensor: sensors) {
+ if("com.samsung.sensor.physical_proximity".equals(sensor.getStringType()))
+ mProximitySensor = sensor;
+ }
+ }
if(mProximitySensor == null) {
List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
for(Sensor sensor: sensors) {
--
2.17.1

View File

@ -0,0 +1,56 @@
From d2cdf9ba6dc99f28c94e093078c1307dd4414a56 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Thu, 2 Jan 2020 10:16:49 +0800
Subject: [PATCH] fix crashing on devices with higher aspect ratio down to
sw288dp
* This is what the Qin 2 (Pro) is.
Change-Id: Ia39682b327fcf947f06219ce2dab996f53dcb01d
---
.../SystemUI/res/values-sw288dp/dimens.xml | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 packages/SystemUI/res/values-sw288dp/dimens.xml
diff --git a/packages/SystemUI/res/values-sw288dp/dimens.xml b/packages/SystemUI/res/values-sw288dp/dimens.xml
new file mode 100644
index 00000000000..40adc2e6879
--- /dev/null
+++ b/packages/SystemUI/res/values-sw288dp/dimens.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2019 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
+ -->
+<resources>
+ <!-- Global actions grid -->
+ <dimen name="global_actions_grid_vertical_padding">3dp</dimen>
+ <dimen name="global_actions_grid_horizontal_padding">3dp</dimen>
+
+ <dimen name="global_actions_grid_item_side_margin">5dp</dimen>
+ <dimen name="global_actions_grid_item_vertical_margin">4dp</dimen>
+ <dimen name="global_actions_grid_item_width">64dp</dimen>
+ <dimen name="global_actions_grid_item_height">64dp</dimen>
+
+ <dimen name="global_actions_grid_item_icon_width">20dp</dimen>
+ <dimen name="global_actions_grid_item_icon_height">20dp</dimen>
+ <dimen name="global_actions_grid_item_icon_top_margin">12dp</dimen>
+ <dimen name="global_actions_grid_item_icon_side_margin">22dp</dimen>
+ <dimen name="global_actions_grid_item_icon_bottom_margin">4dp</dimen>
+
+</resources>
--
2.25.1

View File

@ -0,0 +1,28 @@
From 76cbbb0d09a80eaad75c64281d635e58976bd5be Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 1 Mar 2020 18:14:40 +0100
Subject: [PATCH 17/25] Remove orientation 4 from sensor earlier in the process
chain
Change-Id: Id8e2e860a73d417fc70db6cf5fc5fa5ef187aa50
---
.../com/android/server/policy/WindowOrientationListener.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/services/core/java/com/android/server/policy/WindowOrientationListener.java b/services/core/java/com/android/server/policy/WindowOrientationListener.java
index 0157706866c..732417b88f4 100644
--- a/services/core/java/com/android/server/policy/WindowOrientationListener.java
+++ b/services/core/java/com/android/server/policy/WindowOrientationListener.java
@@ -1055,6 +1055,9 @@ public abstract class WindowOrientationListener {
synchronized (mLock) {
mDesiredRotation = reportedRotation;
+ if(mDesiredRotation >= 4 || mDesiredRotation < 0) {
+ mDesiredRotation = 0;
+ }
newRotation = evaluateRotationChangeLocked();
}
if (newRotation >=0) {
--
2.17.1

View File

@ -0,0 +1,39 @@
From 0dc5a490d8aac60ce2ed3efafc9f6bcb6ced71f4 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 10 Mar 2020 23:30:17 +0100
Subject: [PATCH 18/25] Allow disabling of fingerprint cleanups, needed on some
Realme devices that cant enumerate
Change-Id: I8a486e707712b81711fb1a691faec029499fa897
---
.../android/server/biometrics/BiometricServiceBase.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/services/core/java/com/android/server/biometrics/BiometricServiceBase.java b/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
index 75452ea5fb6..fd77ada1109 100644
--- a/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
+++ b/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
@@ -344,6 +344,7 @@ public abstract class BiometricServiceBase extends SystemService
private List<? extends BiometricAuthenticator.Identifier> mEnrolledList;
// List of templates to remove from the HAL
private List<BiometricAuthenticator.Identifier> mUnknownHALTemplates = new ArrayList<>();
+ final boolean mNocleanup = android.os.SystemProperties.getBoolean("persist.sys.phh.fingerprint.nocleanup", false);
InternalEnumerateClient(Context context,
DaemonWrapper daemon, long halDeviceId, IBinder token,
@@ -389,8 +390,10 @@ public abstract class BiometricServiceBase extends SystemService
Slog.e(getTag(), "doTemplateCleanup(): Removing dangling template from framework: "
+ identifier.getBiometricId() + " "
+ identifier.getName());
- mUtils.removeBiometricForUser(getContext(),
- getTargetUserId(), identifier.getBiometricId());
+ if(!mNocleanup) {
+ mUtils.removeBiometricForUser(getContext(),
+ getTargetUserId(), identifier.getBiometricId());
+ }
FrameworkStatsLog.write(FrameworkStatsLog.BIOMETRIC_SYSTEM_HEALTH_ISSUE_DETECTED,
statsModality(),
BiometricsProtoEnums.ISSUE_UNKNOWN_TEMPLATE_ENROLLED_FRAMEWORK);
--
2.17.1

View File

@ -0,0 +1,32 @@
From dc92080dc096ff77e5d751026d24decc1e424ca9 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 5 Apr 2020 16:32:46 +0200
Subject: [PATCH 20/25] Always allow overriding the number of work profiles
Change-Id: I6eb09aa71663c6fbe7563e3038bffcabdba0ff6a
---
.../java/com/android/server/pm/UserManagerService.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 27924a68ff4..4d687679f59 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -5282,12 +5282,8 @@ public class UserManagerService extends IUserManager.Stub {
*/
private static int getMaxUsersOfTypePerParent(UserTypeDetails userTypeDetails) {
final int defaultMax = userTypeDetails.getMaxAllowedPerParent();
- if (!Build.IS_DEBUGGABLE) {
- return defaultMax;
- } else {
- if (userTypeDetails.isManagedProfile()) {
- return SystemProperties.getInt("persist.sys.max_profiles", defaultMax);
- }
+ if (userTypeDetails.isManagedProfile()) {
+ return SystemProperties.getInt("persist.sys.max_profiles", defaultMax);
}
return defaultMax;
}
--
2.17.1

View File

@ -0,0 +1,26 @@
From 3be1d7309cb7c496963c5d391b53ad3932563282 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 6 Jun 2020 18:21:56 +0200
Subject: [PATCH] HOME deserves to wake-up devices just as well as back and
menu
Change-Id: Ia562bafd8c620d00c17e8eb338e4701c6c4a3c3a
---
core/java/android/view/KeyEvent.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 144dd8b3c36..9a704296bbf 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -1977,6 +1977,7 @@ public class KeyEvent extends InputEvent implements Parcelable {
case KeyEvent.KEYCODE_CAMERA:
case KeyEvent.KEYCODE_FOCUS:
case KeyEvent.KEYCODE_MENU:
+ case KeyEvent.KEYCODE_HOME:
case KeyEvent.KEYCODE_PAIRING:
case KeyEvent.KEYCODE_STEM_1:
case KeyEvent.KEYCODE_STEM_2:
--
2.25.1

View File

@ -0,0 +1,33 @@
From b8adbf5e35d5d1e40077b3226ad3f842fc9be6dc Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 21 Sep 2020 10:30:18 +0200
Subject: [PATCH 23/25] On old inits (A-only devices), multi-sim basedband
property too long, catch that and make it shorter
Change-Id: I2f52595409f0d43b148063d5fd90c80d1182ff8c
---
telephony/java/android/telephony/TelephonyManager.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 8ae1ee99b06..4659c7909bc 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -10104,7 +10104,13 @@ public class TelephonyManager {
if (SubscriptionManager.isValidPhoneId(phoneId)) {
List<String> newList = updateTelephonyProperty(
TelephonyProperties.baseband_version(), phoneId, version);
- TelephonyProperties.baseband_version(newList);
+ try {
+ TelephonyProperties.baseband_version(newList);
+ } catch(java.lang.IllegalArgumentException e) {
+ List<String> list = new ArrayList<>();
+ list.add(newList.get(0));
+ TelephonyProperties.baseband_version(list);
+ }
}
}
--
2.17.1

View File

@ -0,0 +1,28 @@
From 11dae80179722994abd9e3501e6c14d4393c4c93 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 29 Sep 2020 22:39:47 +0200
Subject: [PATCH 24/25] Some devices have proximity sensor reporting NaN as max
range for some reason. Make them behave standard way by setting 5 cm
Change-Id: I3c39e3e914a05903c140235702e0480d2d58a612
---
.../com/android/server/display/DisplayPowerController.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 4c12ebbd94f..01f367e8a2f 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -544,6 +544,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
if (mProximitySensor != null) {
mProximityThreshold = Math.min(mProximitySensor.getMaximumRange(),
TYPICAL_PROXIMITY_THRESHOLD);
+ if(Float.isNaN(mProximityThreshold)) {
+ mProximityThreshold = 5.0f;
+ }
}
}
mCurrentScreenBrightnessSetting = getScreenBrightnessSetting();
--
2.17.1

View File

@ -0,0 +1,37 @@
From c341fe6ac6366d2e78b8ec69d11729180ab5cb84 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 29 Sep 2020 22:40:10 +0200
Subject: [PATCH 25/25] Fix brightness range not being complete on Samsung
devices
On some devices, minimum brightness is 0, which totally messes with
Brightness computations (minimum float brightness becomes -1.0 instead
of 0.0...).
Cheat and have them report 1 as minimum instead, which fixes the slope
Change-Id: I4d97cbc32490949e83272b81ec6320a5483310b1
---
.../java/com/android/server/power/PowerManagerService.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 764ac969e18..40aeb32c40a 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -913,9 +913,11 @@ public final class PowerManagerService extends SystemService
if (min == INVALID_BRIGHTNESS_IN_CONFIG || max == INVALID_BRIGHTNESS_IN_CONFIG
|| def == INVALID_BRIGHTNESS_IN_CONFIG) {
+ int correctedMin = mContext.getResources().getInteger(com.android.internal.R.integer
+ .config_screenBrightnessSettingMinimum);
+ if(correctedMin == 0) correctedMin = 1;
mScreenBrightnessMinimum = BrightnessSynchronizer.brightnessIntToFloat(
- mContext.getResources().getInteger(com.android.internal.R.integer
- .config_screenBrightnessSettingMinimum),
+ correctedMin,
PowerManager.BRIGHTNESS_OFF + 1, PowerManager.BRIGHTNESS_ON,
PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX);
mScreenBrightnessMaximum = BrightnessSynchronizer.brightnessIntToFloat(
--
2.17.1

View File

@ -0,0 +1,37 @@
From cbe557557ea73ea8fef866f362c869daf4c3be51 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 25 Oct 2020 23:57:26 +0100
Subject: [PATCH 26/26] Re-implement fnmatch-like behaviour for RRO java-side
Change-Id: Id38292a9a1453aa87b8401c1fdb390fa4e63c7d1
---
core/java/android/content/pm/PackageParser.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 70e4e6cbf62..a4d8941d1e5 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2476,8 +2476,17 @@ public class PackageParser {
for (int i = 0; i < propNames.length; i++) {
// Check property value: make sure it is both set and equal to expected value
final String currValue = SystemProperties.get(propNames[i]);
- if (!TextUtils.equals(currValue, propValues[i])) {
- return false;
+ final String value = propValues[i];
+ if(value.startsWith("+")) {
+ final java.util.regex.Pattern regex = java.util.regex.Pattern.compile(value.substring(1, value.length()).replace("*", ".*"));
+ java.util.regex.Matcher matcher = regex.matcher(currValue);
+ if (!matcher.find()) {
+ return false;
+ }
+ } else {
+ if(!value.equals(currValue)) {
+ return false;
+ }
}
}
return true;
--
2.17.1

View File

@ -0,0 +1,157 @@
From 772f3c12ec0676d9e22eea8a005ddf302ad09940 Mon Sep 17 00:00:00 2001
From: Danny Lin <danny@kdrag0n.dev>
Date: Mon, 5 Oct 2020 12:36:35 -0700
Subject: [PATCH 27/27] Add support for app signature spoofing
This is needed by microG GmsCore to pretend to be the official Google
Play Services package, because client apps check the package signature
to make sure it matches Google's official certificate.
This was forward-ported from the Android 10 patch by gudenau:
https://github.com/microg/android_packages_apps_GmsCore/pull/957
Changes made for Android 11:
- Updated PackageInfo calls
- Added new permission to public API surface, needed for
PermissionController which is now an updatable APEX on 11
- Added a dummy permission group to allow users to manage the
permission through the PermissionController UI
(by Vachounet <vachounet@live.fr>)
- Updated location provider comment for conciseness
Change made by PHH:
- Permission is exposed as "privileged" rather than "dangerous", so that
apps need to be in system;product's priv-app
Change-Id: Ied7d6ce0b83a2d2345c3abba0429998d86494a88
---
api/current.txt | 1 +
core/res/AndroidManifest.xml | 7 ++++++
core/res/res/values/config.xml | 2 ++
core/res/res/values/strings.xml | 12 ++++++++++
non-updatable-api/current.txt | 1 +
.../server/pm/PackageManagerService.java | 23 +++++++++++++++++--
6 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/api/current.txt b/api/current.txt
index 952ccdad992..73fb59fedab 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -79,6 +79,7 @@ package android {
field public static final String DUMP = "android.permission.DUMP";
field public static final String EXPAND_STATUS_BAR = "android.permission.EXPAND_STATUS_BAR";
field public static final String FACTORY_TEST = "android.permission.FACTORY_TEST";
+ field public static final String FAKE_PACKAGE_SIGNATURE = "android.permission.FAKE_PACKAGE_SIGNATURE";
field public static final String FOREGROUND_SERVICE = "android.permission.FOREGROUND_SERVICE";
field public static final String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
field public static final String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 9945057f0e9..e1adee20ccf 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2829,6 +2829,13 @@
android:description="@string/permdesc_getPackageSize"
android:protectionLevel="normal" />
+ <!-- Allows an application to change the package signature as
+ seen by applications -->
+ <permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE"
+ android:protectionLevel="signature|privileged"
+ android:label="@string/permlab_fakePackageSignature"
+ android:description="@string/permdesc_fakePackageSignature" />
+
<!-- @deprecated No longer useful, see
{@link android.content.pm.PackageManager#addPackageToPreferred}
for details. -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index d21930f31df..372319ed32b 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1646,6 +1646,8 @@
<string-array name="config_locationProviderPackageNames" translatable="false">
<!-- The standard AOSP fused location provider -->
<item>com.android.location.fused</item>
+ <!-- Google Play Services or microG (free reimplementation) location provider -->
+ <item>com.google.android.gms</item>
</string-array>
<!-- This string array can be overriden to enable test location providers initially. -->
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 4f9911fbe38..32f2dbf33d3 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -847,6 +847,18 @@
<!-- Permissions -->
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_fakePackageSignature">Spoof package signature</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_fakePackageSignature">Allows the app to pretend to be a different app. Malicious applications might be able to use this to access private application data. Legitimate uses include an emulator pretending to be what it emulates. Grant this permission with caution only!</string>
+ <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permgrouplab_fake_package_signature">Spoof package signature</string>
+ <!-- Description of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permgroupdesc_fake_package_signature">allow to spoof package signature</string>
+ <!-- Message shown to the user when the apps requests permission from this group. If ever possible this should stay below 80 characters (assuming the parameters takes 20 characters). Don't abbreviate until the message reaches 120 characters though. [CHAR LIMIT=120] -->
+ <string name="permgrouprequest_fake_package_signature">Allow
+ &lt;b><xliff:g id="app_name" example="Gmail">%1$s</xliff:g>&lt;/b> to spoof package signature?</string>
+
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_statusBar">disable or modify status bar</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt
index 5f15216e840..c29feb9cd7b 100644
--- a/non-updatable-api/current.txt
+++ b/non-updatable-api/current.txt
@@ -79,6 +79,7 @@ package android {
field public static final String DUMP = "android.permission.DUMP";
field public static final String EXPAND_STATUS_BAR = "android.permission.EXPAND_STATUS_BAR";
field public static final String FACTORY_TEST = "android.permission.FACTORY_TEST";
+ field public static final String FAKE_PACKAGE_SIGNATURE = "android.permission.FAKE_PACKAGE_SIGNATURE";
field public static final String FOREGROUND_SERVICE = "android.permission.FOREGROUND_SERVICE";
field public static final String GET_ACCOUNTS = "android.permission.GET_ACCOUNTS";
field public static final String GET_ACCOUNTS_PRIVILEGED = "android.permission.GET_ACCOUNTS_PRIVILEGED";
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index c3c655d632e..f7faf418fb4 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -4395,8 +4395,9 @@ public class PackageManagerService extends IPackageManager.Stub
});
}
- PackageInfo packageInfo = PackageInfoUtils.generate(p, gids, flags,
- ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId, ps);
+ PackageInfo packageInfo = mayFakeSignature(p, PackageInfoUtils.generate(p, gids, flags,
+ ps.firstInstallTime, ps.lastUpdateTime, permissions, state, userId, ps),
+ permissions);
if (packageInfo == null) {
return null;
@@ -4432,6 +4433,24 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
+ private PackageInfo mayFakeSignature(AndroidPackage p, PackageInfo pi,
+ Set<String> permissions) {
+ try {
+ if (permissions.contains("android.permission.FAKE_PACKAGE_SIGNATURE")
+ && p.getTargetSdkVersion() > Build.VERSION_CODES.LOLLIPOP_MR1
+ && p.getMetaData() != null) {
+ String sig = p.getMetaData().getString("fake-signature");
+ if (sig != null) {
+ pi.signatures = new Signature[] {new Signature(sig)};
+ }
+ }
+ } catch (Throwable t) {
+ // We should never die because of any failures, this is system code!
+ Log.w("PackageManagerService.FAKE_PACKAGE_SIGNATURE", t);
+ }
+ return pi;
+ }
+
@Override
public void checkPackageStartable(String packageName, int userId) {
final int callingUid = Binder.getCallingUid();
--
2.17.1

View File

@ -0,0 +1,91 @@
From 014ba558076692fb0009b0100c4f18a6800e30ac Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 6 Dec 2020 12:20:08 +0100
Subject: [PATCH] Make rounded corners padding overridable with
persist.sys.phh.rounded_corners_padding
Change-Id: Id5d73b06b9a2cb2da95ff31f204c1984555872ff
---
.../src/com/android/systemui/qs/QuickStatusBarHeader.java | 6 +++++-
.../systemui/statusbar/phone/KeyguardStatusBarView.java | 6 +++++-
.../systemui/statusbar/phone/PhoneStatusBarView.java | 6 +++++-
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
index 7533f2ac1db..94fd996d085 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickStatusBarHeader.java
@@ -32,6 +32,7 @@ import android.graphics.Rect;
import android.media.AudioManager;
import android.os.Handler;
import android.os.Looper;
+import android.os.SystemProperties;
import android.provider.AlarmClock;
import android.provider.Settings;
import android.service.notification.ZenModeConfig;
@@ -447,8 +448,11 @@ public class QuickStatusBarHeader extends RelativeLayout implements
Resources resources = mContext.getResources();
updateMinimumHeight();
- mRoundedCornerPadding = resources.getDimensionPixelSize(
+ mRoundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if (mRoundedCornerPadding == -1) {
+ mRoundedCornerPadding = resources.getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
+ }
mStatusBarPaddingTop = resources.getDimensionPixelSize(R.dimen.status_bar_padding_top);
// Update height for a few views, especially due to landscape mode restricting space.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
index 8a4ea21a11c..a54269460e5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -25,6 +25,7 @@ import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.TypedValue;
@@ -186,8 +187,11 @@ public class KeyguardStatusBarView extends RelativeLayout
R.dimen.system_icons_super_container_avatarless_margin_end);
mCutoutSideNudge = getResources().getDimensionPixelSize(
R.dimen.display_cutout_margin_consumption);
- mRoundedCornerPadding = res.getDimensionPixelSize(
+ mRoundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if (mRoundedCornerPadding == -1) {
+ mRoundedCornerPadding = res.getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
+ }
}
private void updateVisibilities() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 1c6c7db6a69..f0e5c7bb3d2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.RemoteException;
+import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.EventLog;
import android.util.Pair;
@@ -331,8 +332,11 @@ public class PhoneStatusBarView extends PanelBar implements Callbacks {
public void updateResources() {
mCutoutSideNudge = getResources().getDimensionPixelSize(
R.dimen.display_cutout_margin_consumption);
- mRoundedCornerPadding = getResources().getDimensionPixelSize(
+ mRoundedCornerPadding = SystemProperties.getInt("persist.sys.phh.rounded_corners_padding", -1);
+ if (mRoundedCornerPadding == -1) {
+ mRoundedCornerPadding = getResources().getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
+ }
updateStatusBarHeight();
}
--
2.25.1

View File

@ -0,0 +1,26 @@
From 54222334328e1bf9202ca95a941894ce48758c40 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 11 Dec 2020 14:41:09 +0100
Subject: [PATCH 30/35] Remove useless notification about "console" service
being running
---
.../core/java/com/android/server/am/ActivityManagerService.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 091c77ecaac..df72122a4c5 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -5563,7 +5563,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
private void showConsoleNotificationIfActive() {
- if (!SystemProperties.get("init.svc.console").equals("running")) {
+ if (!SystemProperties.get("init.svc.console").equals("running") || true) {
return;
}
String title = mContext
--
2.25.1

View File

@ -0,0 +1,25 @@
From 9d2d5c8b106404769d8e6c2bebd4a2779fd2f21f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 13 Dec 2020 01:38:50 +0100
Subject: [PATCH 31/35] [Tethering] Ignore DUN required and always use main APN
---
.../android/networkstack/tethering/TetheringConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java b/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
index e1771a56137..65d17ffa54b 100644
--- a/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
+++ b/packages/Tethering/src/com/android/networkstack/tethering/TetheringConfiguration.java
@@ -132,7 +132,7 @@ public class TetheringConfiguration {
tetherableBluetoothRegexs = getResourceStringArray(
res, R.array.config_tether_bluetooth_regexs);
- isDunRequired = checkDunRequired(ctx);
+ isDunRequired = false;
chooseUpstreamAutomatically = getResourceBoolean(
res, R.bool.config_tether_upstream_automatic, false /** defaultValue */);
--
2.25.1

View File

@ -0,0 +1,95 @@
From e8f19bb6d060133e461791fc51c243f081fc00d0 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 16 Dec 2020 21:24:12 +0800
Subject: [PATCH 32/35] Revert "Remove unused SystemProperties.set"
This reverts commit debb4616ef67f9ed5054eca51ec58592358ff55f.
* Needed for SPRD IMS
---
.../android/telephony/TelephonyManager.java | 69 +++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 1b197b00069..89147084043 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -7033,6 +7033,75 @@ public class TelephonyManager {
}
}
+ /**
+ * Sets a per-phone telephony property with the value specified.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public static void setTelephonyProperty(int phoneId, String property, String value) {
+ String propVal = "";
+ String p[] = null;
+ String prop = SystemProperties.get(property);
+
+ if (value == null) {
+ value = "";
+ }
+ value.replace(',', ' ');
+ if (prop != null) {
+ p = prop.split(",");
+ }
+
+ if (!SubscriptionManager.isValidPhoneId(phoneId)) {
+ Rlog.d(TAG, "setTelephonyProperty: invalid phoneId=" + phoneId +
+ " property=" + property + " value: " + value + " prop=" + prop);
+ return;
+ }
+
+ for (int i = 0; i < phoneId; i++) {
+ String str = "";
+ if ((p != null) && (i < p.length)) {
+ str = p[i];
+ }
+ propVal = propVal + str + ",";
+ }
+
+ propVal = propVal + value;
+ if (p != null) {
+ for (int i = phoneId + 1; i < p.length; i++) {
+ propVal = propVal + "," + p[i];
+ }
+ }
+
+ int propValLen = propVal.length();
+ try {
+ propValLen = propVal.getBytes("utf-8").length;
+ } catch (java.io.UnsupportedEncodingException e) {
+ Rlog.d(TAG, "setTelephonyProperty: utf-8 not supported");
+ }
+ if (propValLen > SystemProperties.PROP_VALUE_MAX) {
+ Rlog.d(TAG, "setTelephonyProperty: property too long phoneId=" + phoneId +
+ " property=" + property + " value: " + value + " propVal=" + propVal);
+ return;
+ }
+
+ SystemProperties.set(property, propVal);
+ }
+
+ /**
+ * Sets a global telephony property with the value specified.
+ *
+ * @hide
+ */
+ public static void setTelephonyProperty(String property, String value) {
+ if (value == null) {
+ value = "";
+ }
+ Rlog.d(TAG, "setTelephonyProperty: success" + " property=" +
+ property + " value: " + value);
+ SystemProperties.set(property, value);
+ }
+
/**
* Inserts or updates a list property. Expands the list if its length is not enough.
*/
--
2.25.1

View File

@ -0,0 +1,84 @@
From 7268f850f701698f948f37a7d5bfac3cc4dae644 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 16 Dec 2020 13:46:15 +0800
Subject: [PATCH 33/35] TelephonyManager: bring back getNetworkClass()
This partially reverts commit c058cac051ab083dc7fb7ea6aa85699110b2e9bf.
* Needed by Spreadtrum IMS
---
.../android/telephony/TelephonyManager.java | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 89147084043..f470d4595c3 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -3135,6 +3135,64 @@ public class TelephonyManager {
}
}
+ /**
+ * Network Class Definitions.
+ * Do not change this order, it is used for sorting during emergency calling in
+ * {@link TelephonyConnectionService#getFirstPhoneForEmergencyCall()}. Any newer technologies
+ * should be added after the current definitions.
+ */
+ /** Unknown network class. {@hide} */
+ public static final int NETWORK_CLASS_UNKNOWN = 0;
+ /** Class of broadly defined "2G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_2_G = 1;
+ /** Class of broadly defined "3G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_3_G = 2;
+ /** Class of broadly defined "4G" networks. {@hide} */
+ @UnsupportedAppUsage
+ public static final int NETWORK_CLASS_4_G = 3;
+ /** Class of broadly defined "5G" networks. {@hide} */
+ public static final int NETWORK_CLASS_5_G = 4;
+
+ /**
+ * Return general class of network type, such as "3G" or "4G". In cases
+ * where classification is contentious, this method is conservative.
+ *
+ * @hide
+ */
+ @UnsupportedAppUsage
+ public static int getNetworkClass(int networkType) {
+ switch (networkType) {
+ case NETWORK_TYPE_GPRS:
+ case NETWORK_TYPE_GSM:
+ case NETWORK_TYPE_EDGE:
+ case NETWORK_TYPE_CDMA:
+ case NETWORK_TYPE_1xRTT:
+ case NETWORK_TYPE_IDEN:
+ return NETWORK_CLASS_2_G;
+ case NETWORK_TYPE_UMTS:
+ case NETWORK_TYPE_EVDO_0:
+ case NETWORK_TYPE_EVDO_A:
+ case NETWORK_TYPE_HSDPA:
+ case NETWORK_TYPE_HSUPA:
+ case NETWORK_TYPE_HSPA:
+ case NETWORK_TYPE_EVDO_B:
+ case NETWORK_TYPE_EHRPD:
+ case NETWORK_TYPE_HSPAP:
+ case NETWORK_TYPE_TD_SCDMA:
+ return NETWORK_CLASS_3_G;
+ case NETWORK_TYPE_LTE:
+ case NETWORK_TYPE_IWLAN:
+ case NETWORK_TYPE_LTE_CA:
+ return NETWORK_CLASS_4_G;
+ case NETWORK_TYPE_NR:
+ return NETWORK_CLASS_5_G;
+ default:
+ return NETWORK_CLASS_UNKNOWN;
+ }
+ }
+
/**
* Returns a string representation of the radio technology (network type)
* currently in use on the device.
--
2.25.1

View File

@ -0,0 +1,41 @@
From 04a8e10d1ac42ade9e707081920940931bc80f07 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Wed, 16 Dec 2020 21:26:45 +0800
Subject: [PATCH 34/35] TelephonyManager: add API annotations for
setTelephonyProperty
* This method was added back by reverting commit
debb4616ef67f9ed5054eca51ec58592358ff55f, but they do not conform to
the new R API requirements.
* R requires such annotations.
---
telephony/java/android/telephony/TelephonyManager.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index f470d4595c3..4b912e88798 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -7097,7 +7097,7 @@ public class TelephonyManager {
* @hide
*/
@UnsupportedAppUsage
- public static void setTelephonyProperty(int phoneId, String property, String value) {
+ public static void setTelephonyProperty(int phoneId, @NonNull String property, @Nullable String value) {
String propVal = "";
String p[] = null;
String prop = SystemProperties.get(property);
@@ -7151,7 +7151,8 @@ public class TelephonyManager {
*
* @hide
*/
- public static void setTelephonyProperty(String property, String value) {
+ @UnsupportedAppUsage
+ public static void setTelephonyProperty(@NonNull String property, @Nullable String value) {
if (value == null) {
value = "";
}
--
2.25.1

View File

@ -0,0 +1,72 @@
From 368af07a0fc4fbed6f6946c8bf8237702841d914 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 18 Dec 2020 16:38:58 -0500
Subject: [PATCH] Fix Samsung Power HAL (switch/case was filled with
mines/returns), and cleanup code and add logs
---
...droid_server_power_PowerManagerService.cpp | 25 +++++++++++--------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
index dcd33366a35..298cd8c7171 100644
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
@@ -89,7 +89,6 @@ static sp<IPowerAidl> gPowerHalAidl_ = nullptr;
static sp<ILineagePowerV1_0> gLineagePowerHalV1_0_ = nullptr;
static sp<ILineagePowerAidl> gLineagePowerHalAidl_ = nullptr;
static sp<ISehMiscPower> gSehMiscPower = nullptr;
-static bool gPowerHalExists = true;
static std::mutex gPowerHalMutex;
static std::mutex gLineagePowerHalMutex;
@@ -136,9 +135,11 @@ static HalVersion connectPowerHalLocked() {
gPowerHalAidlExists = false;
}
}
- if (gPowerHalExists && gPowerHalHidlV1_0_ == nullptr) {
+ if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
+ ALOGE("Trying to connect to Samsung Power HAL");
gSehMiscPower = ISehMiscPower::getService();
gPowerHalHidlV1_0_ = IPowerV1_0::getService("miscpower");
+ ALOGE("Got miscpower = %d, SehMiscPower = %d", gPowerHalHidlV1_0_ != nullptr ? 1 : 0, gSehMiscPower ? 1 : 0);
}
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
@@ -545,7 +546,17 @@ static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring
static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
std::unique_lock<std::mutex> lock(gPowerHalMutex);
- switch (connectPowerHalLocked()) {
+
+ auto powerHalType = connectPowerHalLocked();
+ if(gSehMiscPower != nullptr) {
+ android::base::Timer t;
+ Return<void> ret = gSehMiscPower->setInteractiveAsync(enable, 0);
+ if(!ret.isOk()) {
+ ALOGE("set interactive async() failed: seh misc setInteractiveAsync");
+ }
+ }
+
+ switch (powerHalType) {
case HalVersion::NONE:
return;
case HalVersion::HIDL_1_0:
@@ -573,14 +584,6 @@ static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean
return;
}
}
- sp<ISehMiscPower> sehMiscPower = getSehMiscPower();
- if(sehMiscPower != nullptr) {
- android::base::Timer t;
- Return<void> ret = sehMiscPower->setInteractiveAsync(enable, 0);
- if(!ret.isOk()) {
- ALOGE("set interactive async() failed: seh misc setInteractiveAsync");
- }
- }
}
static void nativeSetAutoSuspend(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) {
--
2.25.1

View File

@ -0,0 +1,27 @@
From a54f02964ce04634fcf6178c8127800dfb1cfba6 Mon Sep 17 00:00:00 2001
From: Alberto Ponces <ponces26@gmail.com>
Date: Mon, 18 Jan 2021 09:23:57 +0000
Subject: [PATCH] KeyStore: Block key attestation for Google Play Services
Change-Id: Ia2cd58ea1abfdb1a2c0eb358442c36b5c6809c6b
---
keystore/java/android/security/KeyStore.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index 88b614dc7ee..de4e9ade191 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -1124,6 +1124,9 @@ public class KeyStore {
public int attestKey(
String alias, KeymasterArguments params, KeymasterCertificateChain outChain) {
+ if (mContext.getPackageName().equals("com.google.android.gms")) {
+ return KeymasterDefs.KM_ERROR_UNIMPLEMENTED; // Prevent Google Play Services from using key attestation for SafetyNet
+ }
CertificateChainPromise promise = new CertificateChainPromise();
try {
mBinder.asBinder().linkToDeath(promise, 0);
--
2.25.1

View File

@ -0,0 +1,28 @@
From d47fac84706c80d14989b6348808d2d6602a250d Mon Sep 17 00:00:00 2001
From: Alberto Ponces <ponces26@gmail.com>
Date: Tue, 2 Feb 2021 10:20:51 +0000
Subject: [PATCH 37/37] Fix Wakelock issue
Prevent SystemUI crash due to "WakeLock under-locked Doze" (issue #12) by only releasing a wakelock that was not already released
---
.../src/com/android/systemui/util/wakelock/WakeLock.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java b/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java
index 08cd6e38389..c54dca88dcf 100644
--- a/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java
+++ b/packages/SystemUI/src/com/android/systemui/util/wakelock/WakeLock.java
@@ -109,7 +109,9 @@ public interface WakeLock {
} else {
mActiveClients.put(why, count - 1);
}
- inner.release();
+ if (inner.isHeld()) {
+ inner.release();
+ }
}
/** @see PowerManager.WakeLock#wrap(Runnable) */
--
2.25.1

View File

@ -0,0 +1,37 @@
From 109bc691f314f18f923c5c72fc82ff072c77eca3 Mon Sep 17 00:00:00 2001
From: N Harish <kqn736@zebra.com>
Date: Mon, 25 Jan 2021 17:22:33 +0530
Subject: [PATCH 40/40] Fix for TestDirectBootEmulated testcase
In case of emulated FBE the secrets are empty hence add this
exception to prevent from unlocking userkey.
Bug: 177617301
Test: android.appsecurity.cts.DirectBootHostTest#testDirectBootEmulated
Change-Id: I5be2ceb61d9ef47219862e75cc8ec03ab5513426
(cherry picked from commit 2912b101aaa34abfa9637f2f00c992e7d129b994)
---
.../core/java/com/android/server/StorageManagerService.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 87afdac45dae..179899ee6067 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -3295,6 +3295,12 @@ class StorageManagerService extends IStorageManager.Stub
enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);
if (isFsEncrypted) {
+ // When a user has secure lock screen, require secret to actually unlock.
+ // This check is mostly in place for emulation mode.
+ if (StorageManager.isFileEncryptedEmulatedOnly() &&
+ mLockPatternUtils.isSecure(userId) && ArrayUtils.isEmpty(secret)) {
+ throw new IllegalStateException("Secret required to unlock secure user " + userId);
+ }
try {
mVold.unlockUserKey(userId, serialNumber, encodeBytes(token),
encodeBytes(secret));
--
2.25.1

View File

@ -0,0 +1,27 @@
From 8b9a1e5df3dd1b25b2cf9d83eca1353327697796 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 6 Mar 2021 18:39:15 -0500
Subject: [PATCH 41/41] Make secondary displays' lock screen black. Useful for
Moto Razr AOD
---
.../SystemUI/res-keyguard/layout/keyguard_presentation.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml b/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml
index f4d34f4ca141..58650b26ceaf 100644
--- a/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml
+++ b/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml
@@ -22,7 +22,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/presentation"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:background="@android:color/black">
<!-- This is mostly keyguard_status_view.xml with minor modifications -->
<com.android.keyguard.KeyguardStatusView
android:id="@+id/clock"
--
2.25.1

View File

@ -0,0 +1,46 @@
From e202b51e3522636dade7a0ede8688ccd38306468 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 13 Mar 2021 13:21:46 -0500
Subject: [PATCH 42/45] On Samsung R vendor, there is still the ISehMiscPower
HIDL HAL, but there is also the AOSP's AIDL HAL. It was previously assumed
this wouldn't happen, fix this assumption.
---
...om_android_server_power_PowerManagerService.cpp | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp
index 2ebff05d6c5c..c5d9aa94687e 100644
--- a/services/core/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp
@@ -112,6 +112,14 @@ static HalVersion connectPowerHalLocked() {
if (!gPowerHalHidlExists && !gPowerHalAidlExists) {
return HalVersion::NONE;
}
+ if (
+ gPowerHalAidl_ == nullptr &&
+ gPowerHalHidlV1_0_ == nullptr) {
+ ALOGE("Trying to connect to Samsung Power HAL");
+ gSehMiscPower = ISehMiscPower::getService();
+ gPowerHalHidlV1_0_ = IPowerV1_0::getService("miscpower");
+ ALOGE("Got miscpower = %d, SehMiscPower = %d", gPowerHalHidlV1_0_ != nullptr ? 1 : 0, gSehMiscPower ? 1 : 0);
+ }
if (gPowerHalAidlExists) {
if (!gPowerHalAidl_) {
gPowerHalAidl_ = waitForVintfService<IPowerAidl>();
@@ -123,12 +131,6 @@ static HalVersion connectPowerHalLocked() {
gPowerHalAidlExists = false;
}
}
- if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
- ALOGE("Trying to connect to Samsung Power HAL");
- gSehMiscPower = ISehMiscPower::getService();
- gPowerHalHidlV1_0_ = IPowerV1_0::getService("miscpower");
- ALOGE("Got miscpower = %d, SehMiscPower = %d", gPowerHalHidlV1_0_ != nullptr ? 1 : 0, gSehMiscPower ? 1 : 0);
- }
if (gPowerHalHidlExists && gPowerHalHidlV1_0_ == nullptr) {
gPowerHalHidlV1_0_ = IPowerV1_0::getService();
if (gPowerHalHidlV1_0_) {
--
2.25.1

View File

@ -0,0 +1,45 @@
From a4d9278457f0035b44a4b18e07a224d0a827e446 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 20 Mar 2021 14:30:17 +0100
Subject: [PATCH 43/45] Handle another type of Samsung proximity sensor: Hover
Proximity Sensor, with yet another behavior (seen on S20 FE)
---
.../server/display/DisplayPowerController.java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index bd41d38ad34c..0d160c37f6ea 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -540,6 +540,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mProximitySensor = sensor;
}
}
+ if(mProximitySensor == null) {
+ List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
+ for(Sensor sensor: sensors) {
+ if("com.samsung.sensor.hover_proximity".equals(sensor.getStringType()))
+ mProximitySensor = sensor;
+ }
+ }
if(mProximitySensor == null) {
List<Sensor> sensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
for(Sensor sensor: sensors) {
@@ -2055,6 +2062,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
handleProximitySensorEvent(time, positive);
return;
}
+ if("com.samsung.sensor.hover_proximity".equals(mProximitySensor.getStringType())) {
+ float v = event.values[0];
+ boolean positive = (v >= 0.5f && v <= 4.5);
+ android.util.Log.d("PHH", "Samsung hover sensor changed " + positive + ":" + v);
+ handleProximitySensorEvent(time, positive);
+ return;
+ }
final float distance = event.values[0];
boolean positive = distance >= 0.0f && distance < mProximityThreshold;
handleProximitySensorEvent(time, positive);
--
2.25.1

View File

@ -0,0 +1,49 @@
From b560c2bba2559c95a97ca614fa46d542be6d2858 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sat, 20 Mar 2021 14:31:01 +0100
Subject: [PATCH 44/45] Automatically detect pick up sensor, so that an overlay
is required for the sole purpose of enabling pulse doze on pick up sensor
---
.../display/AmbientDisplayConfiguration.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/core/java/android/hardware/display/AmbientDisplayConfiguration.java b/core/java/android/hardware/display/AmbientDisplayConfiguration.java
index ece5c28884fa..010fce24057d 100644
--- a/core/java/android/hardware/display/AmbientDisplayConfiguration.java
+++ b/core/java/android/hardware/display/AmbientDisplayConfiguration.java
@@ -23,6 +23,9 @@ import android.os.SystemProperties;
import android.provider.Settings;
import android.text.TextUtils;
+import android.hardware.SensorManager;
+import android.hardware.Sensor;
+
import com.android.internal.R;
/**
@@ -74,7 +77,20 @@ public class AmbientDisplayConfiguration {
/** {@hide} */
public boolean dozePickupSensorAvailable() {
- return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup);
+ SensorManager sm = mContext.getSystemService(SensorManager.class);
+ boolean found = false;
+ if(sm == null) {
+ android.util.Log.d("PHH", "Failed getting sensor manager, can't detect pickup sensor");
+ } else {
+ java.util.List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ALL);
+ for(Sensor s : sensors) {
+ if(Sensor.STRING_TYPE_PICK_UP_GESTURE.equals(s.getStringType())) {
+ found = true;
+ break;
+ }
+ }
+ }
+ return mContext.getResources().getBoolean(R.bool.config_dozePulsePickup) || found;
}
/** {@hide} */
--
2.25.1

View File

@ -0,0 +1,43 @@
From 575db4c47ba68a6355774abc815f2f4c8de7a996 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 23 Mar 2021 19:43:26 +0100
Subject: [PATCH 45/45] Catch broken mainBuiltInDisplayCutoutRectApproximation
Some devices (Redmi Note 9T) have:
mainBuiltInDisplayCutoutRectApproximation = @android:mainBuiltInDisplayCutout
Since mainBuiltInDisplayCutout is private, its ID is dynamic and can't
be relied upon.
This means that we'll get garbage in mainBuiltInDisplayCutoutRectApproximation
The SVG Path parser will fail, triggering an exception.
Fix it by catching it, and parsing mainBuiltInDisplayCutout instead
---
core/java/android/view/DisplayCutout.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/core/java/android/view/DisplayCutout.java b/core/java/android/view/DisplayCutout.java
index b4863f9c6dd0..e1d57e6869aa 100644
--- a/core/java/android/view/DisplayCutout.java
+++ b/core/java/android/view/DisplayCutout.java
@@ -681,9 +681,15 @@ public final class DisplayCutout {
* @hide
*/
public static DisplayCutout fromResourcesRectApproximation(Resources res, int displayWidth, int displayHeight) {
- return fromSpec(res.getString(R.string.config_mainBuiltInDisplayCutoutRectApproximation),
- displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
- loadWaterfallInset(res));
+ try {
+ return fromSpec(res.getString(R.string.config_mainBuiltInDisplayCutoutRectApproximation),
+ displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
+ loadWaterfallInset(res));
+ } catch(java.lang.IllegalArgumentException e) {
+ return fromSpec(res.getString(R.string.config_mainBuiltInDisplayCutout),
+ displayWidth, displayHeight, DENSITY_DEVICE_STABLE / (float) DENSITY_DEFAULT,
+ loadWaterfallInset(res));
+ }
}
/**
--
2.25.1

View File

@ -0,0 +1,24 @@
From 50edb017dc10058835e178885d432eb89ec7e131 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 19 Apr 2021 21:03:45 +0200
Subject: [PATCH 49/49] Fix build
---
.../java/com/android/server/display/DisplayPowerController.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 908c3b852fe1..550965ef7cd2 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -62,6 +62,7 @@ import com.android.server.display.whitebalance.DisplayWhiteBalanceController;
import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory;
import com.android.server.display.whitebalance.DisplayWhiteBalanceSettings;
import com.android.server.lights.LightsManager;
+import com.android.server.lights.LogicalLight;
import com.android.server.policy.WindowManagerPolicy;
import java.io.PrintWriter;
--
2.25.1

View File

@ -0,0 +1,32 @@
From d8fbdb4092155a1c8f8e2b2ee77b4fcfb7102367 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 12 Aug 2019 23:48:37 +0200
Subject: [PATCH 1/8] Some Samsung devices requires lying colorspace
Change-Id: I4153b8e7abc10c519565e4e4386c6388621477b2
---
opengl/libs/EGL/egl_platform_entries.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/opengl/libs/EGL/egl_platform_entries.cpp b/opengl/libs/EGL/egl_platform_entries.cpp
index aa24e8ee6..1c6380f6f 100644
--- a/opengl/libs/EGL/egl_platform_entries.cpp
+++ b/opengl/libs/EGL/egl_platform_entries.cpp
@@ -454,8 +454,14 @@ EGLBoolean eglGetConfigAttribImpl(EGLDisplay dpy, EGLConfig config,
// ----------------------------------------------------------------------------
// Translates EGL color spaces to Android data spaces.
+static int samsungColorspace = -1;
static android_dataspace dataSpaceFromEGLColorSpace(EGLint colorspace) {
+ if(samsungColorspace == -1) {
+ samsungColorspace = property_get_bool("persist.sys.phh.samsung_colorspace", false);
+ }
if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
+ if(samsungColorspace)
+ return HAL_DATASPACE_UNKNOWN;
return HAL_DATASPACE_UNKNOWN;
} else if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR) {
return HAL_DATASPACE_V0_SRGB;
--
2.17.1

View File

@ -0,0 +1,51 @@
From 61f5f4b804e8e14f15b928630489f22a5e7df04e Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 14 Aug 2019 23:37:10 +0200
Subject: [PATCH 2/8] On Samsung, we need to send a hack-message to HAL to get
all Sensors
Change-Id: Id6a1fa48340de61c418493668e9abd22c2599376
---
opengl/libs/EGL/egl_platform_entries.cpp | 2 +-
services/sensorservice/SensorDevice.cpp | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/opengl/libs/EGL/egl_platform_entries.cpp b/opengl/libs/EGL/egl_platform_entries.cpp
index 1c6380f6f..6e810e592 100644
--- a/opengl/libs/EGL/egl_platform_entries.cpp
+++ b/opengl/libs/EGL/egl_platform_entries.cpp
@@ -457,7 +457,7 @@ EGLBoolean eglGetConfigAttribImpl(EGLDisplay dpy, EGLConfig config,
static int samsungColorspace = -1;
static android_dataspace dataSpaceFromEGLColorSpace(EGLint colorspace) {
if(samsungColorspace == -1) {
- samsungColorspace = property_get_bool("persist.sys.phh.samsung_colorspace", false);
+ samsungColorspace = base::GetBoolProperty("persist.sys.phh.samsung_colorspace", false);
}
if (colorspace == EGL_GL_COLORSPACE_LINEAR_KHR) {
if(samsungColorspace)
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 8a282e238..53b686870 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -34,7 +34,9 @@
#include <cinttypes>
#include <thread>
+#include <android-base/properties.h>
using namespace android::hardware::sensors;
+
using namespace android::hardware::sensors::V1_0;
using namespace android::hardware::sensors::V1_0::implementation;
using android::hardware::sensors::V2_0::EventQueueFlagBits;
@@ -134,6 +136,8 @@ SensorDevice::SensorDevice()
void SensorDevice::initializeSensorList() {
float minPowerMa = 0.001; // 1 microAmp
+ if(::android::base::GetBoolProperty("persist.sys.phh.samsung_sensors", false))
+ setMode(5555);
checkReturn(mSensors->getSensorsList(
[&](const auto &list) {
const size_t count = list.size();
--
2.17.1

View File

@ -0,0 +1,42 @@
From 113f48e1e25d168e16e6a6717c7ea70fbef033e3 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Tue, 10 Mar 2020 23:26:55 +0100
Subject: [PATCH 3/8] Use BKK's hwcomposer hacks to properly display FOD layers
Insecure hack: Set FOD layers to magical Z values to trigger
OPPO/Realme/Oneplus' whole blitter behaviours:
- reports touch event to fingerprint driver
- removes dim on touched layer
Change-Id: I1d924b1e5c2389c8df17174c079cee8ef2380112
---
.../CompositionEngine/src/OutputLayer.cpp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index 1faf775ed..deb0b0923 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -370,7 +370,18 @@ void OutputLayer::writeOutputDependentGeometryStateToHWC(
static_cast<int32_t>(error));
}
- if (auto error = hwcLayer->setZOrder(outputDependentState.z); error != hal::Error::NONE) {
+ uint32_t z = outputDependentState.z;
+ if(strstr(getLayerFE().getDebugName(), "Fingerprint on display") != nullptr) {
+ ALOGE("Found fingerprint on display!");
+ z = 0x41000031;
+ }
+
+ if(strstr(getLayerFE().getDebugName(), "Fingerprint on display.touched") != nullptr) {
+ ALOGE("Found fingerprint on display touched!");
+ z = 0x41000033;
+ }
+
+ if (auto error = hwcLayer->setZOrder(z); error != hal::Error::NONE) {
ALOGE("[%s] Failed to set Z %u: %s (%d)", getLayerFE().getDebugName(),
outputDependentState.z, to_string(error).c_str(), static_cast<int32_t>(error));
}
--
2.17.1

View File

@ -0,0 +1,122 @@
From 0c7b289c3d724f32f4d64e8972736f3aa8e3261f Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 20 May 2020 21:16:56 +0200
Subject: [PATCH 4/8] Samsung + Xiaomi new FOD HBM controls
Change-Id: I5ab27fa70882efa85f0c917bf31bb32adaa09bb1
---
services/surfaceflinger/BufferQueueLayer.cpp | 19 ++++++++++++++++-
.../CompositionEngine/src/OutputLayer.cpp | 21 +++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp
index 07be7916e..472ceda4d 100644
--- a/services/surfaceflinger/BufferQueueLayer.cpp
+++ b/services/surfaceflinger/BufferQueueLayer.cpp
@@ -26,6 +26,7 @@
#include <compositionengine/LayerFECompositionState.h>
#include <gui/BufferQueueConsumer.h>
#include <system/window.h>
+#include <cutils/properties.h>
#include "LayerRejecter.h"
#include "SurfaceInterceptor.h"
@@ -34,6 +35,14 @@
#include "Scheduler/LayerHistory.h"
#include "TimeStats/TimeStats.h"
+static bool sCheckedProps = false;
+static bool sSamsungFod = false;
+static void init_fod_props() {
+ if(sCheckedProps) return;
+ sCheckedProps = true;
+ sSamsungFod = property_get_bool("persist.sys.phh.fod.samsung", false);
+}
+
namespace android {
BufferQueueLayer::BufferQueueLayer(const LayerCreationArgs& args) : BufferLayer(args) {}
@@ -486,6 +495,7 @@ void BufferQueueLayer::onFirstRef() {
mConsumer =
mFlinger->getFactory().createBufferLayerConsumer(consumer, mFlinger->getRenderEngine(),
mTextureName, this);
+ init_fod_props();
mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
mContentsChangedListener = new ContentsChangedListener(this);
@@ -509,9 +519,16 @@ status_t BufferQueueLayer::setDefaultBufferProperties(uint32_t w, uint32_t h, Pi
return BAD_VALUE;
}
+ init_fod_props();
+
setDefaultBufferSize(w, h);
mConsumer->setDefaultBufferFormat(format);
- mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
+ uint64_t usageBits = getEffectiveUsage(0);
+ if(sSamsungFod && strstr(mName.c_str(), "Fingerprint on display.touched") != nullptr) {
+ ALOGE("Found on touched layer!");
+ usageBits |= 0x400000000LL;
+ }
+ mConsumer->setConsumerUsageBits(usageBits);
return NO_ERROR;
}
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index deb0b0923..5f9620715 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -22,6 +22,7 @@
#include <compositionengine/impl/OutputCompositionState.h>
#include <compositionengine/impl/OutputLayer.h>
#include <compositionengine/impl/OutputLayerCompositionState.h>
+#include <cutils/properties.h>
// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic push
@@ -32,6 +33,10 @@
// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop // ignored "-Wconversion"
+static bool sCheckedProps = false;
+static bool sBBKFod = false;
+static bool sXiaomiFod = false;
+
namespace android::compositionengine {
OutputLayer::~OutputLayer() = default;
@@ -370,15 +375,31 @@ void OutputLayer::writeOutputDependentGeometryStateToHWC(
static_cast<int32_t>(error));
}
+ if(!sCheckedProps) {
+ sCheckedProps = true;
+ sBBKFod = property_get_bool("persist.sys.phh.fod.bbk", false);
+ sXiaomiFod = property_get_bool("persist.sys.phh.fod.xiaomi", false);
+ }
+
uint32_t z = outputDependentState.z;
if(strstr(getLayerFE().getDebugName(), "Fingerprint on display") != nullptr) {
ALOGE("Found fingerprint on display!");
z = 0x41000031;
+ if(sBBKFod) {
+ z = 0x41000031;
+ } else if(sXiaomiFod) {
+ z |= 0x1000000;
+ }
}
if(strstr(getLayerFE().getDebugName(), "Fingerprint on display.touched") != nullptr) {
ALOGE("Found fingerprint on display touched!");
z = 0x41000033;
+ if(sBBKFod) {
+ z = 0x41000033;
+ } else if(sXiaomiFod) {
+ z |= 0x2000000;
+ }
}
if (auto error = hwcLayer->setZOrder(z); error != hal::Error::NONE) {
--
2.17.1

View File

@ -0,0 +1,27 @@
From 15125c6d89352f46742c0e575556e43720e1c03c Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Fri, 11 Sep 2020 21:33:05 +0200
Subject: [PATCH 5/8] vr_hwc crashes because it registers a 2.3 hwc, while
manifest says 2.1
Change-Id: Icfaea3e471209e5773f52f880ffbcf5de744737e
---
services/vr/hardware_composer/manifest_vr_hwc.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/services/vr/hardware_composer/manifest_vr_hwc.xml b/services/vr/hardware_composer/manifest_vr_hwc.xml
index 1068cac33..6694ac086 100644
--- a/services/vr/hardware_composer/manifest_vr_hwc.xml
+++ b/services/vr/hardware_composer/manifest_vr_hwc.xml
@@ -2,7 +2,7 @@
<hal>
<name>android.hardware.graphics.composer</name>
<transport>hwbinder</transport>
- <version>2.1</version>
+ <version>2.3</version>
<interface>
<name>IComposer</name>
<instance>vr</instance>
--
2.17.1

View File

@ -0,0 +1,50 @@
From 1003d0293dc372b8fc0bbefe160f7d6a770b184b Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 30 Sep 2020 22:41:39 +0200
Subject: [PATCH 6/8] Add persist.sys.phh.no_present_or_validate property to
disable presentOrValidate since on vndk 26/27 presentOrValidate can be broken
Change-Id: I5f0c6c5e129bc21348d6f279d3ba455a5a0f008b
---
.../surfaceflinger/DisplayHardware/HWComposer.cpp | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 7a2f0f34e..1ea104521 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -34,6 +34,7 @@
#include <ui/GraphicBuffer.h>
#include <utils/Errors.h>
#include <utils/Trace.h>
+#include <android-base/properties.h>
#include "../Layer.h" // needed only for debugging
#include "../Promise.h"
@@ -500,12 +501,22 @@ status_t HWComposer::getDeviceCompositionChanges(
hal::Error error = hal::Error::NONE;
+ static int forceNoPresentOrValidate = -1;
+ if(forceNoPresentOrValidate == -1) {
+ bool res = android::base::GetBoolProperty("persist.sys.phh.no_present_or_validate", false);
+ if(res) {
+ forceNoPresentOrValidate = 1;
+ } else {
+ forceNoPresentOrValidate = 0;
+ }
+ }
+
// First try to skip validate altogether when there is no client
// composition. When there is client composition, since we haven't
// rendered to the client target yet, we should not attempt to skip
// validate.
displayData.validateWasSkipped = false;
- if (!frameUsesClientComposition) {
+ if (forceNoPresentOrValidate == 0 && !frameUsesClientComposition) {
sp<Fence> outPresentFence;
uint32_t state = UINT32_MAX;
error = hwcDisplay->presentOrValidate(&numTypes, &numRequests, &outPresentFence , &state);
--
2.17.1

View File

@ -0,0 +1,41 @@
From dc47d76a49d2a2d8dc2bd6bf68098cd910fcb364 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Wed, 30 Sep 2020 22:51:37 +0200
Subject: [PATCH 7/8] Add persist.sys.phh.disable_sensor_direct_report property
to disable Sensors direct report (it seems to break Qin 2 Pro sensors HAL)
Change-Id: I0763324a4bd6a3ba6716c396c4cb3f0772b85d62
---
services/sensorservice/SensorDevice.cpp | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 53b686870..87899e2cd 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -22,6 +22,7 @@
#include "convertV2_1.h"
#include <android-base/logging.h>
+#include <android-base/properties.h>
#include <android/util/ProtoOutputStream.h>
#include <frameworks/base/core/proto/android/service/sensor_service.proto.h>
#include <sensors/convert.h>
@@ -129,8 +130,12 @@ SensorDevice::SensorDevice()
initializeSensorList();
- mIsDirectReportSupported =
- (checkReturnAndGetStatus(mSensors->unregisterDirectChannel(-1)) != INVALID_OPERATION);
+ if(::android::base::GetBoolProperty("persist.sys.phh.disable_sensor_direct_report", false)) {
+ mIsDirectReportSupported = false;
+ } else {
+ mIsDirectReportSupported =
+ (checkReturnAndGetStatus(mSensors->unregisterDirectChannel(-1)) != INVALID_OPERATION);
+ }
}
void SensorDevice::initializeSensorList() {
--
2.17.1

Some files were not shown because too many files have changed in this diff Show More